From 6814c1d883791a1ad976f3146315de30e00dc0b9 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 19 Oct 2016 08:27:49 -0700 Subject: [PATCH 1/2] Forbid unused locals/parameters anywhere --- Jakefile.js | 2 +- lib/cancellationToken.js | 2 + lib/lib.d.ts | 12 +- lib/lib.dom.d.ts | 4 + lib/lib.dom.iterable.d.ts | 4 + lib/lib.es2015.collection.d.ts | 4 + lib/lib.es2015.core.d.ts | 4 + lib/lib.es2015.d.ts | 4 + lib/lib.es2015.generator.d.ts | 4 + lib/lib.es2015.iterable.d.ts | 4 + lib/lib.es2015.promise.d.ts | 4 + lib/lib.es2015.proxy.d.ts | 4 + lib/lib.es2015.reflect.d.ts | 4 + lib/lib.es2015.symbol.d.ts | 4 + lib/lib.es2015.symbol.wellknown.d.ts | 4 + lib/lib.es2016.array.include.d.ts | 4 + lib/lib.es2016.d.ts | 4 + lib/lib.es2017.d.ts | 4 + lib/lib.es2017.object.d.ts | 4 + lib/lib.es2017.sharedmemory.d.ts | 4 + lib/lib.es5.d.ts | 4 + lib/lib.es6.d.ts | 44 +- lib/lib.scripthost.d.ts | 4 + lib/lib.webworker.d.ts | 4 + lib/tsc.js | 16678 +++-- lib/tsserver.js | 58289 ++++++++-------- lib/tsserverlibrary.d.ts | 13056 +--- lib/tsserverlibrary.js | 37627 +++++----- lib/typescript.d.ts | 528 +- lib/typescript.js | 24671 +++---- lib/typescriptServices.d.ts | 528 +- lib/typescriptServices.js | 24671 +++---- lib/typingsInstaller.js | 1578 +- src/harness/fourslash.ts | 54 +- src/harness/harness.ts | 25 +- src/harness/harnessLanguageService.ts | 60 +- src/harness/loggedIO.ts | 26 +- src/harness/projectsRunner.ts | 4 +- src/harness/tsconfig.json | 4 +- .../unittests/cachingInServerLSHost.ts | 45 +- src/harness/unittests/jsDocParsing.ts | 2 +- src/harness/unittests/moduleResolution.ts | 10 +- .../unittests/reuseProgramStructure.ts | 18 +- .../unittests/services/documentRegistry.ts | 2 +- src/harness/unittests/session.ts | 18 +- .../unittests/tsserverProjectSystem.ts | 21 +- src/harness/unittests/typingsInstaller.ts | 22 +- src/server/builder.ts | 2 +- src/server/cancellationToken/tsconfig.json | 4 +- src/server/client.ts | 43 +- src/server/scriptVersionCache.ts | 8 +- src/server/server.ts | 12 +- src/server/session.ts | 8 +- src/server/tsconfig.json | 4 +- src/server/tsconfig.library.json | 4 +- src/server/typingsCache.ts | 4 +- .../typingsInstaller/nodeTypingsInstaller.ts | 2 +- src/server/typingsInstaller/tsconfig.json | 4 +- .../typingsInstaller/typingsInstaller.ts | 7 +- src/services/completions.ts | 18 +- src/services/findAllReferences.ts | 4 +- src/services/formatting/formatting.ts | 2 +- src/services/formatting/tokenRange.ts | 2 +- src/services/jsDoc.ts | 2 +- src/services/jsTyping.ts | 3 +- src/services/services.ts | 25 +- src/services/shims.ts | 9 +- src/services/transpile.ts | 10 +- src/services/tsconfig.json | 4 +- src/services/types.ts | 2 +- src/services/utilities.ts | 4 +- 71 files changed, 89546 insertions(+), 88718 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 301dc574eb634..cda7e2ca882ce 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -448,7 +448,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --stripInternal"; } - options += " --target es5"; + options += " --target es5 --noUnusedLocals --noUnusedParameters"; var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index 8af21172df4a0..f5a28f8d52d7d 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -39,3 +39,5 @@ function createCancellationToken(args) { }; } module.exports = createCancellationToken; + +//# sourceMappingURL=cancellationToken.js.map diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 922820b5d90a5..969bf70448c9a 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// ECMAScript APIs ///////////////////////////// @@ -4149,6 +4153,8 @@ interface Date { */ toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; } + + ///////////////////////////// /// IE DOM APIs @@ -18774,12 +18780,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; -type ScrollRestoration = "auto" | "manual"; +type ScrollRestoration = "auto" | "manual"; + + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// // These are only available in a Web Worker declare function importScripts(...urls: string[]): void; + + ///////////////////////////// diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 4c19c878064a5..b80f167b7a8be 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// IE DOM APIs diff --git a/lib/lib.dom.iterable.d.ts b/lib/lib.dom.iterable.d.ts index 397e0ab111ea2..2b62054765b15 100644 --- a/lib/lib.dom.iterable.d.ts +++ b/lib/lib.dom.iterable.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// interface DOMTokenList { diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 24c737df74b5f..eabd6319de6c7 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface Map { clear(): void; delete(key: K): boolean; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 669c80944ecfb..499d0de52db94 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + declare type PropertyKey = string | number | symbol; interface Array { diff --git a/lib/lib.es2015.d.ts b/lib/lib.es2015.d.ts index 973d518098985..ff5c555bfee88 100644 --- a/lib/lib.es2015.d.ts +++ b/lib/lib.es2015.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// /// diff --git a/lib/lib.es2015.generator.d.ts b/lib/lib.es2015.generator.d.ts index 003f325e4e03d..20d6725f66b1c 100644 --- a/lib/lib.es2015.generator.d.ts +++ b/lib/lib.es2015.generator.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface GeneratorFunction extends Function { } interface GeneratorFunctionConstructor { diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 1c27525d4326f..cb92cb4b8aac7 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// interface SymbolConstructor { diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index 36fe9e7777f22..02352da40611b 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /** * Represents the completion of an asynchronous operation */ diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index 3908e97c17c87..03996c6ad9fba 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface ProxyHandler { getPrototypeOf? (target: T): any; setPrototypeOf? (target: T, v: any): boolean; diff --git a/lib/lib.es2015.reflect.d.ts b/lib/lib.es2015.reflect.d.ts index 0f1a491ebcf2e..b6a6853457a90 100644 --- a/lib/lib.es2015.reflect.d.ts +++ b/lib/lib.es2015.reflect.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; diff --git a/lib/lib.es2015.symbol.d.ts b/lib/lib.es2015.symbol.d.ts index 4ab7b4374f126..c0474aec0118a 100644 --- a/lib/lib.es2015.symbol.d.ts +++ b/lib/lib.es2015.symbol.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface Symbol { /** Returns a string representation of an object. */ toString(): string; diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index 2d122d1284e3e..42299fe7d0969 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// interface SymbolConstructor { diff --git a/lib/lib.es2016.array.include.d.ts b/lib/lib.es2016.array.include.d.ts index a4677e7cf1e16..42b95c478d059 100644 --- a/lib/lib.es2016.array.include.d.ts +++ b/lib/lib.es2016.array.include.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface Array { /** * Determines whether an array includes a certain element, returning true or false as appropriate. diff --git a/lib/lib.es2016.d.ts b/lib/lib.es2016.d.ts index 04a2337967663..5921e060d0fe6 100644 --- a/lib/lib.es2016.d.ts +++ b/lib/lib.es2016.d.ts @@ -13,6 +13,10 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// \ No newline at end of file diff --git a/lib/lib.es2017.d.ts b/lib/lib.es2017.d.ts index 24d23994d962f..8354de37f7fd0 100644 --- a/lib/lib.es2017.d.ts +++ b/lib/lib.es2017.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// /// \ No newline at end of file diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index ac3a16ab37059..996147a974616 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface ObjectConstructor { /** * Returns an array of values of the enumerable properties of an object diff --git a/lib/lib.es2017.sharedmemory.d.ts b/lib/lib.es2017.sharedmemory.d.ts index 639ca7530e4cc..c59e1255519e1 100644 --- a/lib/lib.es2017.sharedmemory.d.ts +++ b/lib/lib.es2017.sharedmemory.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index a13ffc92d0407..2cf3f742522aa 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// ECMAScript APIs ///////////////////////////// diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 4c8806dd7dd48..1ace5f499b182 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// ECMAScript APIs ///////////////////////////// @@ -4149,6 +4153,8 @@ interface Date { */ toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; } + + declare type PropertyKey = string | number | symbol; interface Array { @@ -4673,6 +4679,8 @@ interface StringConstructor { */ raw(template: TemplateStringsArray, ...substitutions: any[]): string; } + + interface Map { clear(): void; delete(key: K): boolean; @@ -4745,6 +4753,8 @@ interface WeakSetConstructor { readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; + + interface GeneratorFunction extends Function { } interface GeneratorFunctionConstructor { @@ -4757,6 +4767,8 @@ interface GeneratorFunctionConstructor { readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; + + /// interface SymbolConstructor { @@ -5201,7 +5213,9 @@ interface Float64ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; -}/** +} + +/** * Represents the completion of an asynchronous operation */ interface Promise { @@ -5454,7 +5468,9 @@ interface PromiseConstructor { resolve(): Promise; } -declare var Promise: PromiseConstructor;interface ProxyHandler { +declare var Promise: PromiseConstructor; + +interface ProxyHandler { getPrototypeOf? (target: T): any; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; @@ -5475,7 +5491,9 @@ interface ProxyConstructor { revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; new (target: T, handler: ProxyHandler): T } -declare var Proxy: ProxyConstructor;declare namespace Reflect { +declare var Proxy: ProxyConstructor; + +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; @@ -5489,7 +5507,9 @@ declare var Proxy: ProxyConstructor;declare namespace Reflect { function preventExtensions(target: any): boolean; function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; -}interface Symbol { +} + +interface Symbol { /** Returns a string representation of an object. */ toString(): string; @@ -5524,7 +5544,9 @@ interface SymbolConstructor { keyFor(sym: symbol): string | undefined; } -declare var Symbol: SymbolConstructor;/// +declare var Symbol: SymbolConstructor; + +/// interface SymbolConstructor { /** @@ -5850,7 +5872,9 @@ interface Float32Array { */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; -} +} + + ///////////////////////////// /// IE DOM APIs ///////////////////////////// @@ -20475,12 +20499,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; -type ScrollRestoration = "auto" | "manual"; +type ScrollRestoration = "auto" | "manual"; + + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// // These are only available in a Web Worker declare function importScripts(...urls: string[]): void; + + ///////////////////////////// @@ -20772,6 +20800,8 @@ interface DateConstructor { interface Date { getVarDate: () => VarDate; } + + /// interface DOMTokenList { diff --git a/lib/lib.scripthost.d.ts b/lib/lib.scripthost.d.ts index b4e52a342f1ad..2d2f4df3b7080 100644 --- a/lib/lib.scripthost.d.ts +++ b/lib/lib.scripthost.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 6cb14c5b184a9..531295672563e 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// IE Worker APIs diff --git a/lib/tsc.js b/lib/tsc.js index b1fac7955d0a1..fbfe07a4588d2 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -15,6 +15,418 @@ and limitations under the License. var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -27,6 +439,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -41,6 +485,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -58,10 +662,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -72,7 +933,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -124,7 +985,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -145,7 +1013,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -187,6 +1055,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -330,13 +1204,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -437,6 +1330,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -449,8 +1354,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -483,8 +1388,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -703,8 +1608,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -805,7 +1710,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -836,7 +1741,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -861,11 +1766,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -928,7 +1833,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1081,7 +1986,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1378,7 +2283,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1393,7 +2298,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1503,6 +2408,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1566,10 +2479,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1591,6 +2504,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1903,7 +2823,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1975,6 +2895,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2116,7 +3041,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2132,9 +3057,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2922,7 +3847,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2959,139 +3884,139 @@ var ts; 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" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 69; + return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "abstract": 115, - "any": 117, - "as": 116, - "boolean": 120, - "break": 70, - "case": 71, - "catch": 72, - "class": 73, - "continue": 75, - "const": 74, - "constructor": 121, - "debugger": 76, - "declare": 122, - "default": 77, - "delete": 78, - "do": 79, - "else": 80, - "enum": 81, - "export": 82, - "extends": 83, - "false": 84, - "finally": 85, - "for": 86, - "from": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 44, - ">>>": 45, - "&": 46, - "|": 47, - "^": 48, - "!": 49, - "~": 50, - "&&": 51, - "||": 52, - "?": 53, - ":": 54, - "=": 56, - "+=": 57, - "-=": 58, - "*=": 59, - "**=": 60, - "/=": 61, - "%=": 62, - "<<=": 63, - ">>=": 64, - ">>>=": 65, - "&=": 66, - "|=": 67, - "^=": 68, - "@": 55 + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, }); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -3488,7 +4413,7 @@ var ts; return iterateCommentRanges(true, text, pos, true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -3554,8 +4479,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3574,7 +4499,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -3691,20 +4616,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; + resultingToken = startedWithBacktick ? 13 : 14; break; } if (currChar === 92) { @@ -3866,7 +4791,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69; + return token = 70; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -3941,12 +4866,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } pos++; - return token = 49; + return token = 50; case 34: case 39: tokenValue = scanString(); @@ -3955,68 +4880,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 67; } pos++; - return token = 46; + return token = 47; case 40: pos++; - return token = 17; + return token = 18; case 41: pos++; - return token = 18; + return token = 19; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 38; + return pos += 2, token = 39; } pos++; - return token = 37; + return token = 38; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } pos++; - return token = 35; + return token = 36; case 44: pos++; - return token = 24; + return token = 25; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } pos++; - return token = 36; + return token = 37; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; + return pos += 3, token = 23; } pos++; - return token = 21; + return token = 22; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -4060,10 +4985,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } pos++; - return token = 39; + return token = 40; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -4112,10 +5037,10 @@ var ts; return token = 8; case 58: pos++; - return token = 54; + return token = 55; case 59: pos++; - return token = 23; + return token = 24; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4128,20 +5053,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 64; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; + return pos += 2, token = 29; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; + return pos += 2, token = 27; } pos++; - return token = 25; + return token = 26; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4154,15 +5079,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; + return pos += 2, token = 35; } pos++; - return token = 56; + return token = 57; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4174,43 +5099,43 @@ var ts; } } pos++; - return token = 27; + return token = 28; case 63: pos++; - return token = 53; + return token = 54; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; + return pos += 2, token = 69; } pos++; - return token = 48; + return token = 49; case 123: pos++; - return token = 15; + return token = 16; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; + return pos += 2, token = 53; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; + return pos += 2, token = 68; } pos++; - return token = 47; + return token = 48; case 125: pos++; - return token = 16; + return token = 17; case 126: pos++; - return token = 50; + return token = 51; case 64: pos++; - return token = 55; + return token = 56; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -4248,29 +5173,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27) { + if (token === 28) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; + return pos += 3, token = 66; } - return pos += 2, token = 45; + return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } pos++; - return token = 44; + return token = 45; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 29; + return token = 30; } } return token; } function reScanSlashToken() { - if (token === 39 || token === 61) { + if (token === 40 || token === 62) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -4309,12 +5234,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10; + token = 11; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -4331,14 +5256,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 26; + return token = 27; } pos++; - return token = 25; + return token = 26; } if (char === 123) { pos++; - return token = 15; + return token = 16; } while (pos < end) { pos++; @@ -4347,7 +5272,7 @@ var ts; break; } } - return token = 244; + return token = 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -4394,39 +5319,39 @@ var ts; return token = 5; case 64: pos++; - return token = 55; + return token = 56; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 37; + return token = 38; case 123: pos++; - return token = 15; + return token = 16; case 125: pos++; - return token = 16; + return token = 17; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 61: pos++; - return token = 56; + return token = 57; case 44: pos++; - return token = 24; + return token = 25; } - if (isIdentifierStart(ch, 2)) { + if (isIdentifierStart(ch, 4)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { pos++; } - return token = 69; + return token = 70; } else { return pos += 1, token = 0; @@ -4647,11 +5572,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: return true; } return false; @@ -4772,13 +5697,13 @@ var ts; switch (node.kind) { case 9: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8: return node.text; @@ -4820,7 +5745,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 && + return node && node.kind === 226 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -4829,11 +5754,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 225 && (!node.body); + return node.kind === 226 && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 || - node.kind === 225 || + node.kind === 226 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -4848,7 +5773,7 @@ var ts; switch (node.parent.kind) { case 256: return ts.isExternalModule(node.parent); - case 226: + case 227: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -4857,21 +5782,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256: - case 227: + case 228: case 252: - case 225: - case 206: + case 226: case 207: case 208: - case 148: - case 147: + case 209: case 149: + case 148: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: return true; - case 199: + case 200: return parentNode && !isFunctionLike(parentNode); } return false; @@ -4889,7 +5814,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 && + declaration.kind === 219 && declaration.parent && declaration.parent.kind === 252; } @@ -4926,7 +5851,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199) { + if (node.body && node.body.kind === 200) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -4944,23 +5869,23 @@ var ts; return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 218: - case 169: - case 221: - case 192: + case 219: + case 170: case 222: + case 193: + case 223: + case 226: case 225: - case 224: case 255: - case 220: - case 179: - case 147: - case 149: + case 221: + case 180: + case 148: case 150: - case 223: + case 151: + case 224: errorNode = node.name; break; - case 180: + case 181: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -4981,7 +5906,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 && isConst(node); + return node.kind === 225 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -4994,11 +5919,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 && n.expression.kind === 95; + return n.kind === 175 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 && node.expression.kind === 9; + return node.kind === 203 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5014,10 +5939,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 || - node.kind === 141 || - node.kind === 179 || - node.kind === 180) ? + var commentRanges = (node.kind === 143 || + node.kind === 142 || + node.kind === 180 || + node.kind === 181) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -5032,69 +5957,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 <= node.kind && node.kind <= 166) { + if (155 <= node.kind && node.kind <= 167) { return true; } switch (node.kind) { - case 117: - case 130: - case 132: - case 120: + case 118: + case 131: case 133: - case 135: - case 127: + case 121: + case 134: + case 136: + case 128: return true; - case 103: - return node.parent.kind !== 183; - case 194: + case 104: + return node.parent.kind !== 184; + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 139 && node.parent.right === node) { + case 70: + if (node.parent.kind === 140 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 && node.parent.name === node) { + else if (node.parent.kind === 173 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 139 || node.kind === 172, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139: - case 172: - case 97: + ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140: + case 173: + case 98: var parent_1 = node.parent; - if (parent_1.kind === 158) { + if (parent_1.kind === 159) { return false; } - if (154 <= parent_1.kind && parent_1.kind <= 166) { + if (155 <= parent_1.kind && parent_1.kind <= 167) { return true; } switch (parent_1.kind) { - case 194: + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 141: + case 142: return node === parent_1.constraint; + case 146: case 145: - case 144: - case 142: - case 218: + case 143: + case 219: return node === parent_1.type; - case 220: - case 179: + case 221: case 180: + case 181: + case 149: case 148: case 147: - case 146: - case 149: case 150: - return node === parent_1.type; case 151: + return node === parent_1.type; case 152: case 153: + case 154: return node === parent_1.type; - case 177: + case 178: return node === parent_1.type; - case 174: case 175: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 176: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 177: return false; } } @@ -5105,22 +6030,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211: + case 212: return visitor(node); - case 227: - case 199: - case 203: + case 228: + case 200: case 204: case 205: case 206: case 207: case 208: - case 212: + case 209: case 213: + case 214: case 249: case 250: - case 214: - case 216: + case 215: + case 217: case 252: return ts.forEachChild(node, traverse); } @@ -5131,23 +6056,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190: + case 191: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224: - case 222: case 225: case 223: - case 221: - case 192: + case 226: + case 224: + case 222: + case 193: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 140) { + if (name_5 && name_5.kind === 141) { traverse(name_5.expression); return; } @@ -5162,14 +6087,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169: + case 170: case 255: - case 142: + case 143: case 253: + case 146: case 145: - case 144: case 254: - case 218: + case 219: return true; } } @@ -5177,11 +6102,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 || node.kind === 150); + return node && (node.kind === 150 || node.kind === 151); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 || node.kind === 192); + return node && (node.kind === 222 || node.kind === 193); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5190,19 +6115,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148: - case 179: - case 220: + case 149: case 180: + case 221: + case 181: + case 148: case 147: - case 146: - case 149: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return true; } return false; @@ -5210,13 +6135,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: + case 180: return true; } return false; @@ -5224,30 +6149,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206: case 207: case 208: - case 204: + case 209: case 205: + case 206: return true; - case 214: + case 215: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 && isFunctionLike(node.parent); + return node && node.kind === 200 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 && node.parent.kind === 171; + return node && node.kind === 148 && node.parent.kind === 172; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 && - (node.parent.kind === 171 || - node.parent.kind === 192); + return node.kind === 148 && + (node.parent.kind === 172 || + node.parent.kind === 193); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5283,38 +6208,38 @@ var ts; return undefined; } switch (node.kind) { - case 140: + case 141: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 180: + case 181: if (!includeArrowFunctions) { continue; } - case 220: - case 179: - case 225: - case 145: - case 144: - case 147: + case 221: + case 180: + case 226: case 146: + case 145: case 148: + case 147: case 149: case 150: case 151: case 152: case 153: - case 224: + case 154: + case 225: case 256: return node; } @@ -5328,25 +6253,25 @@ var ts; return node; } switch (node.kind) { - case 140: + case 141: node = node.parent; break; - case 220: - case 179: + case 221: case 180: + case 181: if (!stopOnFunctions) { continue; } - case 145: - case 144: - case 147: case 146: + case 145: case 148: + case 147: case 149: case 150: + case 151: return node; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -5358,14 +6283,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 || func.kind === 180) { + if (func.kind === 180 || func.kind === 181) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 178) { + while (parent_2.kind === 179) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 174 && parent_2.expression === prev) { + if (parent_2.kind === 175 && parent_2.expression === prev) { return parent_2; } } @@ -5373,20 +6298,20 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 || kind === 173) - && node.expression.kind === 95; + return (kind === 173 || kind === 174) + && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155: + case 156: return node.typeName; - case 194: + case 195: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69: - case 139: + case 70: + case 140: return node; } } @@ -5395,10 +6320,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174: case 175: case 176: - case 143: + case 177: + case 144: return true; default: return false; @@ -5406,7 +6331,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176) { + if (node.kind === 177) { return node.tag; } return node.expression; @@ -5414,21 +6339,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221: + case 222: return true; - case 145: - return node.parent.kind === 221; - case 149: + case 146: + return node.parent.kind === 222; case 150: - case 147: + case 151: + case 148: return node.body !== undefined - && node.parent.kind === 221; - case 142: + && node.parent.kind === 222; + case 143: return node.parent.body !== undefined - && (node.parent.kind === 148 - || node.parent.kind === 147 - || node.parent.kind === 150) - && node.parent.parent.kind === 221; + && (node.parent.kind === 149 + || node.parent.kind === 148 + || node.parent.kind === 151) + && node.parent.parent.kind === 222; } return false; } @@ -5444,18 +6369,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221: + case 222: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147: - case 150: + case 148: + case 151: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 || - parent.kind === 242 || + if (parent.kind === 244 || + parent.kind === 243 || parent.kind === 245) { return parent.tagName === node; } @@ -5464,97 +6389,97 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97: - case 95: - case 93: - case 99: - case 84: - case 10: - case 170: + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: case 171: case 172: case 173: case 174: case 175: case 176: - case 195: case 177: case 196: case 178: + case 197: case 179: - case 192: case 180: - case 183: + case 193: case 181: + case 184: case 182: - case 185: + case 183: case 186: case 187: case 188: - case 191: case 189: - case 11: - case 193: - case 241: - case 242: + case 192: case 190: - case 184: + case 12: + case 194: + case 242: + case 243: + case 191: + case 185: return true; - case 139: - while (node.parent.kind === 139) { + case 140: + while (node.parent.kind === 140) { node = node.parent; } - return node.parent.kind === 158 || isJSXTagName(node); - case 69: - if (node.parent.kind === 158 || isJSXTagName(node)) { + return node.parent.kind === 159 || isJSXTagName(node); + case 70: + if (node.parent.kind === 159 || isJSXTagName(node)) { return true; } case 8: case 9: - case 97: + case 98: var parent_3 = node.parent; switch (parent_3.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: case 255: case 253: - case 169: + case 170: return parent_3.initializer === node; - case 202: case 203: case 204: case 205: - case 211: + case 206: case 212: case 213: + case 214: case 249: - case 215: - case 213: + case 216: + case 214: return parent_3.expression === node; - case 206: + case 207: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || forStatement.condition === node || forStatement.incrementor === node; - case 207: case 208: + case 209: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || forInStatement.expression === node; - case 177: - case 195: + case 178: + case 196: return node === parent_3.expression; - case 197: + case 198: return node === parent_3.expression; - case 140: + case 141: return node === parent_3.expression; - case 143: + case 144: case 248: case 247: return true; - case 194: + case 195: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -5572,7 +6497,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind === 240; + return node.kind === 230 && node.moduleReference.kind === 241; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5581,7 +6506,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind !== 240; + return node.kind === 230 && node.moduleReference.kind !== 241; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5593,8 +6518,8 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 174 && - expression.expression.kind === 69 && + var isRequire = expression.kind === 175 && + expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); @@ -5605,9 +6530,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179; + return declaration.initializer && declaration.initializer.kind === 180; } return false; } @@ -5616,15 +6541,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 187) { + if (expression.kind !== 188) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 172) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { return 0; } var lhs = expr.left; - if (lhs.expression.kind === 69) { + if (lhs.expression.kind === 70) { var lhsId = lhs.expression; if (lhsId.text === "exports") { return 1; @@ -5633,12 +6558,12 @@ var ts; return 2; } } - else if (lhs.expression.kind === 97) { + else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 172) { + else if (lhs.expression.kind === 173) { var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69) { + if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { return 1; @@ -5652,35 +6577,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return node.moduleSpecifier; } - if (node.kind === 229) { + if (node.kind === 230) { var reference = node.moduleReference; - if (reference.kind === 240) { + if (reference.kind === 241) { return reference.expression; } } - if (node.kind === 236) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 225 && node.name.kind === 9) { + if (node.kind === 226 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 + return node.kind === 231 && node.importClause && !!node.importClause.name; } @@ -5688,13 +6613,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142: + case 143: + case 148: case 147: - case 146: case 254: case 253: + case 146: case 145: - case 144: return node.questionToken !== undefined; } } @@ -5755,24 +6680,24 @@ var ts; if (checkParentVariableStatement) { var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200; + node.parent.parent.parent.kind === 201; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200; + node.parent.parent.kind === 201; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 && - node.parent && node.parent.kind === 225) { + if (node.kind === 226 && + node.parent && node.parent.kind === 226) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 && - parent_4.operatorToken.kind === 56 && - parent_4.parent.kind === 202; + parent_4.kind === 188 && + parent_4.operatorToken.kind === 57 && + parent_4.parent.kind === 203; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -5780,7 +6705,7 @@ var ts; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 142) { + if (node.kind === 143) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -5810,7 +6735,7 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69) { + else if (param.name.kind === 70) { var name_6 = param.name.text; var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_6; }); if (paramTags) { @@ -5834,7 +6759,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { + if (parameter.name && parameter.name.kind === 70) { var parameterName = parameter.name.text; var jsDocTags = getJSDocTags(parameter.parent, true); if (!jsDocTags) { @@ -5879,12 +6804,12 @@ var ts; } ts.isDeclaredRestParam = isDeclaredRestParam; function isAssignmentTarget(node) { - while (node.parent.kind === 178) { + while (node.parent.kind === 179) { node = node.parent; } while (true) { var parent_5 = node.parent; - if (parent_5.kind === 170 || parent_5.kind === 191) { + if (parent_5.kind === 171 || parent_5.kind === 192) { node = parent_5; continue; } @@ -5892,10 +6817,10 @@ var ts; node = parent_5.parent; continue; } - return parent_5.kind === 187 && + return parent_5.kind === 188 && isAssignmentOperator(parent_5.operatorToken.kind) && parent_5.left === node || - (parent_5.kind === 207 || parent_5.kind === 208) && + (parent_5.kind === 208 || parent_5.kind === 209) && parent_5.initializer === node; } } @@ -5920,11 +6845,11 @@ var ts; } ts.isInAmbientContext = isInAmbientContext; function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 234 || parent.kind === 238) { + if (parent.kind === 235 || parent.kind === 239) { if (parent.propertyName) { return true; } @@ -5937,48 +6862,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 140 && + node.parent.kind === 141 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { + case 146: case 145: - case 144: + case 148: case 147: - case 146: - case 149: case 150: + case 151: case 255: case 253: - case 172: + case 173: return parent.name === node; - case 139: + case 140: if (parent.right === node) { - while (parent.kind === 139) { + while (parent.kind === 140) { parent = parent.parent; } - return parent.kind === 158; + return parent.kind === 159; } return false; - case 169: - case 234: + case 170: + case 235: return parent.propertyName === node; - case 238: + case 239: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 229 || - node.kind === 228 || - node.kind === 231 && !!node.name || - node.kind === 232 || - node.kind === 234 || - node.kind === 238 || - node.kind === 235 && exportAssignmentIsAlias(node); + return node.kind === 230 || + node.kind === 229 || + node.kind === 232 && !!node.name || + node.kind === 233 || + node.kind === 235 || + node.kind === 239 || + node.kind === 236 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -5986,17 +6911,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); + var heritageClause = getHeritageClause(node.heritageClauses, 107); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6064,7 +6989,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 138; + return 71 <= token && token <= 139; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6084,7 +7009,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 && + return name.kind === 141 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6094,10 +7019,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { return name.text; } - if (name.kind === 140) { + if (name.kind === 141) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6115,22 +7040,26 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; + return node.kind === 70 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 128: + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: case 113: + case 111: + case 112: + case 129: + case 114: return true; } return false; @@ -6138,11 +7067,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142; + return root.kind === 143; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169) { + while (node.kind === 170) { node = node.parent.parent; } return node; @@ -6150,14 +7079,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 - || kind === 179 - || kind === 220 + return kind === 149 || kind === 180 - || kind === 147 - || kind === 149 + || kind === 221 + || kind === 181 + || kind === 148 || kind === 150 - || kind === 225 + || kind === 151 + || kind === 226 || kind === 256; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -6207,40 +7136,45 @@ var ts; return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(ts.Associativity || (ts.Associativity = {})); + var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175: + case 176: return hasArguments ? 0 : 1; - case 185: - case 182: + case 186: case 183: - case 181: case 184: - case 188: - case 190: + case 182: + case 185: + case 189: + case 191: return 1; - case 187: + case 188: switch (operator) { - case 38: - case 56: + case 39: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 1; } } @@ -6249,15 +7183,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187) { + if (expression.kind === 188) { return expression.operatorToken.kind; } - else if (expression.kind === 185 || expression.kind === 186) { + else if (expression.kind === 186 || expression.kind === 187) { return expression.operator; } else { @@ -6267,106 +7201,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97: - case 95: - case 69: - case 93: - case 99: - case 84: + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: case 8: case 9: - case 170: case 171: - case 179: + case 172: case 180: - case 192: - case 241: + case 181: + case 193: case 242: - case 10: + case 243: case 11: - case 189: - case 178: - case 193: + case 12: + case 190: + case 179: + case 194: return 19; - case 176: - case 172: + case 177: case 173: + case 174: return 18; - case 175: + case 176: return hasArguments ? 18 : 17; - case 174: + case 175: return 17; - case 186: + case 187: return 16; - case 185: - case 182: + case 186: case 183: - case 181: case 184: + case 182: + case 185: return 15; - case 187: + case 188: switch (operatorKind) { - case 49: case 50: + case 51: return 15; - case 38: - case 37: case 39: + case 38: case 40: + case 41: return 14; - case 35: case 36: + case 37: return 13; - case 43: case 44: case 45: + case 46: return 12; - case 25: - case 28: - case 27: + case 26: case 29: - case 90: + case 28: + case 30: case 91: + case 92: return 11; - case 30: - case 32: case 31: case 33: + case 32: + case 34: return 10; - case 46: + case 47: return 9; - case 48: + case 49: return 8; - case 47: + case 48: return 7; - case 51: - return 6; case 52: + return 6; + case 53: return 5; - case 56: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 3; - case 24: + case 25: return 0; default: return -1; } - case 188: + case 189: return 4; - case 190: - return 2; case 191: + return 2; + case 192: return 1; default: return -1; @@ -6630,7 +7564,7 @@ var ts; function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -6657,7 +7591,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -6746,7 +7680,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 && nodeIsPresent(member.body)) { + if (member.kind === 149 && nodeIsPresent(member.body)) { return member; } }); @@ -6773,11 +7707,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 && identifierIsThisKeyword(node); + return node && node.kind === 70 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97; + return id.originalKeywordKind === 98; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -6787,10 +7721,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149) { + if (accessor.kind === 150) { getAccessor = accessor; } - else if (accessor.kind === 150) { + else if (accessor.kind === 151) { setAccessor = accessor; } else { @@ -6799,7 +7733,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 || member.kind === 150) + if ((member.kind === 150 || member.kind === 151) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6810,10 +7744,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 && !getAccessor) { + if (member.kind === 150 && !getAccessor) { getAccessor = member; } - if (member.kind === 150 && !setAccessor) { + if (member.kind === 151 && !setAccessor) { setAccessor = member; } } @@ -7005,34 +7939,34 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113: return 32; - case 112: return 4; - case 111: return 16; - case 110: return 8; - case 115: return 128; - case 82: return 1; - case 122: return 2; - case 74: return 2048; - case 77: return 512; - case 118: return 256; - case 128: return 64; + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 129: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 - || token === 51 - || token === 49; + return token === 53 + || token === 52 + || token === 50; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 && token <= 68; + return token >= 57 && token <= 69; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 && - node.parent.token === 83 && + if (node.kind === 195 && + node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -7040,10 +7974,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56) { + if (node.operatorToken.kind === 57) { var kind = node.left.kind; - return kind === 171 - || kind === 170; + return kind === 172 + || kind === 171; } } return false; @@ -7054,7 +7988,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { + if (node.kind === 70) { return true; } else if (isPropertyAccessExpression(node)) { @@ -7069,21 +8003,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 || - node.kind === 172 && isEntityNameExpression(node.expression); + return node.kind === 70 || + node.kind === 173 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 && node.parent.right === node) || - (node.parent.kind === 172 && node.parent.name === node); + return (node.parent.kind === 140 && node.parent.right === node) || + (node.parent.kind === 173 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171) { + if (kind === 172) { return expression.properties.length === 0; } - if (kind === 170) { + if (kind === 171) { return expression.elements.length === 0; } return false; @@ -7207,49 +8141,49 @@ var ts; var kind = node.kind; if (kind === 9 || kind === 8 - || kind === 10 || kind === 11 - || kind === 69 - || kind === 97 - || kind === 95 - || kind === 99 - || kind === 84 - || kind === 93) { + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { return true; } - else if (kind === 172) { + else if (kind === 173) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173) { + else if (kind === 174) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 - || kind === 186) { + else if (kind === 186 + || kind === 187) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187) { - return node.operatorToken.kind !== 38 + else if (kind === 188) { + return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188) { + else if (kind === 189) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 - || kind === 182 - || kind === 181) { + else if (kind === 184 + || kind === 183 + || kind === 182) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170) { + else if (kind === 171) { return node.elements.length === 0; } - else if (kind === 171) { + else if (kind === 172) { return node.properties.length === 0; } - else if (kind === 174) { + else if (kind === 175) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -7355,7 +8289,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -7363,26 +8297,21 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 230: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } + case 231: + externalImports.push(node); break; - case 229: - if (node.moduleReference.kind === 240 && resolver.isReferencedAliasDeclaration(node)) { + case 230: + if (node.moduleReference.kind === 241) { externalImports.push(node); } break; - case 236: + case 237: if (node.moduleSpecifier) { if (!node.exportClause) { - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { + else { externalImports.push(node); } } @@ -7394,7 +8323,7 @@ var ts; } } break; - case 235: + case 236: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -7415,7 +8344,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 === 221 && declaration !== node) { + if (declaration.kind === 222 && declaration !== node) { return true; } } @@ -7433,15 +8362,15 @@ var ts; } ts.isNodeArray = isNodeArray; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11; + return node.kind === 12; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; + return 8 <= kind && kind <= 12; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; + return kind === 9 || kind === 12; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -7449,21 +8378,21 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; + return 12 <= kind && kind <= 15; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12; + return node.kind === 13; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 - || kind === 14; + return kind === 14 + || kind === 15; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { - return node.kind === 69; + return node.kind === 70; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -7475,87 +8404,87 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 139; + return node.kind === 140; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140; + return node.kind === 141; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 - || kind === 69; + return kind === 140 + || kind === 70; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9 || kind === 8 - || kind === 140; + || kind === 141; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 - || kind === 167 - || kind === 168; + return kind === 70 + || kind === 168 + || kind === 169; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 141; + return node.kind === 142; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142; + return node.kind === 143; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143; + return node.kind === 144; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 147; + return node.kind === 148; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 - || kind === 145 - || kind === 147 - || kind === 149 + return kind === 149 + || kind === 146 + || kind === 148 || kind === 150 - || kind === 153 - || kind === 198; + || kind === 151 + || kind === 154 + || kind === 199; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 || kind === 254 - || kind === 147 - || kind === 149 + || kind === 148 || kind === 150 - || kind === 239; + || kind === 151 + || kind === 240; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 154 && kind <= 166) - || kind === 117 - || kind === 130 - || kind === 120 - || kind === 132 + return (kind >= 155 && kind <= 167) + || kind === 118 + || kind === 131 + || kind === 121 || kind === 133 - || kind === 103 - || kind === 127 - || kind === 194; + || kind === 134 + || kind === 104 + || kind === 128 + || kind === 195; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -7564,94 +8493,94 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 - || kind === 167; + return kind === 169 + || kind === 168; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169; + return node.kind === 170; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 - || kind === 193; + return kind === 170 + || kind === 194; } ts.isArrayBindingElement = isArrayBindingElement; function isPropertyAccessExpression(node) { - return node.kind === 172; + return node.kind === 173; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173; + return node.kind === 174; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187; + return node.kind === 188; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174; + return node.kind === 175; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 - || kind === 11; + return kind === 190 + || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194; + return node.kind === 195; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 - || kind === 173 - || kind === 175 + return kind === 173 || kind === 174 - || kind === 241 - || kind === 242 || kind === 176 - || kind === 170 - || kind === 178 + || kind === 175 + || kind === 242 + || kind === 243 + || kind === 177 || kind === 171 - || kind === 192 || kind === 179 - || kind === 69 - || kind === 10 + || kind === 172 + || kind === 193 + || kind === 180 + || kind === 70 + || kind === 11 || kind === 8 || kind === 9 - || kind === 11 - || kind === 189 - || kind === 84 - || kind === 93 - || kind === 97 - || kind === 99 - || kind === 95 - || kind === 196; + || kind === 12 + || kind === 190 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 197; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 - || kind === 186 - || kind === 181 + return kind === 186 + || kind === 187 || kind === 182 || kind === 183 || kind === 184 - || kind === 177 + || kind === 185 + || kind === 178 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -7659,13 +8588,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 - || kind === 190 - || kind === 180 - || kind === 187 + return kind === 189 || kind === 191 - || kind === 195 - || kind === 193 + || kind === 181 + || kind === 188 + || kind === 192 + || kind === 196 + || kind === 194 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -7674,8 +8603,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 - || kind === 195; + return kind === 178 + || kind === 196; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -7692,15 +8621,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 197; + return node.kind === 198; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 199; + return node.kind === 200; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -7718,118 +8647,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218; + return node.kind === 219; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219; + return node.kind === 220; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227; + return node.kind === 228; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 - || kind === 225; + return kind === 227 + || kind === 226; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229; + return node.kind === 230; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231; + return node.kind === 232; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 - || kind === 232; + return kind === 234 + || kind === 233; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237; + return node.kind === 238; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238; + return node.kind === 239; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 || node.kind === 224; + return node.kind === 226 || node.kind === 225; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 - || kind === 169 - || kind === 221 - || kind === 192 - || kind === 148 - || kind === 224 - || kind === 255 - || kind === 238 - || kind === 220 - || kind === 179 - || kind === 149 - || kind === 231 - || kind === 229 - || kind === 234 + return kind === 181 + || kind === 170 || kind === 222 - || kind === 147 - || kind === 146 + || kind === 193 + || kind === 149 || kind === 225 - || kind === 228 + || kind === 255 + || kind === 239 + || kind === 221 + || kind === 180 + || kind === 150 || kind === 232 - || kind === 142 + || kind === 230 + || kind === 235 + || kind === 223 + || kind === 148 + || kind === 147 + || kind === 226 + || kind === 229 + || kind === 233 + || kind === 143 || kind === 253 + || kind === 146 || kind === 145 - || kind === 144 - || kind === 150 + || kind === 151 || kind === 254 - || kind === 223 - || kind === 141 - || kind === 218 + || kind === 224 + || kind === 142 + || kind === 219 || kind === 279; } function isDeclarationStatementKind(kind) { - return kind === 220 - || kind === 239 - || kind === 221 + return kind === 221 + || kind === 240 || kind === 222 || kind === 223 || kind === 224 || kind === 225 + || kind === 226 + || kind === 231 || kind === 230 - || kind === 229 + || kind === 237 || kind === 236 - || kind === 235 - || kind === 228; + || kind === 229; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 + return kind === 211 + || kind === 210 + || kind === 218 + || kind === 205 + || kind === 203 + || kind === 202 + || kind === 208 || kind === 209 - || kind === 217 + || kind === 207 || kind === 204 - || kind === 202 + || kind === 215 + || kind === 212 + || kind === 214 + || kind === 216 + || kind === 217 || kind === 201 - || kind === 207 - || kind === 208 || kind === 206 - || kind === 203 - || kind === 214 - || kind === 211 || kind === 213 - || kind === 215 - || kind === 216 - || kind === 200 - || kind === 205 - || kind === 212 || kind === 287; } function isDeclaration(node) { @@ -7848,18 +8777,18 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199; + || kind === 200; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 240 - || kind === 139 - || kind === 69; + return kind === 241 + || kind === 140 + || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 243; + return node.kind === 244; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -7868,17 +8797,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 - || kind === 69 - || kind === 172; + return kind === 98 + || kind === 70 + || kind === 173; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 + return kind === 242 || kind === 248 - || kind === 242 - || kind === 244; + || kind === 243 + || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -7938,7 +8867,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -8057,9 +8995,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141) { + if (d && d.kind === 142) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { return current; } } @@ -8067,11 +9005,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 148 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8079,14 +9017,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= ts.getModifierFlags(node); } return flags; @@ -8095,14 +9033,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= node.flags; } return flags; @@ -8195,7 +9133,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 : 84, location, undefined); + return createNode(value ? 100 : 85, location, undefined); } else if (typeof value === "string") { var node = createNode(9, location, undefined); @@ -8212,7 +9150,7 @@ var ts; ts.createLiteral = createLiteral; var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69, location); + var node = createNode(70, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0; @@ -8221,7 +9159,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 1; @@ -8234,7 +9172,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 2; @@ -8244,7 +9182,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = text; name.originalKeywordKind = 0; name.autoGenerateKind = 3; @@ -8254,7 +9192,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.original = node; name.text = ""; name.originalKeywordKind = 0; @@ -8269,22 +9207,22 @@ var ts; } ts.createToken = createToken; function createSuper() { - var node = createNode(95); + var node = createNode(96); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97, location); + var node = createNode(98, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93); + var node = createNode(94); return node; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(140, location); + var node = createNode(141, location); node.expression = expression; return node; } @@ -8301,7 +9239,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142, location, flags); + var node = createNode(143, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -8320,7 +9258,7 @@ var ts; } ts.updateParameterDeclaration = updateParameterDeclaration; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145, location); + var node = createNode(146, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8338,7 +9276,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147, location, flags); + var node = createNode(148, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -8358,7 +9296,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -8376,7 +9314,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8395,7 +9333,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8413,7 +9351,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(167, location); + var node = createNode(168, location); node.elements = createNodeArray(elements); return node; } @@ -8426,7 +9364,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(169, location); node.elements = createNodeArray(elements); return node; } @@ -8439,7 +9377,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169, location); + var node = createNode(170, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8455,7 +9393,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170, location); + var node = createNode(171, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -8471,7 +9409,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171, location); + var node = createNode(172, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -8487,7 +9425,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172, location, flags); + var node = createNode(173, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8504,7 +9442,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173, location); + var node = createNode(174, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -8518,7 +9456,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174, location, flags); + var node = createNode(175, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -8535,7 +9473,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -8550,7 +9488,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176, location); + var node = createNode(177, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -8564,7 +9502,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178, location); + var node = createNode(179, location); node.expression = expression; return node; } @@ -8576,9 +9514,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -8588,20 +9526,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(181, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); node.body = parenthesizeConciseBody(body); return node; } @@ -8614,7 +9552,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181, location); + var node = createNode(182, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8627,7 +9565,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182, location); + var node = createNode(183, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8640,7 +9578,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183, location); + var node = createNode(184, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8653,7 +9591,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8666,7 +9604,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185, location); + var node = createNode(186, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -8680,7 +9618,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186, location); + var node = createNode(187, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -8696,7 +9634,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187, location); + var node = createNode(188, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -8711,7 +9649,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188, location); + var node = createNode(189, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -8728,7 +9666,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189, location); + var node = createNode(190, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -8742,7 +9680,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190, location); + var node = createNode(191, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -8756,7 +9694,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191, location); + var node = createNode(192, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -8769,7 +9707,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192, location); + var node = createNode(193, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -8787,12 +9725,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193, location); + var node = createNode(194, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194, location); + var node = createNode(195, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -8806,7 +9744,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(197, location); + var node = createNode(198, location); node.expression = expression; node.literal = literal; return node; @@ -8820,7 +9758,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(199, location, flags); + var block = createNode(200, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -8836,7 +9774,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200, location, flags); + var node = createNode(201, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -8851,7 +9789,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(220, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -8864,7 +9802,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218, location, flags); + var node = createNode(219, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -8879,11 +9817,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201, location); + return createNode(202, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202, location, flags); + var node = createNode(203, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -8896,7 +9834,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203, location); + var node = createNode(204, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -8911,7 +9849,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204, location); + var node = createNode(205, location); node.statement = statement; node.expression = expression; return node; @@ -8925,7 +9863,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205, location); + var node = createNode(206, location); node.expression = expression; node.statement = statement; return node; @@ -8939,7 +9877,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206, location, undefined); + var node = createNode(207, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -8955,7 +9893,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207, location); + var node = createNode(208, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -8970,7 +9908,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -8985,7 +9923,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209, location); + var node = createNode(210, location); if (label) { node.label = label; } @@ -9000,7 +9938,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210, location); + var node = createNode(211, location); if (label) { node.label = label; } @@ -9015,7 +9953,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211, location); + var node = createNode(212, location); node.expression = expression; return node; } @@ -9028,7 +9966,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.expression = expression; node.statement = statement; return node; @@ -9042,7 +9980,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -9056,7 +9994,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214, location); + var node = createNode(215, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -9070,7 +10008,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -9083,7 +10021,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9098,7 +10036,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227, location); + var node = createNode(228, location); node.clauses = createNodeArray(clauses); return node; } @@ -9111,7 +10049,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(221, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -9131,7 +10069,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -9149,7 +10087,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230, location); + var node = createNode(231, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -9165,7 +10103,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231, location); + var node = createNode(232, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -9179,7 +10117,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.name = name; return node; } @@ -9192,7 +10130,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233, location); + var node = createNode(234, location); node.elements = createNodeArray(elements); return node; } @@ -9205,7 +10143,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234, location); + var node = createNode(235, location); node.propertyName = propertyName; node.name = name; return node; @@ -9219,7 +10157,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -9235,7 +10173,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -9251,7 +10189,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -9264,7 +10202,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -9278,7 +10216,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9293,7 +10231,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9307,7 +10245,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9541,47 +10479,47 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createComma(left, right) { - return createBinary(left, 24, right); + return createBinary(left, 25, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25, right, location); + return createBinary(left, 26, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56, right, location); + return createBinary(left, 57, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32, right); + return createBinary(left, 33, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41, location); + return createPostfix(operand, 42, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51, right); + return createBinary(left, 52, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49, operand); + return createPrefix(50, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -9600,7 +10538,7 @@ var ts; } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -9714,7 +10652,7 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + var generatorFunc = createFunctionExpression(undefined, createToken(38), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), @@ -9758,7 +10696,7 @@ var ts; setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, [ + createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ createParameter("geti"), createParameter("seti") ], undefined, createBlock([ @@ -9780,19 +10718,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69: + case 70: return cacheIdentifiers; - case 97: + case 98: case 8: case 9: return false; - case 170: + case 171: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171: + case 172: return target.properties.length > 0; default: return true; @@ -9806,13 +10744,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95) { + else if (callee.kind === 96) { thisArg = createThis(); target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; } else { switch (callee.kind) { - case 172: { + case 173: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -9823,7 +10761,7 @@ var ts; } break; } - case 173: { + case 174: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -9873,14 +10811,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149: case 150: + case 151: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253: return createExpressionForPropertyAssignment(property, receiver); case 254: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147: + case 148: return createExpressionForMethodDeclaration(property, receiver); } } @@ -9890,13 +10828,13 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); + var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); setOriginalNode(getterFunction, getAccessor); var getter = createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); + var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); setOriginalNode(setterFunction, setAccessor); var setter = createPropertyAssignment("set", setterFunction); properties_1.push(setter); @@ -9919,13 +10857,13 @@ var ts; return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -9938,16 +10876,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -9978,7 +10920,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 178) { + if (skipped.kind === 179) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -9987,15 +10929,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 190) { + && operand.kind === 191) { return false; } return true; @@ -10011,7 +10953,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 35) { + if (binaryOperator === 36) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -10024,17 +10966,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 37 + return binaryOperator === 38 + || binaryOperator === 48 || binaryOperator === 47 - || binaryOperator === 46 - || binaryOperator === 48; + || binaryOperator === 49; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 && node.operatorToken.kind === 35) { + if (node.kind === 188 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -10051,9 +10993,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174: - return createParen(expression); case 175: + return createParen(expression); + case 176: return emittedExpression.arguments ? expression : createParen(expression); @@ -10064,7 +11006,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 || emittedExpression.arguments) + && (emittedExpression.kind !== 176 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -10102,7 +11044,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187, 24); + var commaPrecedence = ts.getOperatorPrecedence(188, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -10113,7 +11055,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 || kind === 180) { + if (kind === 180 || kind === 181) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -10121,7 +11063,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 || leftmostExpressionKind === 179) { + if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { return createParen(expression, expression); } } @@ -10139,18 +11081,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186: + case 187: node = node.operand; continue; - case 187: + case 188: node = node.left; continue; - case 188: + case 189: node = node.condition; continue; + case 175: case 174: case 173: - case 172: node = node.expression; continue; case 288: @@ -10162,12 +11104,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171) { + if (emittedBody.kind === 172) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + var OuterExpressionKinds = ts.OuterExpressionKinds; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -10187,7 +11136,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178) { + while (node.kind === 179) { node = node.expression; } return node; @@ -10350,10 +11299,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 && node.importClause) { + if (node.kind === 231 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 && node.moduleSpecifier) { + if (node.kind === 237 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -10402,10 +11351,10 @@ var ts; if (kind === 256) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69) { + else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139) { + else if (kind < 140) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -10441,10 +11390,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139: + case 140: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141: + case 142: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -10455,12 +11404,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142: + case 143: + case 146: case 145: - case 144: case 253: - case 218: - case 169: + case 219: + case 170: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -10469,24 +11418,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156: case 157: - case 151: + case 158: case 152: case 153: + case 154: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: + case 221: + case 181: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -10497,176 +11446,176 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155: + case 156: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154: + case 155: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158: - return visitNode(cbNode, node.exprName); case 159: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 160: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 161: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 162: + return visitNodes(cbNodes, node.elementTypes); case 163: - return visitNodes(cbNodes, node.types); case 164: + return visitNodes(cbNodes, node.types); + case 165: return visitNode(cbNode, node.type); - case 166: - return visitNode(cbNode, node.literal); case 167: + return visitNode(cbNode, node.literal); case 168: - return visitNodes(cbNodes, node.elements); - case 170: + case 169: return visitNodes(cbNodes, node.elements); case 171: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 172: + return visitNodes(cbNodes, node.properties); + case 173: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 173: + case 174: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 174: case 175: + case 176: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176: + case 177: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177: + case 178: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 181: + case 179: return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); case 183: return visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.operand); - case 190: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 184: return visitNode(cbNode, node.expression); case 186: return visitNode(cbNode, node.operand); + case 191: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 185: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.operand); + case 188: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 188: + case 189: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191: + case 192: return visitNode(cbNode, node.expression); - case 199: - case 226: + case 200: + case 227: return visitNodes(cbNodes, node.statements); case 256: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200: + case 201: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219: + case 220: return visitNodes(cbNodes, node.declarations); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204: + case 205: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205: + case 206: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 206: + case 207: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 207: + case 208: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208: + case 209: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209: case 210: - return visitNode(cbNode, node.label); case 211: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.label); case 212: + return visitNode(cbNode, node.expression); + case 213: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213: + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227: + case 228: return visitNodes(cbNodes, node.clauses); case 249: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250: return visitNodes(cbNodes, node.statements); - case 214: + case 215: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 221: - case 192: + case 222: + case 193: 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 222: + case 223: 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 223: + case 224: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -10674,65 +11623,65 @@ var ts; case 255: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229: + case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231: + case 232: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228: - return visitNode(cbNode, node.name); - case 232: + case 229: return visitNode(cbNode, node.name); case 233: - case 237: + return visitNode(cbNode, node.name); + case 234: + case 238: return visitNodes(cbNodes, node.elements); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234: - case 238: + case 235: + case 239: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189: + case 190: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140: + case 141: return visitNode(cbNode, node.expression); case 251: return visitNodes(cbNodes, node.types); - case 194: + case 195: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240: + case 241: return visitNode(cbNode, node.expression); - case 239: + case 240: return visitNodes(cbNodes, node.decorators); - case 241: + case 242: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242: case 243: + case 244: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246: @@ -10834,7 +11783,7 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(2, true); + var scanner = ts.createScanner(4, true); var disallowInAndDecoratorContext = 32768 | 131072; var NodeConstructor; var TokenConstructor; @@ -10851,9 +11800,9 @@ var ts; var parsingContext; var contextFlags; var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -10862,7 +11811,7 @@ var ts; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -11105,16 +12054,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 69) { + if (token() === 70) { return true; } - if (token() === 114 && inYieldContext()) { + if (token() === 115 && inYieldContext()) { return false; } - if (token() === 119 && inAwaitContext()) { + if (token() === 120 && inAwaitContext()) { return false; } - return token() > 105; + return token() > 106; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -11155,20 +12104,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 23) { + if (token() === 24) { return true; } - return token() === 16 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23) { + if (token() === 24) { nextToken(); } return true; } else { - return parseExpected(23); + return parseExpected(24); } } function createNode(kind, pos) { @@ -11176,8 +12125,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 ? new NodeConstructor(kind, pos, pos) : - kind === 69 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -11218,15 +12167,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69); - if (token() !== 69) { + var node = createNode(70); + if (token() !== 70) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -11243,7 +12192,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 19) { + if (allowComputedPropertyNames && token() === 20) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -11258,10 +12207,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(140); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(141); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); return finishNode(node); } function parseContextualModifier(t) { @@ -11275,20 +12224,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74) { - return nextToken() === 81; + if (token() === 75) { + return nextToken() === 82; } - if (token() === 82) { + if (token() === 83) { nextToken(); - if (token() === 77) { + if (token() === 78) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 && token() !== 116 && token() !== 15 && canFollowModifier(); + return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); } - if (token() === 77) { + if (token() === 78) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113) { + if (token() === 114) { nextToken(); return canFollowModifier(); } @@ -11298,16 +12247,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 - || token() === 15 - || token() === 37 - || token() === 22 + return token() === 20 + || token() === 16 + || token() === 38 + || token() === 23 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 || token() === 87 || - (token() === 118 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 || token() === 88 || + (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -11318,21 +12267,21 @@ var ts; case 0: case 1: case 3: - return !(token() === 23 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 71 || token() === 77; + return token() === 72 || token() === 78; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 23 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); case 6: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 19 || token() === 37 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || isLiteralPropertyName(); case 9: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 7: - if (token() === 15) { + if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -11344,23 +12293,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 24 || token() === 22 || isIdentifierOrPattern(); + return token() === 25 || token() === 23 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token() === 24 || token() === 22 || isStartOfExpression(); + return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token() === 24 || isStartOfType(); + return token() === 25 || isStartOfType(); case 20: return isHeritageClause(); case 21: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; case 22: @@ -11373,10 +12322,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15); - if (nextToken() === 16) { + ts.Debug.assert(token() === 16); + if (nextToken() === 17) { var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; + return next === 25 || next === 16 || next === 84 || next === 107; } return true; } @@ -11389,8 +12338,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 || - token() === 83) { + if (token() === 107 || + token() === 84) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -11412,39 +12361,39 @@ var ts; case 12: case 9: case 21: - return token() === 16; + return token() === 17; case 3: - return token() === 16 || token() === 71 || token() === 77; + return token() === 17 || token() === 72 || token() === 78; case 7: - return token() === 15 || token() === 83 || token() === 106; + return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token() === 27 || token() === 17 || token() === 15 || token() === 83 || token() === 106; + return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: - return token() === 18 || token() === 23; + return token() === 19 || token() === 24; case 15: case 19: case 10: - return token() === 20; + return token() === 21; case 16: - return token() === 18 || token() === 20; + return token() === 19 || token() === 21; case 18: - return token() !== 24; + return token() !== 25; case 20: - return token() === 15 || token() === 16; + return token() === 16 || token() === 17; case 13: - return token() === 27 || token() === 39; + return token() === 28 || token() === 40; case 14: - return token() === 25 && lookAhead(nextTokenIsSlash); + return token() === 26 && lookAhead(nextTokenIsSlash); case 22: - return token() === 18 || token() === 54 || token() === 16; + return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 27 || token() === 16; + return token() === 28 || token() === 17; case 25: - return token() === 20 || token() === 16; + return token() === 21 || token() === 17; case 24: - return token() === 16; + return token() === 17; } } function isVariableDeclaratorListTerminator() { @@ -11454,7 +12403,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 34) { + if (token() === 35) { return true; } return false; @@ -11558,17 +12507,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148: - case 153: case 149: + case 154: case 150: - case 145: - case 198: + case 151: + case 146: + case 199: return true; - case 147: + case 148: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; + var nameIsConstructor = methodDeclaration.name.kind === 70 && + methodDeclaration.name.originalKeywordKind === 122; return !nameIsConstructor; } } @@ -11587,35 +12536,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220: + case 221: + case 201: case 200: - case 199: + case 204: case 203: - case 202: - case 215: + case 216: + case 212: + case 214: case 211: - case 213: case 210: + case 208: case 209: case 207: - case 208: case 206: - case 205: - case 212: - case 201: - case 216: - case 214: - case 204: + case 213: + case 202: case 217: + case 215: + case 205: + case 218: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 225: - case 221: + case 226: case 222: - case 224: case 223: + case 225: + case 224: return true; } } @@ -11627,25 +12576,25 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152: - case 146: case 153: - case 144: - case 151: + case 147: + case 154: + case 145: + case 152: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218) { + if (node.kind !== 219) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var parameter = node; @@ -11699,15 +12648,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { + if (parseOptional(25)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(24); - if (considerSemicolonAsDelimiter && token() === 23 && !scanner.hasPrecedingLineBreak()) { + parseExpected(25); + if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -11739,8 +12688,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(139, entity.pos); + while (parseOptional(22)) { + var node = createNode(140, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -11751,33 +12700,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189); + var template = createNode(190); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197); + var span = createNode(198); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16) { + if (token() === 17) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); } span.literal = literal; return finishNode(span); @@ -11787,12 +12736,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -11817,35 +12766,35 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(155, typeName.pos); + var node = createNode(156, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (!scanner.hasPrecedingLineBreak() && token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154, lhs.pos); + var node = createNode(155, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165); + var node = createNode(166); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158); - parseExpected(101); + var node = createNode(159); + parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141); + var node = createNode(142); node.name = parseIdentifier(); - if (parseOptional(83)) { + if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -11856,34 +12805,34 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); + if (token() === 26) { + return parseBracketedList(17, parseTypeParameter, 26, 28); } } function parseParameterType() { - if (parseOptional(54)) { + if (parseOptional(55)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 || token() === 97; + return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(142); - if (token() === 97) { + var node = createNode(143); + if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(53); + node.questionToken = parseOptionalToken(54); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -11895,7 +12844,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; + var returnTokenRequired = returnToken === 35; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -11907,7 +12856,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { + if (parseExpected(18)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -11915,7 +12864,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { + if (!parseExpected(19) && requireCompleteParameterList) { return undefined; } return result; @@ -11923,29 +12872,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(24)) { + if (parseOptional(25)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152) { - parseExpected(92); + if (kind === 153) { + parseExpected(93); } - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19) { + if (token() !== 20) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 22 || token() === 20) { + if (token() === 23 || token() === 21) { return true; } if (ts.isModifierKind(token())) { @@ -11960,43 +12909,43 @@ var ts; else { nextToken(); } - if (token() === 54 || token() === 24) { + if (token() === 55 || token() === 25) { return true; } - if (token() !== 53) { + if (token() !== 54) { return false; } nextToken(); - return token() === 54 || token() === 24 || token() === 20; + return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153, fullStart); + var node = createNode(154, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.parameters = parseBracketedList(16, parseParameter, 20, 21); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token() === 17 || token() === 25) { - var method = createNode(146, fullStart); + var questionToken = parseOptionalToken(54); + if (token() === 18 || token() === 26) { + var method = createNode(147, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(54, false, false, false, method); + fillSignature(55, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144, fullStart); + var property = createNode(145, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56) { + if (token() === 57) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -12005,14 +12954,14 @@ var ts; } function isTypeMemberStart() { var idToken; - if (token() === 17 || token() === 25) { + if (token() === 18 || token() === 26) { return true; } while (ts.isModifierKind(token())) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (isLiteralPropertyName()) { @@ -12020,22 +12969,22 @@ var ts; nextToken(); } if (idToken) { - return token() === 17 || - token() === 25 || - token() === 53 || + return token() === 18 || + token() === 26 || token() === 54 || - token() === 24 || + token() === 55 || + token() === 25 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 || token() === 25) { - return parseSignatureMember(151); - } - if (token() === 92 && lookAhead(isStartOfConstructSignature)) { + if (token() === 18 || token() === 26) { return parseSignatureMember(152); } + if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -12045,18 +12994,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 || token() === 25; + return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(159); + var node = createNode(160); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15)) { + if (parseExpected(16)) { members = parseList(4, parseTypeMember); - parseExpected(16); + parseExpected(17); } else { members = createMissingList(); @@ -12064,31 +13013,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); + var node = createNode(162); + node.elementTypes = parseBracketedList(19, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164); - parseExpected(17); - node.type = parseType(); + var node = createNode(165); parseExpected(18); + node.type = parseType(); + parseExpected(19); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157) { - parseExpected(92); + if (kind === 158) { + parseExpected(93); } - fillSignature(34, false, false, false, node); + fillSignature(35, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 ? undefined : node; + return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166); + var node = createNode(167); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -12098,41 +13047,41 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 135: - case 127: + case 131: + case 121: + case 134: + case 136: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseLiteralTypeNode(); - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103: - case 93: + case 104: + case 94: return parseTokenNode(); - case 97: { + case 98: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101: + case 102: return parseTypeQuery(); - case 15: + case 16: return parseTypeLiteral(); - case 19: + case 20: return parseTupleType(); - case 17: + case 18: return parseParenthesizedType(); default: return parseTypeReference(); @@ -12140,29 +13089,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 98: + case 102: + case 128: + case 16: + case 20: + case 26: case 93: - case 97: - case 101: - case 127: - case 15: - case 19: - case 25: - case 92: case 9: case 8: - case 99: - case 84: + case 100: + case 85: return true; - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral); - case 17: + case 18: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -12170,13 +13119,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 || isStartOfParameter() || isStartOfType(); + return token() === 19 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(160, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + parseExpected(21); + var node = createNode(161, type.pos); node.elementType = type; type = finishNode(node); } @@ -12197,26 +13146,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { - if (token() === 25) { + if (token() === 26) { return true; } - return token() === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 97) { + if (isIdentifier() || token() === 98) { nextToken(); return true; } - if (token() === 19 || token() === 15) { + if (token() === 20 || token() === 16) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -12225,17 +13174,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 || token() === 22) { + if (token() === 19 || token() === 23) { return true; } if (skipParameterStart()) { - if (token() === 54 || token() === 24 || - token() === 53 || token() === 56) { + if (token() === 55 || token() === 25 || + token() === 54 || token() === 57) { return true; } - if (token() === 18) { + if (token() === 19) { nextToken(); - if (token() === 34) { + if (token() === 35) { return true; } } @@ -12246,7 +13195,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154, typePredicateVariable.pos); + var node = createNode(155, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -12257,7 +13206,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -12267,36 +13216,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156); - } - if (token() === 92) { return parseFunctionOrConstructorType(157); } + if (token() === 93) { + return parseFunctionOrConstructorType(158); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; + return parseOptional(55) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: case 8: case 9: - case 11: case 12: - case 17: - case 19: - case 15: - case 87: - case 73: - case 92: - case 39: - case 61: - case 69: + case 13: + case 18: + case 20: + case 16: + case 88: + case 74: + case 93: + case 40: + case 62: + case 70: return true; default: return isIdentifier(); @@ -12307,18 +13256,18 @@ var ts; return true; } switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 41: + case 79: + case 102: + case 104: case 42: - case 25: - case 119: - case 114: + case 43: + case 26: + case 120: + case 115: return true; default: if (isBinaryOperator()) { @@ -12328,10 +13277,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 15 && - token() !== 87 && - token() !== 73 && - token() !== 55 && + return token() !== 16 && + token() !== 88 && + token() !== 74 && + token() !== 56 && isStartOfExpression(); } function parseExpression() { @@ -12341,7 +13290,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { + while ((operatorToken = parseOptionalToken(25))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -12350,12 +13299,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15) || !isStartOfExpression()) { + if (token() !== 57) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { return undefined; } } - parseExpected(56); + parseExpected(57); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -12367,7 +13316,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token() === 34) { + if (expr.kind === 70 && token() === 35) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -12376,7 +13325,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114) { + if (token() === 115) { if (inYieldContext()) { return true; } @@ -12389,11 +13338,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); + (token() === 38 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -12402,21 +13351,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180, asyncModifier.pos); + node = createNode(181, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180, identifier.pos); + node = createNode(181, identifier.pos); } - var parameter = createNode(142, identifier.pos); + var parameter = createNode(143, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -12433,78 +13382,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 || lastToken === 16) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 17 || token() === 25 || token() === 118) { + if (token() === 18 || token() === 26 || token() === 119) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34) { + if (token() === 35) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 17 && token() !== 25) { + if (token() !== 18 && token() !== 26) { return 0; } } var first = token(); var second = nextToken(); - if (first === 17) { - if (second === 18) { + if (first === 18) { + if (second === 19) { var third = nextToken(); switch (third) { - case 34: - case 54: - case 15: + case 35: + case 55: + case 16: return 1; default: return 0; } } - if (second === 19 || second === 15) { + if (second === 20 || second === 16) { return 2; } - if (second === 22) { + if (second === 23) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 54) { + if (nextToken() === 55) { return 1; } return 2; } else { - ts.Debug.assert(first === 25); + ts.Debug.assert(first === 26); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83) { + if (third === 84) { var fourth = nextToken(); switch (fourth) { - case 56: - case 27: + case 57: + case 28: return false; default: return true; } } - else if (third === 24) { + else if (third === 25) { return true; } return false; @@ -12521,7 +13470,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 118) { + if (token() === 119) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -12532,38 +13481,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 34) { + if (scanner.hasPrecedingLineBreak() || token() === 35) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 && token() === 34) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180); + var node = createNode(181); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(54, false, isAsync, !allowAmbiguity, node); + fillSignature(55, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 34 && token() !== 15) { + if (!allowAmbiguity && token() !== 35 && token() !== 16) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15) { + if (token() === 16) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 23 && - token() !== 87 && - token() !== 73 && + if (token() !== 24 && + token() !== 88 && + token() !== 74 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -12573,15 +13522,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); + var questionToken = parseOptionalToken(54); if (!questionToken) { return leftOperand; } - var node = createNode(188, leftOperand.pos); + var node = createNode(189, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); + node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -12590,22 +13539,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 138; + return t === 91 || t === 139; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 38 ? + var consumeCurrentOperator = token() === 39 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 && inDisallowInContext()) { + if (token() === 91 && inDisallowInContext()) { break; } - if (token() === 116) { + if (token() === 117) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -12621,92 +13570,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90) { + if (inDisallowInContext() && token() === 91) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52: + case 53: return 1; - case 51: + case 52: return 2; - case 47: - return 3; case 48: + return 3; + case 49: return 4; - case 46: + case 47: return 5; - case 30: case 31: case 32: case 33: + case 34: return 6; - case 25: - case 27: + case 26: case 28: case 29: + case 30: + case 92: case 91: - case 90: - case 116: + case 117: return 7; - case 43: case 44: case 45: + case 46: return 8; - case 35: case 36: - return 9; case 37: - case 39: + return 9; + case 38: case 40: + case 41: return 10; - case 38: + case 39: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187, left.pos); + var node = createNode(188, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195, left.pos); + var node = createNode(196, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185); + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(182); + var node = createNode(183); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(183); + var node = createNode(184); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 119) { + if (token() === 120) { if (inAwaitContext()) { return true; } @@ -12715,7 +13664,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -12723,15 +13672,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 ? + return token() === 39 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38) { + if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177) { + if (simpleUnaryExpression.kind === 178) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -12742,20 +13691,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: return parsePrefixUnaryExpression(); - case 78: + case 79: return parseDeleteExpression(); - case 101: + case 102: return parseTypeOfExpression(); - case 103: + case 104: return parseVoidExpression(); - case 25: + case 26: return parseTypeAssertion(); - case 119: + case 120: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -12765,16 +13714,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 119: + case 79: + case 102: + case 104: + case 120: return false; - case 25: + case 26: if (sourceFile.languageVariant !== 1) { return false; } @@ -12783,20 +13732,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 41 || token() === 42) { - var node = createNode(185); + if (token() === 42 || token() === 43) { + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 || token() === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186, expression.pos); + if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -12805,7 +13754,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 95 + var expression = token() === 96 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -12816,12 +13765,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 || token() === 21 || token() === 19) { + if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(172, expression.pos); + var node = createNode(173, expression.pos); node.expression = expression; - parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -12829,10 +13778,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69) { + if (lhs.kind === 70) { return lhs.text === rhs.text; } - if (lhs.kind === 97) { + if (lhs.kind === 98) { return true; } return lhs.name.text === rhs.name.text && @@ -12841,8 +13790,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243) { - var node = createNode(241, opening.pos); + if (opening.kind === 244) { + var node = createNode(242, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -12852,18 +13801,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242); + ts.Debug.assert(opening.kind === 243); result = opening; } - if (inExpressionContext && token() === 25) { + if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187, result.pos); + var badNode = createNode(188, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken = createMissingNode(25, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -12871,17 +13820,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(10, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244: + case 10: return parseJsxText(); - case 15: + case 16: return parseJsxExpression(false); - case 25: + case 26: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -12892,7 +13841,7 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26) { + if (token() === 27) { break; } else if (token() === 1) { @@ -12907,24 +13856,24 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25); + parseExpected(26); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (token() === 27) { - node = createNode(243, fullStart); + if (token() === 28) { + node = createNode(244, fullStart); scanJsxText(); } else { - parseExpected(39); + parseExpected(40); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(242, fullStart); + node = createNode(243, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -12932,10 +13881,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 97 ? + var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21)) { - var propertyAccess = createNode(172, expression.pos); + while (parseOptional(22)) { + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -12944,27 +13893,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); - parseExpected(15); - if (token() !== 16) { + parseExpected(16); + if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16); + parseExpected(17); } else { - parseExpected(16, undefined, false); + parseExpected(17, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15) { + if (token() === 16) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246); node.name = parseIdentifierName(); - if (token() === 56) { + if (token() === 57) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -12978,68 +13927,68 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); parseExpected(16); + parseExpected(23); + node.expression = parseExpression(); + parseExpected(17); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245); - parseExpected(26); + parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177); - parseExpected(25); + var node = createNode(178); + parseExpected(26); node.type = parseType(); - parseExpected(27); + parseExpected(28); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21); + var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(172, expression.pos); + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196, expression.pos); + var nonNullExpression = createNode(197, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(173, expression.pos); + if (!inDecoratorContext() && parseOptional(20)) { + var indexedAccess = createNode(174, expression.pos); indexedAccess.expression = expression; - if (token() !== 20) { + if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20); + parseExpected(21); expression = finishNode(indexedAccess); continue; } - if (token() === 11 || token() === 12) { - var tagExpression = createNode(176, expression.pos); + if (token() === 12 || token() === 13) { + var tagExpression = createNode(177, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 + tagExpression.template = token() === 12 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -13051,20 +14000,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25) { + if (token() === 26) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(174, expression.pos); + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17) { - var callExpr = createNode(174, expression.pos); + else if (token() === 18) { + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -13074,17 +14023,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(18); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(19); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { + if (!parseOptional(26)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { + if (!parseExpected(28)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -13093,27 +14042,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17: - case 21: case 18: - case 20: + case 22: + case 19: + case 21: + case 55: + case 24: case 54: - case 23: - case 53: - case 30: - case 32: case 31: case 33: - case 51: + case 32: + case 34: case 52: - case 48: - case 46: + case 53: + case 49: case 47: - case 16: + case 48: + case 17: case 1: return true; - case 24: - case 15: + case 25: + case 16: default: return false; } @@ -13122,80 +14071,80 @@ var ts; switch (token()) { case 8: case 9: - case 11: + case 12: return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: return parseTokenNode(); - case 17: + case 18: return parseParenthesizedExpression(); - case 19: + case 20: return parseArrayLiteralExpression(); - case 15: + case 16: return parseObjectLiteralExpression(); - case 118: + case 119: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 73: + case 74: return parseClassExpression(); - case 87: + case 88: return parseFunctionExpression(); - case 92: + case 93: return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { + case 40: + case 62: + if (reScanSlashToken() === 11) { return parseLiteralNode(); } break; - case 12: + case 13: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(179); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 ? parseSpreadElement() : - token() === 24 ? createNode(193) : + return token() === 23 ? parseSpreadElement() : + token() === 25 ? createNode(194) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170); - parseExpected(19); + var node = createNode(171); + parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); + parseExpected(21); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(149, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(131)) { + if (parseContextualModifier(124)) { return parseAccessorDeclaration(150, fullStart, decorators, modifiers); } + else if (parseContextualModifier(132)) { + return parseAccessorDeclaration(151, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -13206,19 +14155,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 || token() === 16 || token() === 56); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); + var equalsToken = parseOptionalToken(57); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -13230,19 +14179,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54); + parseExpected(55); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171); - parseExpected(15); + var node = createNode(172); + parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); + parseExpected(17); return finishNode(node); } function parseFunctionExpression() { @@ -13250,10 +14199,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(179); + var node = createNode(180); node.modifiers = parseModifiers(); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -13261,7 +14210,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -13272,23 +14221,23 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175); - parseExpected(92); + var node = createNode(176); + parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17) { + if (node.typeArguments || token() === 18) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200); + if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -13313,47 +14262,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201); - parseExpected(23); + var node = createNode(202); + parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(203); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(89); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204); - parseExpected(79); + var node = createNode(205); + parseExpected(80); node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + parseExpected(105); parseExpected(18); - parseOptional(23); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + parseOptional(24); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(206); + parseExpected(105); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86); - parseExpected(17); + parseExpected(87); + parseExpected(18); var initializer = undefined; - if (token() !== 23) { - if (token() === 102 || token() === 108 || token() === 74) { + if (token() !== 24) { + if (token() === 103 || token() === 109 || token() === 75) { initializer = parseVariableDeclarationList(true); } else { @@ -13361,32 +14310,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(207, pos); + if (parseOptional(91)) { + var forInStatement = createNode(208, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138)) { - var forOfStatement = createNode(208, pos); + else if (parseOptional(139)) { + var forOfStatement = createNode(209, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206, pos); + var forStatement = createNode(207, pos); forStatement.initializer = initializer; - parseExpected(23); - if (token() !== 23 && token() !== 18) { + parseExpected(24); + if (token() !== 24 && token() !== 19) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23); - if (token() !== 18) { + parseExpected(24); + if (token() !== 19) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -13394,7 +14343,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 ? 70 : 75); + parseExpected(kind === 211 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -13402,8 +14351,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211); - parseExpected(94); + var node = createNode(212); + parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -13411,90 +14360,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249); - parseExpected(71); + parseExpected(72); node.expression = allowInAnd(parseExpression); - parseExpected(54); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250); - parseExpected(77); - parseExpected(54); + parseExpected(78); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 ? parseCaseClause() : parseDefaultClause(); + return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(214); + parseExpected(97); parseExpected(18); - var caseBlock = createNode(227, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + var caseBlock = createNode(228, scanner.getStartPos()); parseExpected(16); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(17); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(215); - parseExpected(98); + var node = createNode(216); + parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(216); - parseExpected(100); + var node = createNode(217); + parseExpected(101); node.tryBlock = parseBlock(false); - node.catchClause = token() === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 85) { - parseExpected(85); + node.catchClause = token() === 73 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 86) { + parseExpected(86); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252); - parseExpected(72); - if (parseExpected(17)) { + parseExpected(73); + if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18); + parseExpected(19); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217); - parseExpected(76); + var node = createNode(218); + parseExpected(77); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(214, fullStart); + if (expression.kind === 70 && parseOptional(55)) { + var labeledStatement = createNode(215, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202, fullStart); + var expressionStatement = createNode(203, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -13506,7 +14455,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 && !scanner.hasPrecedingLineBreak(); + return token() === 88 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -13515,47 +14464,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102: - case 108: + case 103: + case 109: + case 75: + case 88: case 74: - case 87: - case 73: - case 81: + case 82: return true; - case 107: - case 134: + case 108: + case 135: return nextTokenIsIdentifierOnSameLine(); - case 125: case 126: + case 127: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: + case 116: + case 119: + case 123: case 111: case 112: - case 128: + case 113: + case 129: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137: + case 138: nextToken(); - return token() === 15 || token() === 69 || token() === 82; - case 89: + return token() === 16 || token() === 70 || token() === 83; + case 90: nextToken(); - return token() === 9 || token() === 37 || - token() === 15 || ts.tokenIsIdentifierOrKeyword(token()); - case 82: + return token() === 9 || token() === 38 || + token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); + case 83: nextToken(); - if (token() === 56 || token() === 37 || - token() === 15 || token() === 77 || - token() === 116) { + if (token() === 57 || token() === 38 || + token() === 16 || token() === 78 || + token() === 117) { return true; } continue; - case 113: + case 114: nextToken(); continue; default: @@ -13568,46 +14517,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: + case 56: + case 24: + case 16: + case 103: + case 109: case 88: - case 79: - case 104: - case 86: - case 75: - case 70: - case 94: - case 105: - case 96: - case 98: - case 100: - case 76: - case 72: - case 85: - return true; case 74: case 82: case 89: + case 80: + case 105: + case 87: + case 76: + case 71: + case 95: + case 106: + case 97: + case 99: + case 101: + case 77: + case 73: + case 86: + return true; + case 75: + case 83: + case 90: return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: + case 119: + case 123: + case 108: case 126: - case 134: - case 137: + case 127: + case 135: + case 138: return true; - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -13615,73 +14564,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 || token() === 19; + return isIdentifier() || token() === 16 || token() === 20; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 23: + case 24: return parseEmptyStatement(); - case 15: + case 16: return parseBlock(false); - case 102: + case 103: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: + case 109: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 87: + case 88: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 73: + case 74: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 88: + case 89: return parseIfStatement(); - case 79: + case 80: return parseDoStatement(); - case 104: + case 105: return parseWhileStatement(); - case 86: + case 87: return parseForOrForInOrForOfStatement(); - case 75: - return parseBreakOrContinueStatement(209); - case 70: + case 76: return parseBreakOrContinueStatement(210); - case 94: + case 71: + return parseBreakOrContinueStatement(211); + case 95: return parseReturnStatement(); - case 105: + case 106: return parseWithStatement(); - case 96: + case 97: return parseSwitchStatement(); - case 98: + case 99: return parseThrowStatement(); - case 100: - case 72: - case 85: + case 101: + case 73: + case 86: return parseTryStatement(); - case 76: + case 77: return parseDebuggerStatement(); - case 55: + case 56: return parseDeclaration(); - case 118: - case 107: - case 134: - case 125: + case 119: + case 108: + case 135: case 126: - case 122: - case 74: - case 81: + case 127: + case 123: + case 75: case 82: - case 89: - case 110: + case 83: + case 90: case 111: case 112: - case 115: case 113: - case 128: - case 137: + case 116: + case 114: + case 129: + case 138: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -13694,40 +14643,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: return parseVariableStatement(fullStart, decorators, modifiers); - case 87: + case 88: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: + case 74: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: + case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: + case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137: - case 125: + case 138: case 126: + case 127: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: + case 90: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82: + case 83: nextToken(); switch (token()) { - case 77: - case 56: + case 78: + case 57: return parseExportAssignment(fullStart, decorators, modifiers); - case 116: + case 117: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(239, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -13740,31 +14689,31 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 && canParseSemicolon()) { + if (token() !== 16 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 24) { - return createNode(193); + if (token() === 25) { + return createNode(194); } - var node = createNode(169); - node.dotDotDotToken = parseOptionalToken(22); + var node = createNode(170); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169); + var node = createNode(170); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54) { + if (tokenIsIdentifier && token() !== 55) { node.name = propertyName; } else { - parseExpected(54); + parseExpected(55); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -13772,33 +14721,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(168); parseExpected(16); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(169); parseExpected(20); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(21); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 || token() === 19 || isIdentifier(); + return token() === 16 || token() === 20 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19) { + if (token() === 20) { return parseArrayBindingPattern(); } - if (token() === 15) { + if (token() === 16) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218); + var node = createNode(219); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -13807,21 +14756,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219); + var node = createNode(220); switch (token()) { - case 102: + case 103: break; - case 108: + case 109: node.flags |= 1; break; - case 74: + case 75: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 138 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -13833,10 +14782,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; + return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -13844,29 +14793,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148, pos); + var node = createNode(149, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121); - fillSignature(54, false, false, false, node); + parseExpected(122); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -13874,12 +14823,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(54, isGenerator, isAsync, false, method); + fillSignature(55, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -13892,10 +14841,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -13910,17 +14859,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return true; default: return false; @@ -13928,7 +14877,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55) { + if (token() === 56) { return true; } while (ts.isModifierKind(token())) { @@ -13938,26 +14887,26 @@ var ts; } nextToken(); } - if (token() === 37) { + if (token() === 38) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 131 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { return true; } switch (token()) { - case 17: - case 25: + case 18: + case 26: + case 55: + case 57: case 54: - case 56: - case 53: return true; default: return canParseSemicolon(); @@ -13969,10 +14918,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55)) { + if (!parseOptional(56)) { break; } - var decorator = createNode(143, decoratorStart); + var decorator = createNode(144, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -13992,7 +14941,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 && permitInvalidConstAsModifier) { + if (token() === 75 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -14017,7 +14966,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118) { + if (token() === 119) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -14028,8 +14977,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23) { - var result = createNode(198); + if (token() === 24) { + var result = createNode(199); nextToken(); return finishNode(result); } @@ -14040,7 +14989,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121) { + if (token() === 122) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -14049,33 +14998,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 37 || - token() === 19) { + token() === 38 || + token() === 20) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_10 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); + var name_10 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 192); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73); + parseExpected(74); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16)) { node.members = parseClassMembers(); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -14088,16 +15037,16 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { if (isHeritageClause()) { return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClause() { - if (token() === 83 || token() === 106) { + if (token() === 84 || token() === 107) { var node = createNode(251); node.token = token(); nextToken(); @@ -14107,38 +15056,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194); + var node = createNode(195); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function isHeritageClause() { - return token() === 83 || token() === 106; + return token() === 84 || token() === 107; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222, fullStart); + var node = createNode(223, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107); + parseExpected(108); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134); + parseExpected(135); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56); + parseExpected(57); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -14150,14 +15099,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81); + parseExpected(82); node.name = parseIdentifier(); - if (parseExpected(15)) { + if (parseExpected(16)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -14165,10 +15114,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226, scanner.getStartPos()); - if (parseExpected(15)) { + var node = createNode(227, scanner.getStartPos()); + if (parseExpected(16)) { node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -14176,29 +15125,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21) + node.body = parseOptional(22) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137) { + if (token() === 138) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 15) { + if (token() === 16) { node.body = parseModuleBlock(); } else { @@ -14208,14 +15157,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137) { + if (token() === 138) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126)) { + else if (parseOptional(127)) { flags |= 16; } else { - parseExpected(125); + parseExpected(126); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -14223,63 +15172,63 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 && + return token() === 130 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17; + return nextToken() === 18; } function nextTokenIsSlash() { - return nextToken() === 39; + return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228, fullStart); + var exportDeclaration = createNode(229, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116); - parseExpected(126); + parseExpected(117); + parseExpected(127); exportDeclaration.name = parseIdentifier(); - parseExpected(23); + parseExpected(24); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); + parseExpected(90); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 && token() !== 136) { - var importEqualsDeclaration = createNode(229, fullStart); + if (token() !== 25 && token() !== 137) { + var importEqualsDeclaration = createNode(230, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56); + parseExpected(57); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(230, fullStart); + var importDeclaration = createNode(231, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 37 || - token() === 15) { + token() === 38 || + token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136); + parseExpected(137); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(231, fullStart); + var importClause = createNode(232, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token() === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(233); + parseOptional(25)) { + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); } return finishNode(importClause); } @@ -14289,11 +15238,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(240); - parseExpected(129); - parseExpected(17); - node.expression = parseModuleSpecifier(); + var node = createNode(241); + parseExpected(130); parseExpected(18); + node.expression = parseModuleSpecifier(); + parseExpected(19); return finishNode(node); } function parseModuleSpecifier() { @@ -14307,22 +15256,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(232); - parseExpected(37); - parseExpected(116); + var namespaceImport = createNode(233); + parseExpected(38); + parseExpected(117); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 233 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238); + return parseImportOrExportSpecifier(239); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234); + return parseImportOrExportSpecifier(235); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -14330,9 +15279,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116) { + if (token() === 117) { node.propertyName = identifierName; - parseExpected(116); + parseExpected(117); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -14341,23 +15290,23 @@ var ts; else { node.name = identifierName; } - if (kind === 234 && checkIdentifierIsKeyword) { + if (kind === 235 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(237, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37)) { - parseExpected(136); + if (parseOptional(38)) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237); - if (token() === 136 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(136); + node.exportClause = parseNamedImportsOrExports(238); + if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -14365,14 +15314,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235, fullStart); + var node = createNode(236, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56)) { + if (parseOptional(57)) { node.isExportEquals = true; } else { - parseExpected(77); + parseExpected(78); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -14444,36 +15393,72 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 229 && node.moduleReference.kind === 240 - || node.kind === 230 - || node.kind === 235 + || node.kind === 230 && node.moduleReference.kind === 241 + || node.kind === 231 || node.kind === 236 + || node.kind === 237 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37: - case 53: - case 17: - case 19: - case 49: - case 15: - case 87: - case 22: - case 92: - case 97: + case 38: + case 54: + case 18: + case 20: + case 50: + case 16: + case 88: + case 23: + case 93: + case 98: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); - sourceFile = createSourceFile("file.js", 2, 1); + initializeState(content, 4, undefined, 1); + sourceFile = createSourceFile("file.js", 4, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -14484,21 +15469,21 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { var result = createNode(257, scanner.getTokenPos()); - parseExpected(15); - result.type = parseJSDocTopLevelType(); parseExpected(16); + result.type = parseJSDocTopLevelType(); + parseExpected(17); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47) { + if (token() === 48) { var unionType = createNode(261, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56) { + if (token() === 57) { var optionalType = createNode(268, type.pos); nextToken(); optionalType.type = type; @@ -14509,20 +15494,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19) { + if (token() === 20) { var arrayType = createNode(260, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20); + parseExpected(21); type = finishNode(arrayType); } - else if (token() === 53) { + else if (token() === 54) { var nullableType = createNode(263, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49) { + else if (token() === 50) { var nonNullableType = createNode(264, type.pos); nonNullableType.type = type; nextToken(); @@ -14536,40 +15521,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37: + case 38: return parseJSDocAllType(); - case 53: + case 54: return parseJSDocUnknownOrNullableType(); - case 17: + case 18: return parseJSDocUnionType(); - case 19: + case 20: return parseJSDocTupleType(); - case 49: + case 50: return parseJSDocNonNullableType(); - case 15: + case 16: return parseJSDocRecordType(); - case 87: + case 88: return parseJSDocFunctionType(); - case 22: + case 23: return parseJSDocVariadicType(); - case 92: + case 93: return parseJSDocConstructorType(); - case 97: + case 98: return parseJSDocThisType(); - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 93: - case 135: - case 127: + case 131: + case 121: + case 134: + case 104: + case 94: + case 136: + case 128: return parseTokenNode(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -14577,14 +15562,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } @@ -14597,33 +15582,33 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269); nextToken(); - parseExpected(17); + parseExpected(18); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18); - if (token() === 54) { + parseExpected(19); + if (token() === 55) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142); + var parameter = createNode(143); parameter.type = parseJSDocType(); - if (parseOptional(56)) { - parameter.questionToken = createNode(56); + if (parseOptional(57)) { + parameter.questionToken = createNode(57); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267); result.name = parseSimplePropertyName(); - if (token() === 25) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21)) { - if (token() === 25) { + while (parseOptional(22)) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); break; } @@ -14639,7 +15624,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27); + parseExpected(28); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -14650,7 +15635,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139, left.pos); + var result = createNode(140, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -14671,7 +15656,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20); + parseExpected(21); return finishNode(result); } function checkForTrailingComma(list) { @@ -14684,13 +15669,13 @@ var ts; var result = createNode(261); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); + parseExpected(19); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47)) { + while (parseOptional(48)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -14709,12 +15694,12 @@ var ts; function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 24 || - token() === 16 || - token() === 18 || - token() === 27 || - token() === 56 || - token() === 47) { + if (token() === 25 || + token() === 17 || + token() === 19 || + token() === 28 || + token() === 57 || + token() === 48) { var result = createNode(259, pos); return finishNode(result); } @@ -14725,7 +15710,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); + initializeState(content, 4, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -14747,6 +15732,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -14783,7 +15774,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 55: + case 56: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -14801,7 +15792,7 @@ var ts; state = 0; indent = 0; break; - case 37: + case 38: var asterisk = scanner.getTokenText(); if (state === 1) { state = 2; @@ -14812,7 +15803,7 @@ var ts; indent += asterisk.length; } break; - case 69: + case 70: pushComment(scanner.getTokenText()); state = 2; break; @@ -14869,8 +15860,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getTokenPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -14921,7 +15912,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 && token() !== 1) { + while (token() !== 56 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -14930,7 +15921,7 @@ var ts; } indent = 0; break; - case 55: + case 56: break; case 5: if (state === 2) { @@ -14944,7 +15935,7 @@ var ts; indent += whitespace.length; } break; - case 37: + case 38: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -14955,7 +15946,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55) { + if (token() === 56) { break; } nextJSDocToken(); @@ -14983,7 +15974,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15) { + if (token() !== 16) { return undefined; } return parseJSDocTypeExpression(); @@ -14994,14 +15985,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(19)) { + if (parseOptionalToken(20)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(56)) { + if (parseOptionalToken(57)) { parseExpression(); } - parseExpected(20); + parseExpected(21); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -15078,7 +16069,7 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69) { + if (jsDocTypeReference.name.kind === 70) { var name_11 = jsDocTypeReference.name; if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -15102,7 +16093,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55: + case 56: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -15116,13 +16107,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37: + case 38: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69: + case 70: canParseTag = false; case 1: break; @@ -15133,8 +16124,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getStartPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -15172,11 +16163,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_12.pos); + var typeParameter = createNode(142, name_12.pos); typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24) { + if (token() === 25) { nextJSDocToken(); skipWhitespace(); } @@ -15205,7 +16196,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69, pos); + var result = createNode(70, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -15276,8 +16267,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -15286,7 +16277,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 69: + case 70: return true; } return false; @@ -15349,8 +16340,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -15498,21 +16489,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - if (node.kind === 222 || node.kind === 223) { + if (node.kind === 223 || node.kind === 224) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 230 || node.kind === 229) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 226) { + else if (node.kind === 227) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -15528,7 +16529,7 @@ var ts; }); return state_1; } - else if (node.kind === 225) { + else if (node.kind === 226) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -15537,6 +16538,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -15634,7 +16647,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { symbol.valueDeclaration = node; } } @@ -15644,7 +16657,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -15655,21 +16668,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148: + case 149: return "__constructor"; - case 156: - case 151: - return "__call"; case 157: case 152: - return "__new"; + return "__call"; + case 158: case 153: + return "__new"; + case 154: return "__index"; - case 236: + case 237: return "__export"; - case 235: + case 236: return node.isExportEquals ? "export=" : "default"; - case 187: + case 188: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -15681,12 +16694,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220: case 221: + case 222: return ts.hasModifier(node, 512) ? "default" : undefined; case 269: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142: + case 143: ts.Debug.assert(node.parent.kind === 269); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); @@ -15694,10 +16707,10 @@ var ts; case 279: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { nameFromParentNode = nameIdentifier.text; } } @@ -15738,7 +16751,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -15758,7 +16771,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 238 || (node.kind === 229 && hasExportModifier)) { + if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -15875,64 +16888,64 @@ var ts; return; } switch (node.kind) { - case 205: + case 206: bindWhileStatement(node); break; - case 204: + case 205: bindDoStatement(node); break; - case 206: + case 207: bindForStatement(node); break; - case 207: case 208: + case 209: bindForInOrForOfStatement(node); break; - case 203: + case 204: bindIfStatement(node); break; - case 211: - case 215: + case 212: + case 216: bindReturnOrThrow(node); break; + case 211: case 210: - case 209: bindBreakOrContinueStatement(node); break; - case 216: + case 217: bindTryStatement(node); break; - case 213: + case 214: bindSwitchStatement(node); break; - case 227: + case 228: bindCaseBlock(node); break; case 249: bindCaseClause(node); break; - case 214: + case 215: bindLabeledStatement(node); break; - case 185: + case 186: bindPrefixUnaryExpressionFlow(node); break; - case 186: + case 187: bindPostfixUnaryExpressionFlow(node); break; - case 187: + case 188: bindBinaryExpressionFlow(node); break; - case 181: + case 182: bindDeleteExpressionFlow(node); break; - case 188: + case 189: bindConditionalExpressionFlow(node); break; - case 218: + case 219: bindVariableDeclarationFlow(node); break; - case 174: + case 175: bindCallExpressionFlow(node); break; default: @@ -15942,25 +16955,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return isNarrowableReference(expr); - case 174: + case 175: return hasNarrowableArgument(expr); - case 178: + case 179: return isNarrowingExpression(expr.expression); - case 187: + case 188: return isNarrowingBinaryExpression(expr); - case 185: - return expr.operator === 49 && isNarrowingExpression(expr.operand); + case 186: + return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 || - expr.kind === 97 || - expr.kind === 172 && isNarrowableReference(expr.expression); + return expr.kind === 70 || + expr.kind === 98 || + expr.kind === 173 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -15971,41 +16984,41 @@ var ts; } } } - if (expr.expression.kind === 172 && + if (expr.expression.kind === 173 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableReference(expr.left); - case 30: case 31: case 32: case 33: + case 34: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91: + case 92: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178: + case 179: return isNarrowableOperand(expr.expression); - case 187: + case 188: switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowableOperand(expr.right); } } @@ -16024,7 +17037,7 @@ var ts; }; } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 256 ? 512 : 256; + flow.flags |= flow.flags & 512 ? 1024 : 512; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -16039,8 +17052,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 99 && flags & 64 || - expression.kind === 84 && flags & 32) { + if (expression.kind === 100 && flags & 64 || + expression.kind === 85 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -16074,6 +17087,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -16087,34 +17108,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203: - case 205: case 204: - return parent.expression === node; case 206: - case 188: + case 205: + return parent.expression === node; + case 207: + case 189: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178) { + if (node.kind === 179) { node = node.expression; } - else if (node.kind === 185 && node.operator === 49) { + else if (node.kind === 186 && node.operator === 50) { node = node.operand; } else { - return node.kind === 187 && (node.operatorToken.kind === 51 || - node.operatorToken.kind === 52); + return node.kind === 188 && (node.operatorToken.kind === 52 || + node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 || - node.parent.kind === 185 && - node.parent.operator === 49) { + while (node.parent.kind === 179 || + node.parent.kind === 186 && + node.parent.operator === 50) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -16187,7 +17208,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219) { + if (node.initializer.kind !== 220) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -16209,7 +17230,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211) { + if (node.kind === 212) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -16229,7 +17250,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -16249,21 +17270,32 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + if (!(currentFlow.flags & 1)) { + if ((flowAfterTry.flags & 1) && (flowAfterCatch.flags & 1)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - if (!node.finallyBlock || !(currentFlow.flags & 1)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -16340,7 +17372,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 && node.operatorToken.kind === 56) { + if (node.kind === 188 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -16351,10 +17383,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170) { + else if (node.kind === 171) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191) { + if (e.kind === 192) { bindAssignmentTargetFlow(e.expression); } else { @@ -16362,7 +17394,7 @@ var ts; } } } - else if (node.kind === 171) { + else if (node.kind === 172) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253) { @@ -16376,7 +17408,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -16387,7 +17419,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49) { + if (node.operator === 50) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -16397,20 +17429,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 || operator === 52) { + if (operator === 52 || operator === 53) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -16422,14 +17454,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 && !ts.isAssignmentTarget(node)) { + if (operator === 57 && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172) { + if (node.expression.kind === 173) { bindAssignmentTargetFlow(node.expression); } } @@ -16460,16 +17498,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 || node.parent.parent.kind === 208) { + if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 178) { + while (expr.kind === 179) { expr = expr.expression; } - if (expr.kind === 179 || expr.kind === 180) { + if (expr.kind === 180 || expr.kind === 181) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -16477,54 +17515,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192: - case 221: - case 224: - case 171: - case 159: + case 193: + case 222: + case 225: + case 172: + case 160: case 281: case 265: return 1; - case 222: + case 223: return 1 | 64; case 269: - case 225: - case 223: + case 226: + case 224: return 1 | 32; case 256: return 1 | 4 | 32; - case 147: + case 148: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 148: - case 220: - case 146: case 149: + case 221: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return 1 | 4 | 32 | 8; - case 179: case 180: + case 181: return 1 | 4 | 32 | 8 | 16; - case 226: + case 227: return 4; - case 145: + case 146: return node.initializer ? 4 : 0; case 252: - case 206: case 207: case 208: - case 227: + case 209: + case 228: return 2; - case 199: + case 200: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -16540,36 +17584,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 225: + case 226: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192: - case 221: + case 193: + case 222: return declareClassMember(node, symbolFlags, symbolExcludes); - case 224: + case 225: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159: - case 171: - case 222: + case 160: + case 172: + case 223: case 265: case 281: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156: case 157: - case 151: + case 158: case 152: case 153: - case 147: - case 146: + case 154: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 269: - case 223: + case 224: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -16585,10 +17629,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 226)) { + if (body && (body.kind === 256 || body.kind === 227)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 || stat.kind === 235) { + if (stat.kind === 237 || stat.kind === 236) { return true; } } @@ -16660,15 +17704,20 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69) { + if (prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 147 + var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -16690,7 +17739,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225: + case 226: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256: @@ -16711,8 +17760,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && + node.originalKeywordKind >= 107 && + node.originalKeywordKind <= 115 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -16740,17 +17789,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { + if (inStrictMode && node.expression.kind === 70) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && + return node.kind === 70 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { + if (name && name.kind === 70) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -16784,7 +17833,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 225 && + blockScopeContainer.kind !== 226 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -16803,7 +17852,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -16827,7 +17876,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 138) { + if (node.kind > 139) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -16864,18 +17913,18 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172: + case 173: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187: + case 188: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -16900,30 +17949,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252: return checkStrictModeCatchClause(node); - case 181: + case 182: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 186: + case 187: return checkStrictModePostfixUnaryExpression(node); - case 185: + case 186: return checkStrictModePrefixUnaryExpression(node); - case 212: + case 213: return checkStrictModeWithStatement(node); - case 165: + case 166: seenThisKeyword = true; return; - case 154: + case 155: return checkTypePredicate(node); - case 141: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 142: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 143: return bindParameter(node); - case 218: - case 169: + case 219: + case 170: return bindVariableDeclarationOrBindingElement(node); + case 146: case 145: - case 144: case 266: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); case 280: @@ -16936,82 +17985,82 @@ var ts; case 247: emitFlags |= 16384; return; - case 151: case 152: case 153: + case 154: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 148: case 147: - case 146: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 220: + case 221: return bindFunctionDeclaration(node); - case 148: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 149: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 150: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 151: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 156: case 157: + case 158: case 269: return bindFunctionOrConstructorType(node); - case 159: + case 160: case 281: case 265: return bindAnonymousDeclaration(node, 2048, "__type"); - case 171: + case 172: return bindObjectLiteralExpression(node); - case 179: case 180: + case 181: return bindFunctionExpression(node); - case 174: + case 175: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 192: - case 221: + case 193: + case 222: inStrictMode = true; return bindClassLikeDeclaration(node); - case 222: + case 223: return bindBlockScopedDeclaration(node, 64, 792968); case 279: - case 223: - return bindBlockScopedDeclaration(node, 524288, 793064); case 224: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 225: + return bindEnumDeclaration(node); + case 226: return bindModuleDeclaration(node); - case 229: - case 232: - case 234: - case 238: + case 230: + case 233: + case 235: + case 239: return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 228: + case 229: return bindNamespaceExportDeclaration(node); - case 231: + case 232: return bindImportClause(node); - case 236: + case 237: return bindExportDeclaration(node); - case 235: + case 236: return bindExportAssignment(node); case 256: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199: + case 200: if (!ts.isFunctionLike(node.parent)) { return; } - case 226: + case 227: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69) { + if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165) { + if (parameterName && parameterName.kind === 166) { seenThisKeyword = true; } bind(type); @@ -17030,7 +18079,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -17074,7 +18123,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -17087,11 +18138,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 220 || container.kind === 179) { + if (container.kind === 221 || container.kind === 180) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 148) { + else if (container.kind === 149) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -17131,7 +18182,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 221) { + if (node.kind === 222) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -17249,15 +18300,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 201) || - node.kind === 221 || - (node.kind === 225 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 224 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || + node.kind === 222 || + (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 || + (node.kind !== 201 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -17271,52 +18322,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174: + case 175: return computeCallExpression(node, subtreeFlags); - case 225: + case 176: + return computeNewExpression(node, subtreeFlags); + case 226: return computeModuleDeclaration(node, subtreeFlags); - case 178: + case 179: return computeParenthesizedExpression(node, subtreeFlags); - case 187: + case 188: return computeBinaryExpression(node, subtreeFlags); - case 202: + case 203: return computeExpressionStatement(node, subtreeFlags); - case 142: + case 143: return computeParameter(node, subtreeFlags); - case 180: + case 181: return computeArrowFunction(node, subtreeFlags); - case 179: + case 180: return computeFunctionExpression(node, subtreeFlags); - case 220: + case 221: return computeFunctionDeclaration(node, subtreeFlags); - case 218: - return computeVariableDeclaration(node, subtreeFlags); case 219: + return computeVariableDeclaration(node, subtreeFlags); + case 220: return computeVariableDeclarationList(node, subtreeFlags); - case 200: + case 201: return computeVariableStatement(node, subtreeFlags); - case 214: + case 215: return computeLabeledStatement(node, subtreeFlags); - case 221: + case 222: return computeClassDeclaration(node, subtreeFlags); - case 192: + case 193: return computeClassExpression(node, subtreeFlags); case 251: return computeHeritageClause(node, subtreeFlags); - case 194: + case 195: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148: + case 149: return computeConstructor(node, subtreeFlags); - case 145: + case 146: return computePropertyDeclaration(node, subtreeFlags); - case 147: + case 148: return computeMethod(node, subtreeFlags); - case 149: case 150: + case 151: return computeAccessor(node, subtreeFlags); - case 229: + case 230: return computeImportEquals(node, subtreeFlags); - case 172: + case 173: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -17327,40 +18380,54 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537133909; + return transformFlags & ~537922901; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95: + case 96: return true; - case 172: case 173: + case 174: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95; + return expressionKind === 96; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576) { + transformFlags |= 768; + } + node.transformFlags = transformFlags | 536870912; + return transformFlags & ~537922901; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 - && (leftKind === 171 - || leftKind === 170)) { - transformFlags |= 192 | 256; + if (operatorTokenKind === 57 + && (leftKind === 172 + || leftKind === 171)) { + transformFlags |= 768 | 1024; } - else if (operatorTokenKind === 38 - || operatorTokenKind === 60) { - transformFlags |= 48; + else if (operatorTokenKind === 39 + || operatorTokenKind === 61) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17368,35 +18435,35 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - if (node.questionToken) { - transformFlags |= 3; - } - if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { + if (node.questionToken + || node.type + || subtreeFlags & 8192 + || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 131072; + transformFlags |= 3 | 524288; } - if (subtreeFlags & 2097152 || initializer || dotDotDotToken) { - transformFlags |= 192 | 65536; + if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { + transformFlags |= 768 | 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 195 - || expressionKind === 177) { + if (expressionKind === 196 + || expressionKind === 178) { transformFlags |= 3; } - if (expressionTransformFlags & 256) { - transformFlags |= 256; + if (expressionTransformFlags & 1024) { + transformFlags |= 1024; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -17405,36 +18472,38 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 192; - if ((subtreeFlags & 137216) - || (modifierFlags & 1)) { + transformFlags = subtreeFlags | 768; + if ((subtreeFlags & 548864) + || (modifierFlags & 1) + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - if (subtreeFlags & 137216) { + var transformFlags = subtreeFlags | 768; + if (subtreeFlags & 548864 + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83: - transformFlags |= 192; + case 84: + transformFlags |= 768; break; - case 106: + case 107: transformFlags |= 3; break; default: @@ -17442,135 +18511,148 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; + var transformFlags = subtreeFlags | 768; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { + if (ts.hasModifier(node, 2270) + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - if (!body - || typeParameters - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + var transformFlags = subtreeFlags | 768; + if (node.decorators + || ts.hasModifier(node, 2270) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - if (!body - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + if (node.decorators + || ts.hasModifier(node, 2270) + || node.type + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 4096; + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2)) { transformFlags = 3; } else { - transformFlags = subtreeFlags | 8388608; + transformFlags = subtreeFlags | 33554432; if (modifierFlags & 1) { - transformFlags |= 3 | 192; + transformFlags |= 3 | 768; } - if (modifierFlags & 256) { + if (modifierFlags & 2270 + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (modifierFlags & 256) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - if (modifierFlags & 256) { + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 256) { + var transformFlags = subtreeFlags | 768; + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 8192) { - transformFlags |= 16384; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 32768) { + transformFlags |= 65536; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550710101; + return transformFlags & ~592227669; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 95) { - transformFlags |= 8192; + if (expressionKind === 96) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 167 || nameKind === 168) { - transformFlags |= 192 | 2097152; + if (nameKind === 168 || nameKind === 169) { + transformFlags |= 768 | 8388608; + } + if (node.type) { + transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -17582,23 +18664,23 @@ var ts; else { transformFlags = subtreeFlags; if (modifierFlags & 1) { - transformFlags |= 192 | 3; + transformFlags |= 768 | 3; } - if (declarationListTransformFlags & 2097152) { - transformFlags |= 192; + if (declarationListTransformFlags & 8388608) { + transformFlags |= 768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 1048576 + if (subtreeFlags & 4194304 && ts.isIterationStatement(node, true)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17606,15 +18688,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 256) { - transformFlags |= 192; + if (node.expression.transformFlags & 1024) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -17623,77 +18705,78 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~546335573; + return transformFlags & ~574729557; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608; - if (subtreeFlags & 2097152) { - transformFlags |= 192; + var transformFlags = subtreeFlags | 33554432; + if (subtreeFlags & 8388608) { + transformFlags |= 768; } if (node.flags & 3) { - transformFlags |= 192 | 1048576; + transformFlags |= 768 | 4194304; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536871765; + var excludeFlags = 536874325; switch (kind) { - case 112: - case 110: + case 119: + case 185: + transformFlags |= 48; + break; + case 113: case 111: - case 115: - case 122: - case 118: - case 74: - case 184: - case 224: + case 112: + case 116: + case 123: + case 75: + case 225: case 255: - case 177: - case 195: + case 178: case 196: - case 128: + case 197: + case 129: transformFlags |= 3; break; - case 241: case 242: case 243: case 244: + case 10: case 245: case 246: case 247: case 248: transformFlags |= 12; break; - case 82: - transformFlags |= 192 | 3; + case 83: + transformFlags |= 768 | 3; break; - case 77: - case 11: + case 78: case 12: case 13: case 14: - case 189: - case 176: + case 15: + case 190: + case 177: case 254: - case 208: - transformFlags |= 192; + case 209: + transformFlags |= 768; break; - case 190: - transformFlags |= 192 | 4194304; + case 191: + transformFlags |= 768 | 16777216; break; - case 117: - case 130: - case 127: - case 132: - case 120: + case 118: + case 131: + case 128: case 133: - case 103: - case 141: - case 144: - case 146: - case 151: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: case 154: @@ -17707,68 +18790,69 @@ var ts; case 162: case 163: case 164: - case 222: - case 223: case 165: + case 223: + case 224: case 166: + case 167: transformFlags = 3; excludeFlags = -3; break; - case 140: - transformFlags |= 524288; - if (subtreeFlags & 8192) { - transformFlags |= 32768; + case 141: + transformFlags |= 2097152; + if (subtreeFlags & 32768) { + transformFlags |= 131072; } break; - case 191: - transformFlags |= 262144; + case 192: + transformFlags |= 1048576; break; - case 95: - transformFlags |= 192; + case 96: + transformFlags |= 768; break; - case 97: - transformFlags |= 8192; + case 98: + transformFlags |= 32768; break; - case 167: case 168: - transformFlags |= 192 | 2097152; + case 169: + transformFlags |= 768 | 8388608; break; - case 143: - transformFlags |= 3 | 2048; + case 144: + transformFlags |= 3 | 8192; break; - case 171: - excludeFlags = 537430869; - if (subtreeFlags & 524288) { - transformFlags |= 192; + case 172: + excludeFlags = 539110741; + if (subtreeFlags & 2097152) { + transformFlags |= 768; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } break; - case 170: - case 175: - excludeFlags = 537133909; - if (subtreeFlags & 262144) { - transformFlags |= 192; + case 171: + case 176: + excludeFlags = 537922901; + if (subtreeFlags & 1048576) { + transformFlags |= 768; } break; - case 204: case 205: case 206: case 207: - if (subtreeFlags & 1048576) { - transformFlags |= 192; + case 208: + if (subtreeFlags & 4194304) { + transformFlags |= 768; } break; case 256: - if (subtreeFlags & 16384) { - transformFlags |= 192; + if (subtreeFlags & 65536) { + transformFlags |= 768; } break; - case 211: - case 209: + case 212: case 210: - transformFlags |= 8388608; + case 211: + transformFlags |= 33554432; break; } node.transformFlags = transformFlags | 536870912; @@ -17777,7 +18861,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -18422,6 +19506,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); @@ -18465,6 +19550,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; var getGlobalTemplateStringsArrayType; var getGlobalESSymbolType; @@ -18505,6 +19591,66 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -18547,6 +19693,13 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -18631,7 +19784,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 && source.valueDeclaration.kind !== 225))) { + (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -18766,24 +19919,24 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 218 || + return declaration.kind !== 219 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200: - case 206: - case 208: + case 201: + case 207: + case 209: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 207: case 208: + case 209: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -18801,7 +19954,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 && + current.parent.kind === 146 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -18827,15 +19980,15 @@ var ts; if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 142 || - lastLocation.kind === 141 + lastLocation.kind === 143 || + lastLocation.kind === 142 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 142 || + lastLocation.kind === 143 || (lastLocation === location.type && - result.valueDeclaration.kind === 142); + result.valueDeclaration.kind === 143); } } if (useResult) { @@ -18851,7 +20004,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225: + case 226: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { @@ -18863,7 +20016,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 238)) { + ts.getDeclarationOfKind(moduleExports[name], 239)) { break; } } @@ -18871,13 +20024,13 @@ var ts; break loop; } break; - case 224: + case 225: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 146: case 145: - case 144: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -18887,9 +20040,9 @@ var ts; } } break; - case 221: - case 192: case 222: + case 193: + case 223: 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); @@ -18897,7 +20050,7 @@ var ts; } break loop; } - if (location.kind === 192 && meaning & 32) { + if (location.kind === 193 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -18905,28 +20058,28 @@ var ts; } } break; - case 140: + case 141: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223) { 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; } } break; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 180: + case 151: + case 221: + case 181: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179: + case 180: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -18939,8 +20092,8 @@ var ts; } } break; - case 143: - if (location.parent && location.parent.kind === 142) { + case 144: + if (location.parent && location.parent.kind === 143) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -18982,7 +20135,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228) { + if (decls && decls.length === 1 && decls[0].kind === 229) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -18990,7 +20143,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -19028,10 +20181,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69: - case 172: + case 70: + case 173: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194: + case 195: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -19052,7 +20205,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, 218), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -19069,10 +20222,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } - while (node && node.kind !== 230) { + while (node && node.kind !== 231) { node = node.parent; } return node; @@ -19082,10 +20235,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240) { + if (node.moduleReference.kind === 241) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -19186,19 +20339,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229: + case 230: return getTargetOfImportEqualsDeclaration(node); - case 231: - return getTargetOfImportClause(node); case 232: + return getTargetOfImportClause(node); + case 233: return getTargetOfNamespaceImport(node); - case 234: + case 235: return getTargetOfImportSpecifier(node); - case 238: + case 239: return getTargetOfExportSpecifier(node); - case 235: + case 236: return getTargetOfExportAssignment(node); - case 228: + case 229: return getTargetOfNamespaceExportDeclaration(node); } } @@ -19242,10 +20395,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235) { + if (node.kind === 236) { checkExpressionCached(node.expression); } - else if (node.kind === 238) { + else if (node.kind === 239) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -19253,15 +20406,15 @@ var ts; } } } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { + if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 139) { + if (entityName.kind === 70 || entityName.parent.kind === 140) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 229); + ts.Debug.assert(entityName.parent.kind === 230); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -19273,16 +20426,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69) { + if (name.kind === 70) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 || name.kind === 172) { - var left = name.kind === 139 ? name.left : name.expression; - var right = name.kind === 139 ? name.right : name.name; + else if (name.kind === 140 || name.kind === 173) { + var left = name.kind === 140 ? name.left : name.expression; + var right = name.kind === 140 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -19465,7 +20618,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 && ts.nodeIsPresent(member.body)) { return member; } } @@ -19539,7 +20692,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225: + case 226: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -19572,7 +20725,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -19603,7 +20756,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -19617,10 +20770,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145: - case 147: - case 149: + case 146: + case 148: case 150: + case 151: continue; default: return false; @@ -19642,7 +20795,7 @@ var ts; return { accessibility: 1, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined, }; } return hasAccessibleDeclarations; @@ -19663,7 +20816,7 @@ var ts; } return { accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 }; @@ -19710,11 +20863,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 158 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 139 || entityName.kind === 172 || - entityName.parent.kind === 229) { + else if (entityName.kind === 140 || entityName.kind === 173 || + entityName.parent.kind === 230) { meaning = 1920; } else { @@ -19806,10 +20959,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164) { + while (node.kind === 165) { node = node.parent; } - if (node.kind === 223) { + if (node.kind === 224) { return getSymbolOfNode(node); } } @@ -19817,7 +20970,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 && + node.parent.kind === 227 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -19831,10 +20984,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192: + case 193: return "(Anonymous class)"; - case 179: case 180: + case 181: return "(Anonymous function)"; } } @@ -19848,17 +21001,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } else { - writePunctuation(writer, 21); + writePunctuation(writer, 22); writer.writeSymbol(symbolName, symbol); } } @@ -19934,7 +21087,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 | 65536 | 16 | 16384)) { @@ -19955,23 +21108,23 @@ var ts; writer.writeStringLiteral(literalTypeToString(type)); } else { - writePunctuation(writer, 15); + writePunctuation(writer, 16); writeSpace(writer); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writeSpace(writer); - writePunctuation(writer, 16); + writePunctuation(writer, 17); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24) { + if (delimiter !== 25) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 ? 0 : 64); + writeType(types[i], delimiter === 25 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -19979,29 +21132,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 19); writePunctuation(writer, 20); + writePunctuation(writer, 21); } else if (type.target.flags & 262144) { - writePunctuation(writer, 19); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24); writePunctuation(writer, 20); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); + writePunctuation(writer, 21); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -20016,7 +21169,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } } @@ -20026,16 +21179,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } if (type.flags & 524288) { - writeTypeList(formatUnionTypes(type.types), 47); + writeTypeList(formatUnionTypes(type.types), 48); } else { - writeTypeList(type.types, 46); + writeTypeList(type.types, 47); } if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } } function writeAnonymousType(type, flags) { @@ -20053,7 +21206,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 117); + writeKeyword(writer, 118); } } else { @@ -20074,7 +21227,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 226; + return declaration.parent.kind === 256 || declaration.parent.kind === 227; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -20083,37 +21236,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); + writeKeyword(writer, 102); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20); - writePunctuation(writer, 54); + writePunctuation(writer, 21); + writePunctuation(writer, 55); writeSpace(writer); writeType(info.type, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -20131,53 +21284,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); writePunctuation(writer, 16); + writePunctuation(writer, 17); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15); + writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132); - writeIndexSignature(resolved.numberIndexInfo, 130); + writeIndexSignature(resolved.stringIndexInfo, 133); + writeIndexSignature(resolved.numberIndexInfo, 131); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -20187,21 +21340,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16); + writePunctuation(writer, 17); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -20216,7 +21369,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83); + writeKeyword(writer, 84); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -20224,7 +21377,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -20233,36 +21386,36 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 167) { - writePunctuation(writer, 15); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 168) { writePunctuation(writer, 16); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 17); } - else if (bindingPattern.kind === 168) { - writePunctuation(writer, 19); + else if (bindingPattern.kind === 169) { + writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169); + ts.Debug.assert(bindingElement.kind === 170); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -20270,75 +21423,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - var flags_1 = 256; + writePunctuation(writer, 26); + var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); - flags_1 = 0; + flags = 0; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18); + writePunctuation(writer, 19); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97); + writeKeyword(writer, 98); } writeSpace(writer); - writeKeyword(writer, 124); + writeKeyword(writer, 125); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 34); + writePunctuation(writer, 35); } else { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } writeSpace(writer); if (signature.typePredicate) { @@ -20351,7 +21504,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -20387,63 +21540,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169: + case 170: return isDeclarationVisible(node.parent.parent); - case 218: + case 219: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 225: - case 221: + case 226: case 222: case 223: - case 220: case 224: - case 229: + case 221: + case 225: + case 230: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } return isDeclarationVisible(parent_10); + case 146: case 145: - case 144: - case 149: case 150: + case 151: + case 148: case 147: - case 146: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 148: - case 152: - case 151: + case 149: case 153: - case 142: - case 226: - case 156: + case 152: + case 154: + case 143: + case 227: case 157: - case 159: - case 155: + case 158: case 160: + case 156: case 161: case 162: case 163: case 164: + case 165: return isDeclarationVisible(node.parent); - case 231: case 232: - case 234: + case 233: + case 235: return false; - case 141: + case 142: case 256: - case 228: + case 229: return true; - case 235: + case 236: return false; default: return false; @@ -20452,10 +21605,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235) { + if (node.parent && node.parent.kind === 236) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 239) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -20534,12 +21687,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218: case 219: + case 220: + case 235: case 234: case 233: case 232: - case 231: node = node.parent; break; default: @@ -20567,12 +21720,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69: + case 70: return name.text; case 9: case 8: return name.text; - case 140: + case 141: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -20580,7 +21733,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -20595,7 +21748,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 167) { + if (pattern.kind === 168) { var name_14 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_14)) { return anyType; @@ -20651,15 +21804,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 && - declaration.parent.kind === 219 && - declaration.parent.parent.kind === 200) { + if (declaration.kind === 219 && + declaration.parent.kind === 220 && + declaration.parent.parent.kind === 201) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142) { + else if (declaration.kind === 143) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -20667,9 +21820,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; @@ -20681,10 +21838,10 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 207) { + if (declaration.parent.parent.kind === 208) { return stringType; } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 209) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -20693,15 +21850,19 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { + if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var func = declaration.parent; - if (func.kind === 150 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); + if (func.kind === 151 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -20714,8 +21875,7 @@ var ts; } var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -20788,7 +21948,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 + return pattern.kind === 168 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -20813,7 +21973,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 ? root.parent : root; + var memberDeclaration = root.kind === 143 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -20826,7 +21986,7 @@ var ts; if (declaration.parent.kind === 252) { return links.type = anyType; } - if (declaration.kind === 235) { + if (declaration.kind === 236) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { @@ -20836,15 +21996,15 @@ var ts; return unknownType; } var type = void 0; - if (declaration.kind === 187 || - declaration.kind === 172 && declaration.parent.kind === 187) { + if (declaration.kind === 188 || + declaration.kind === 173 && declaration.parent.kind === 188) { if (declaration.flags & 1048576) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -20870,7 +22030,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149) { + if (accessor.kind === 150) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -20890,8 +22050,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149); - var setter = ts.getDeclarationOfKind(symbol, 150); + var getter = ts.getDeclarationOfKind(symbol, 150); + var setter = ts.getDeclarationOfKind(symbol, 151); if (getter && getter.flags & 1048576) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -20932,7 +22092,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149); + var getter_1 = ts.getDeclarationOfKind(symbol, 150); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -20943,7 +22103,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -21028,9 +22188,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 || node.kind === 192 || - node.kind === 220 || node.kind === 179 || - node.kind === 147 || node.kind === 180) { + if (node.kind === 222 || node.kind === 193 || + node.kind === 221 || node.kind === 180 || + node.kind === 148 || node.kind === 181) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -21039,15 +22199,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 222); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); 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 === 222 || node.kind === 221 || - node.kind === 192 || node.kind === 223) { + if (node.kind === 223 || node.kind === 222 || + node.kind === 193 || node.kind === 224) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -21173,7 +22333,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 === 222 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -21202,7 +22362,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222) { + if (declaration.kind === 223) { if (declaration.flags & 64) { return false; } @@ -21264,7 +22424,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223); + declaration = ts.getDeclarationOfKind(symbol, 224); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -21288,14 +22448,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 69 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -21323,7 +22483,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 === 224) { + if (declaration.kind === 225) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -21361,7 +22521,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -21410,20 +22570,20 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 166: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: + case 167: return true; - case 160: + case 161: return isIndependentType(node.elementType); - case 155: + case 156: return isIndependentTypeReference(node); } return false; @@ -21432,7 +22592,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -21448,12 +22608,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { + case 146: case 145: - case 144: return isIndependentVariableLikeDeclaration(declaration); - case 147: - case 146: case 148: + case 147: + case 149: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -22019,7 +23179,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69) { + if (node.parameterName.kind === 70) { var parameterName = node.parameterName; return { kind: 1, @@ -22058,7 +23218,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166) { + if (param.type && param.type.kind === 167) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -22070,10 +23230,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 149 || declaration.kind === 150) && + if ((declaration.kind === 150 || declaration.kind === 151) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 ? 150 : 149; + var otherKind = declaration.kind === 150 ? 151 : 150; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -22085,24 +23245,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 ? + var classType = declaration.kind === 149 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -22118,8 +23275,8 @@ var ts; return type; } } - if (declaration.kind === 149 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150); + if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -22133,19 +23290,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: + case 181: case 269: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; @@ -22226,7 +23383,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 || signature.declaration.kind === 152; + var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; var type = createObjectType(2097152); type.members = emptySymbols; type.properties = emptyArray; @@ -22240,7 +23397,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 130 : 132; + var syntaxKind = kind === 1 ? 131 : 133; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -22267,7 +23424,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141).constraint; + return ts.getDeclarationOfKind(type.symbol, 142).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -22300,7 +23457,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); } function getTypeListId(types) { var result = ""; @@ -22400,11 +23557,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155: + case 156: return node.typeName; case 267: return node.name; - case 194: + case 195: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -22412,7 +23569,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -22440,11 +23597,11 @@ var ts; var type = void 0; if (node.kind === 267) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 155 + var typeNameOrExpression = node.kind === 156 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -22473,9 +23630,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221: case 222: - case 224: + case 223: + case 225: return declaration; } } @@ -22850,9 +24007,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 148 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -22871,25 +24028,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117: + case 118: case 258: case 259: return anyType; - case 132: + case 133: return stringType; - case 130: + case 131: return numberType; - case 120: + case 121: return booleanType; - case 133: + case 134: return esSymbolType; - case 103: + case 104: return voidType; - case 135: + case 136: return undefinedType; - case 93: + case 94: return nullType; - case 127: + case 128: return neverType; case 283: return nullType; @@ -22897,33 +24054,33 @@ var ts; return undefinedType; case 285: return neverType; - case 165: - case 97: - return getTypeFromThisTypeNode(node); case 166: + case 98: + return getTypeFromThisTypeNode(node); + case 167: return getTypeFromLiteralTypeNode(node); case 282: return getTypeFromLiteralTypeNode(node.literal); - case 155: + case 156: case 267: return getTypeFromTypeReference(node); - case 154: + case 155: return booleanType; - case 194: + case 195: return getTypeFromTypeReference(node); - case 158: + case 159: return getTypeFromTypeQueryNode(node); - case 160: + case 161: case 260: return getTypeFromArrayTypeNode(node); - case 161: - return getTypeFromTupleTypeNode(node); case 162: + return getTypeFromTupleTypeNode(node); + case 163: case 261: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); case 164: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: case 263: case 264: case 271: @@ -22932,14 +24089,14 @@ var ts; return getTypeFromTypeNode(node.type); case 265: return getTypeFromTypeNode(node.literal); - case 156: case 157: - case 159: + case 158: + case 160: case 281: case 269: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); - case 69: - case 139: + case 70: + case 140: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262: @@ -23095,23 +24252,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: - case 221: - case 192: + case 181: case 222: + case 193: case 223: + case 224: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -23121,14 +24278,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222) { + if (ts.isClassLike(node) || node.kind === 223) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225: + case 226: case 256: return false; } @@ -23163,35 +24320,43 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179: case 180: + case 181: return isContextSensitiveFunctionLikeDeclaration(node); - case 171: + case 172: return ts.forEach(node.properties, isContextSensitive); - case 170: + case 171: return ts.forEach(node.elements, isContextSensitive); - case 188: + case 189: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187: - return node.operatorToken.kind === 52 && + case 188: + return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253: return isContextSensitive(node.initializer); + case 148: case 147: - case 146: return isContextSensitiveFunctionLikeDeclaration(node); - case 178: + case 179: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + if (node.typeParameters) { + return false; + } + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + if (node.kind === 181) { + return false; + } + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -23611,8 +24776,8 @@ var ts; } if (source.flags & 524288 && target.flags & 524288 || source.flags & 1048576 && target.flags & 1048576) { - if (result = eachTypeRelatedToSomeType(source, target, false)) { - if (result &= eachTypeRelatedToSomeType(target, source, false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -23663,7 +24828,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -24260,7 +25425,7 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -24268,7 +25433,7 @@ var ts; type.flags & 64 && type.flags & 16777216 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { @@ -24379,10 +25544,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -24423,25 +25588,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 146: case 145: - case 144: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142: + case 143: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169: + case 170: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: - case 179: + case 151: case 180: + case 181: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -24486,7 +25651,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -24494,7 +25659,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } function couldContainTypeParameters(type) { @@ -24735,7 +25900,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; inferenceSucceeded = !!unionOrSuperType; @@ -24776,10 +25941,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 158: + case 159: return true; - case 69: - case 139: + case 70: + case 140: node = node.parent; continue; default: @@ -24789,14 +25954,14 @@ var ts; ts.Debug.fail("should not get here"); } function getFlowCacheKey(node) { - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97) { + if (node.kind === 98) { return "0"; } - if (node.kind === 172) { + if (node.kind === 173) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -24804,31 +25969,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: return node; - case 172: + case 173: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69: - return target.kind === 69 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 || target.kind === 169) && + case 70: + return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 || target.kind === 170) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97: - return target.kind === 97; - case 172: - return target.kind === 172 && + case 98: + return target.kind === 98; + case 173: + return target.kind === 173 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172) { + while (source.kind === 173) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -24837,15 +26002,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 && + return target.kind === 173 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69) { + if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172) { + if (expr.kind === 173) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -24875,7 +26040,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 && + if (callExpression.expression.kind === 173 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -25001,7 +26166,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 || node.parent.kind === 253 ? + return node.parent.kind === 171 || node.parent.kind === 253 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -25020,17 +26185,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207: - return stringType; case 208: + return stringType; + case 209: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187: + case 188: return getAssignedTypeOfBinaryExpression(parent); - case 181: + case 182: return undefinedType; - case 170: + case 171: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191: + case 192: return getAssignedTypeOfSpreadElement(parent); case 253: return getAssignedTypeOfPropertyAssignment(parent); @@ -25042,7 +26207,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 ? + var type = pattern.kind === 168 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -25057,38 +26222,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207) { + if (node.parent.parent.kind === 208) { return stringType; } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 209) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 ? + return node.kind === 219 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 || node.kind === 169 ? + return node.kind === 219 || node.kind === 170 ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 && node.parent.kind === 188 && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178: + case 179: return getReferenceCandidate(node.expression); - case 187: + case 188: switch (node.operatorToken.kind) { - case 56: + case 57: return getReferenceCandidate(node.left); - case 24: + case 25: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 || + parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -25159,24 +26337,88 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 ? + autoArrayType : + createArrayType(elementType.flags & 524288 ? + getUnionType(elementType.types, true) : + elementType); + } + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || + parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 && + parent.expression === root && + parent.parent.kind === 188 && + parent.parent.operatorToken.kind === 57 && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 && getTypeWithFacts(result, 524288).flags & 8192) { + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512) { + if (flow.flags & 1024) { for (var i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { return visitedFlowTypes[i]; @@ -25206,18 +26448,25 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172) { + if (container && container !== flowContainer && reference.kind !== 173) { flow = container.flowNode; continue; } type = initialType; } else { - type = declaredType; + type = convertAutoToAny(declaredType); } - if (flow.flags & 512) { + if (flow.flags & 1024) { visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; @@ -25228,30 +26477,70 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 || node.parent.kind === 186) { + if (node.parent.kind === 186 || node.parent.kind === 187) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; } return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | 2048)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192)) { - var assumeTrue = (flow.flags & 32) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + var assumeTrue = (flow.flags & 32) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -25286,7 +26575,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { var id = getFlowNodeId(flow); @@ -25298,8 +26587,8 @@ var ts; return cache[key]; } for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), true); } } var antecedentTypes = []; @@ -25330,14 +26619,14 @@ var ts; break; } } - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 && + return expr.kind === 173 && declaredType.flags & 524288 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -25362,19 +26651,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56: + case 57: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30: case 31: case 32: case 33: + case 34: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 && right_1.kind === 9) { + if (left_1.kind === 183 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 && left_1.kind === 9) { + if (right_1.kind === 183 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -25393,9 +26682,9 @@ var ts; return declaredType; } break; - case 91: + case 92: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24: + case 25: return narrowType(type, expr.right, assumeTrue); } return type; @@ -25404,7 +26693,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -25412,10 +26701,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 || operator === 31; + var doubleEquals = operator === 31 || operator === 32; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 93 ? + value.kind === 94 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -25441,7 +26730,7 @@ var ts; } return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288)) { @@ -25552,7 +26841,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 || invokedExpression.kind === 172) { + if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -25567,18 +26856,18 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174: + case 175: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178: + case 179: return narrowType(type, expr.expression, assumeTrue); - case 187: + case 188: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185: - if (expr.operator === 49) { + case 186: + if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -25587,7 +26876,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 69) { + if (location.kind === 70) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -25601,7 +26890,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178) { + while (expression.kind === 179) { expression = expression.expression; } return expression; @@ -25610,9 +26899,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 || + node.kind === 227 || node.kind === 256 || - node.kind === 145) { + node.kind === 146) { return node; } } @@ -25640,10 +26929,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69) { + if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { symbol.isAssigned = true; } } @@ -25652,12 +26941,15 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 180) { + if (container.kind === 181) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -25675,7 +26967,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 221 + && declaration_1.kind === 222 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -25687,11 +26979,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192) { + else if (declaration_1.kind === 193) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 && ts.hasModifier(container, 32)) { + if (container.kind === 146 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -25709,28 +27001,26 @@ var ts; if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 142; + var isParameter = ts.getRootDeclaration(declaration).kind === 143; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || - flowContainer.kind === 180 || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || + flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { @@ -25770,8 +27060,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 206 && - ts.getAncestor(symbol.valueDeclaration, 219).parent === container && + if (container.kind === 207 && + ts.getAncestor(symbol.valueDeclaration, 220).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -25783,16 +27073,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 178) { + while (current.parent.kind === 179) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 || current.parent.kind === 186)) { + else if ((current.parent.kind === 186 || current.parent.kind === 187)) { var expr = current.parent; - isAssigned = expr.operator === 41 || expr.operator === 42; + isAssigned = expr.operator === 42 || expr.operator === 43; } if (!isAssigned) { return false; @@ -25809,7 +27099,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 145 || container.kind === 148) { + if (container.kind === 146 || container.kind === 149) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -25843,7 +27133,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 148) { + if (container.kind === 149) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -25853,29 +27143,29 @@ var ts; } } } - if (container.kind === 180) { + if (container.kind === 181) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 225: + case 226: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 224: + case 225: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 148: + case 149: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 146: case 145: - case 144: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140: + case 141: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -25884,7 +27174,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 179 && + if (container.kind === 180 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -25896,7 +27186,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -25928,18 +27218,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142) { + if (n.kind === 143) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 180) { + while (container && container.kind === 181) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -25948,16 +27238,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 140) { + while (current && current !== container && current.kind !== 141) { current = current.parent; } - if (current && current.kind === 140) { + if (current && current.kind === 141) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -25972,7 +27262,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 147 && ts.getModifierFlags(container) & 256) { + if (container.kind === 148 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -25983,7 +27273,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171) { + if (container.parent.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -26001,7 +27291,7 @@ var ts; } return unknownType; } - if (container.kind === 148 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -26013,35 +27303,38 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 148; + return container.kind === 149; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 171) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || - container.kind === 150; + return container.kind === 148 || + container.kind === 147 || + container.kind === 150 || + container.kind === 151; } else { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || + return container.kind === 148 || + container.kind === 147 || container.kind === 150 || + container.kind === 151 || + container.kind === 146 || container.kind === 145 || - container.kind === 144 || - container.kind === 148; + container.kind === 149; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -26091,7 +27384,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -26143,7 +27436,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 && node.parent.initializer === node) { + if (node.parent.kind === 143 && node.parent.initializer === node) { return true; } node = node.parent; @@ -26152,8 +27445,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 148 || - functionDecl.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150))) { + functionDecl.kind === 149 || + functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -26172,7 +27465,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176) { + if (template.parent.kind === 177) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -26180,7 +27473,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { + if (operator >= 57 && operator <= 69) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -26188,14 +27481,14 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52) { + else if (operator === 53) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); } return type; } - else if (operator === 51 || operator === 24) { + else if (operator === 52 || operator === 25) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -26209,8 +27502,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -26304,36 +27597,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: - case 169: + case 170: return getContextualTypeForInitializerExpression(node); - case 180: - case 211: + case 181: + case 212: return getContextualTypeForReturnExpression(node); - case 190: + case 191: return getContextualTypeForYieldOperand(parent); - case 174: case 175: + case 176: return getContextualTypeForArgument(parent, node); - case 177: - case 195: + case 178: + case 196: return getTypeFromTypeNode(parent.type); - case 187: + case 188: return getContextualTypeForBinaryOperand(node); case 253: case 254: return getContextualTypeForObjectLiteralElement(parent); - case 170: + case 171: return getContextualTypeForElementExpression(node); - case 188: + case 189: return getContextualTypeForConditionalOperand(node); - case 197: - ts.Debug.assert(parent.parent.kind === 189); + case 198: + ts.Debug.assert(parent.parent.kind === 190); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178: + case 179: return getContextualType(parent); case 248: return getContextualType(parent); @@ -26353,7 +27646,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 || node.kind === 180; + return node.kind === 180 || node.kind === 181; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -26366,7 +27659,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -26376,8 +27669,8 @@ var ts; } var signatureList; var types = type.types; - 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 signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -26407,8 +27700,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 169 && !!node.initializer) || - (node.kind === 187 && node.operatorToken.kind === 56); + return (node.kind === 170 && !!node.initializer) || + (node.kind === 188 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -26417,7 +27710,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191) { + if (inDestructuringPattern && e.kind === 192) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -26429,7 +27722,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191; + hasSpreadElement = hasSpreadElement || e.kind === 192; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -26440,7 +27733,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 168 || pattern.kind === 170)) { + if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -26448,7 +27741,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193) { + if (patternElement.kind !== 194) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -26465,7 +27758,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -26509,7 +27802,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 || contextualType.pattern.kind === 171); + (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -26524,7 +27817,7 @@ var ts; if (memberDecl.kind === 253) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147) { + else if (memberDecl.kind === 148) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -26563,7 +27856,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 149 || memberDecl.kind === 150); + ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -26622,10 +27915,10 @@ var ts; case 248: checkJsxExpression(child); break; - case 241: + case 242: checkJsxElement(child); break; - case 242: + case 243: checkJsxSelfClosingElement(child); break; } @@ -26636,7 +27929,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 172 || tagName.kind === 97) { + if (tagName.kind === 173 || tagName.kind === 98) { return false; } else { @@ -26739,7 +28032,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } function getJsxElementPropertiesName() { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -26768,7 +28061,7 @@ var ts; } if (elemType.flags & 524288) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), true); } @@ -26944,7 +28237,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145; + return s.valueDeclaration ? s.valueDeclaration.kind : 146; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -26955,11 +28248,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 || node.kind === 218 ? + var errorNode = node.kind === 173 || node.kind === 219 ? node.name : node.right; - if (left.kind === 95) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 147) { + if (left.kind === 96) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -26979,7 +28272,7 @@ var ts; } return true; } - if (left.kind === 95) { + if (left.kind === 96) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -27053,7 +28346,7 @@ var ts; checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 172 || ts.isAssignmentTarget(node) || + if (node.kind !== 173 || ts.isAssignmentTarget(node) || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 524288)) { return propType; @@ -27075,7 +28368,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 + var left = node.kind === 173 ? node.expression : node.left; var type = checkExpression(left); @@ -27089,13 +28382,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219) { + if (initializer.kind === 220) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69) { + else if (initializer.kind === 70) { return getResolvedSymbol(initializer); } return undefined; @@ -27105,13 +28398,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69) { + if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 && + if (node.kind === 208 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -27127,7 +28420,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 && node.parent.expression === node) { + if (node.parent.kind === 176 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -27191,7 +28484,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 || indexArgumentExpression.kind === 172) { + if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -27234,10 +28527,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176) { + if (node.kind === 177) { checkExpression(node.template); } - else if (node.kind !== 143) { + else if (node.kind !== 144) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -27288,7 +28581,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191) { + if (arg && arg.kind === 192) { return i; } } @@ -27301,11 +28594,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176) { + if (node.kind === 177) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189) { + if (tagExpression.template.kind === 190) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -27313,11 +28606,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); + ts.Debug.assert(templateLiteral.kind === 12); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143) { + else if (node.kind === 144) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -27325,7 +28618,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 175); + ts.Debug.assert(callExpression.kind === 176); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -27384,9 +28677,9 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); @@ -27431,7 +28724,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175) { + if (thisType && thisType !== voidType && node.kind !== 176) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -27444,9 +28737,9 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -27459,28 +28752,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 174) { + if (node.kind === 175) { var callee = node.expression; - if (callee.kind === 172) { + if (callee.kind === 173) { return callee.expression; } - else if (callee.kind === 173) { + else if (callee.kind === 174) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 176) { + if (node.kind === 177) { var template = node.template; args = [undefined]; - if (template.kind === 189) { + if (template.kind === 190) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143) { + else if (node.kind === 144) { return undefined; } else { @@ -27489,21 +28782,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143) { + if (node.kind === 144) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return 1; - case 145: + case 146: return 2; - case 147: - case 149: + case 148: case 150: + case 151: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 142: + case 143: return 3; } } @@ -27512,48 +28805,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { return anyType; } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var element = node; switch (element.name.kind) { - case 69: + case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 140: + case 141: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -27570,20 +28863,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { return numberType; } - if (node.kind === 145) { + if (node.kind === 146) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -27603,27 +28896,27 @@ var ts; ts.Debug.fail("Decorators should not have a fourth synthetic argument."); return unknownType; } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 143) { + function getEffectiveArgumentType(node, argIndex) { + if (node.kind === 144) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 143 || - (argIndex === 0 && node.kind === 176)) { + if (node.kind === 144 || + (argIndex === 0 && node.kind === 177)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143) { + if (node.kind === 144) { return node.expression; } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return node.template; } else { @@ -27631,12 +28924,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176; - var isDecorator = node.kind === 143; + var isTaggedTemplate = node.kind === 177; + var isDecorator = node.kind === 144; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { + if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); } } @@ -27662,7 +28955,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -27777,7 +29070,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -27930,16 +29223,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147: - case 149: + case 148: case 150: + case 151: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -27966,13 +29259,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174: - return resolveCallExpression(node, candidatesOutArray); case 175: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 176: + return resolveNewExpression(node, candidatesOutArray); + case 177: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143: + case 144: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -28001,17 +29294,17 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { return voidType; } - if (node.kind === 175) { + if (node.kind === 176) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 && - declaration.kind !== 152 && - declaration.kind !== 157 && + declaration.kind !== 149 && + declaration.kind !== 153 && + declaration.kind !== 158 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 69 ? + var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -28023,7 +29316,9 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, true) && + !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -28063,21 +29358,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } function assignBindingElementTypes(node) { @@ -28085,7 +29395,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69) { + if (element.name.kind === 70) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -28098,8 +29408,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 || - parameter.valueDeclaration.name.kind === 168)) { + (parameter.valueDeclaration.name.kind === 168 || + parameter.valueDeclaration.name.kind === 169)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -28138,7 +29448,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199) { + if (func.body.kind !== 200) { 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); @@ -28217,7 +29527,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -28246,7 +29556,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 || func.kind === 180)) { + func.kind === 180 || func.kind === 181)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -28263,7 +29573,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -28290,9 +29600,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179) { + if (!hasGrammarError && node.kind === 180) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -28326,14 +29636,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147) { + if (produceDiagnostics && node.kind !== 148) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -28343,7 +29653,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199) { + if (node.body.kind === 200) { checkSourceElement(node.body); } else { @@ -28378,10 +29688,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 172 || expr.kind === 173) && - expr.expression.kind === 97) { + (expr.kind === 173 || expr.kind === 174) && + expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148)) + if (!(func && func.kind === 149)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -28390,13 +29700,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 || expr.kind === 173) { + if (expr.kind === 173 || expr.kind === 174) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232; + return declaration && declaration.kind === 233; } } } @@ -28404,7 +29714,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 && node.kind !== 172 && node.kind !== 173) { + if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { error(expr, invalidReferenceMessage); return false; } @@ -28412,7 +29722,7 @@ var ts; var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); if (symbol) { if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 69 && !(symbol.flags & 3)) { + if (node.kind === 70 && !(symbol.flags & 3)) { error(expr, invalidReferenceMessage); return false; } @@ -28422,7 +29732,7 @@ var ts; } } } - else if (node.kind === 173) { + else if (node.kind === 174) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -28459,24 +29769,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 && node.operand.kind === 8) { + if (node.operator === 37 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 35: case 36: - case 50: + case 37: + case 51: if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49: + case 50: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 41: case 42: + case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); @@ -28502,8 +29812,8 @@ var ts; } if (type.flags & 1572864) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -28517,8 +29827,8 @@ var ts; } if (type.flags & 524288) { 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 (!isTypeOfKind(t, kind)) { return false; } @@ -28527,8 +29837,8 @@ var ts; } if (type.flags & 1048576) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -28566,18 +29876,18 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 || property.kind === 254) { var name_17 = property.name; - if (name_17.kind === 140) { + if (name_17.kind === 141) { checkComputedPropertyName(name_17); } if (isComputedNonLiteralName(name_17)) { @@ -28616,8 +29926,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193) { - if (element.kind !== 191) { + if (element.kind !== 194) { + if (element.kind !== 192) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -28643,7 +29953,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -28670,14 +29980,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 && target.operatorToken.kind === 56) { + if (target.kind === 188 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170) { + if (target.kind === 171) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -28692,49 +30002,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69: + case 70: case 9: - case 10: - case 176: - case 189: case 11: + case 177: + case 190: + case 12: case 8: - case 99: - case 84: - case 93: - case 135: - case 179: - case 192: + case 100: + case 85: + case 94: + case 136: case 180: - case 170: + case 193: + case 181: case 171: - case 182: - case 196: + case 172: + case 183: + case 197: + case 243: case 242: - case 241: return true; - case 188: + case 189: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187: + case 188: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185: case 186: + case 187: switch (node.operator) { - case 49: - case 35: - case 36: case 50: + case 36: + case 37: + case 51: return true; } return false; - case 183: - case 177: - case 195: + case 184: + case 178: + case 196: default: return false; } @@ -28754,34 +30064,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 171 || left.kind === 170)) { + if (operator === 57 && (left.kind === 172 || left.kind === 171)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37: case 38: - case 59: - case 60: case 39: + case 60: case 61: case 40: case 62: - case 36: - case 58: - case 43: + case 41: case 63: + case 37: + case 59: case 44: case 64: case 45: case 65: - case 47: - case 67: - case 48: - case 68: case 46: case 66: + case 48: + case 68: + case 49: + case 69: + case 47: + case 67: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -28805,8 +30115,8 @@ var ts; } } return numberType; - case 35: - case 57: + case 36: + case 58: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -28835,24 +30145,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57) { + if (operator === 58) { checkAssignmentOperator(resultType); } return resultType; - case 25: - case 27: + case 26: case 28: case 29: + case 30: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30: case 31: case 32: case 33: + case 34: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -28863,22 +30173,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91: + case 92: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: + case 91: return checkInExpression(left, right, leftType, rightType); - case 51: + case 52: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52: + case 53: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56: + case 57: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24: + case 25: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -28896,21 +30206,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 48: + case 68: + return 53; + case 49: + case 69: + return 34; case 47: case 67: return 52; - case 48: - case 68: - return 33; - case 46: - case 66: - return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 && operator <= 68) { + if (produceDiagnostics && operator >= 57 && operator <= 69) { var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); @@ -28982,9 +30292,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 99: + case 100: return trueType; - case 84: + case 85: return falseType; } } @@ -29013,7 +30323,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 || node.kind === 195; + return node.kind === 178 || node.kind === 196; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -29039,14 +30349,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -29069,7 +30379,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139) { + if (node.kind === 140) { type = checkQualifiedName(node); } else { @@ -29077,9 +30387,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 172 && node.parent.expression === node) || - (node.parent.kind === 173 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 139) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 && node.parent.expression === node) || + (node.parent.kind === 174 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 140) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -29088,79 +30398,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69: + case 70: return checkIdentifier(node); - case 97: + case 98: return checkThisExpression(node); - case 95: + case 96: return checkSuperExpression(node); - case 93: + case 94: return nullWideningType; case 9: case 8: - case 99: - case 84: + case 100: + case 85: return checkLiteralExpression(node); - case 189: + case 190: return checkTemplateExpression(node); - case 11: + case 12: return stringType; - case 10: + case 11: return globalRegExpType; - case 170: - return checkArrayLiteral(node, contextualMapper); case 171: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 172: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 173: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 174: + return checkIndexedAccess(node); case 175: - return checkCallExpression(node); case 176: + return checkCallExpression(node); + case 177: return checkTaggedTemplateExpression(node); - case 178: + case 179: return checkExpression(node.expression, contextualMapper); - case 192: + case 193: return checkClassExpression(node); - case 179: case 180: + case 181: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182: + case 183: return checkTypeOfExpression(node); - case 177: - case 195: - return checkAssertion(node); + case 178: case 196: + return checkAssertion(node); + case 197: return checkNonNullAssertion(node); - case 181: + case 182: return checkDeleteExpression(node); - case 183: - return checkVoidExpression(node); case 184: - return checkAwaitExpression(node); + return checkVoidExpression(node); case 185: - return checkPrefixUnaryExpression(node); + return checkAwaitExpression(node); case 186: - return checkPostfixUnaryExpression(node); + return checkPrefixUnaryExpression(node); case 187: - return checkBinaryExpression(node, contextualMapper); + return checkPostfixUnaryExpression(node); case 188: + return checkBinaryExpression(node, contextualMapper); + case 189: return checkConditionalExpression(node, contextualMapper); - case 191: + case 192: return checkSpreadElementExpression(node, contextualMapper); - case 193: + case 194: return undefinedWideningType; - case 190: + case 191: return checkYieldExpression(node); case 248: return checkJsxExpression(node); - case 241: - return checkJsxElement(node); case 242: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 243: + return checkJsxSelfClosingElement(node); + case 244: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -29181,7 +30491,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -29192,7 +30502,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 || func.kind === 152 || func.kind === 157) { + if (func.kind === 149 || func.kind === 153 || func.kind === 158) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -29204,15 +30514,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 || - node.kind === 220 || - node.kind === 179; + return node.kind === 148 || + node.kind === 221 || + node.kind === 180; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 && + if (param.name.kind === 70 && param.name.text === parameter.text) { return i; } @@ -29262,13 +30572,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 181: + case 152: + case 221: case 180: - case 151: - case 220: - case 179: - case 156: + case 157: + case 148: case 147: - case 146: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -29282,13 +30592,13 @@ var ts; continue; } var name_19 = element.name; - if (name_19.kind === 69 && + if (name_19.kind === 70 && name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 168 || - name_19.kind === 167) { + else if (name_19.kind === 169 || + name_19.kind === 168) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } @@ -29296,12 +30606,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 153) { + if (node.kind === 154) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 || node.kind === 220 || node.kind === 157 || - node.kind === 151 || node.kind === 148 || - node.kind === 152) { + else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || + node.kind === 152 || node.kind === 149 || + node.kind === 153) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -29313,10 +30623,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152: + case 153: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151: + case 152: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -29343,11 +30653,17 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Accessor; + (function (Accessor) { + Accessor[Accessor["Getter"] = 1] = "Getter"; + Accessor[Accessor["Setter"] = 2] = "Setter"; + Accessor[Accessor["Property"] = 3] = "Property"; + })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -29356,18 +30672,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149: + case 150: addName(names, member.name, memberName, 1); break; - case 150: + case 151: addName(names, member.name, memberName, 2); break; - case 145: + case 146: addName(names, member.name, memberName, 3); break; } @@ -29393,12 +30709,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144) { + if (member.kind == 145) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 69: + case 70: memberName = member.name.text; break; default: @@ -29415,7 +30731,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222) { + if (node.kind === 223) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -29430,7 +30746,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132: + case 133: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -29438,7 +30754,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130: + case 131: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -29494,15 +30810,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97) { + if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 && n.kind !== 220) { + else if (n.kind !== 180 && n.kind !== 221) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 && + return n.kind === 146 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -29522,7 +30838,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -29545,18 +30861,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149) { + if (node.kind === 150) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 149 ? 150 : 149; + var otherKind = node.kind === 150 ? 151 : 150; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -29570,11 +30886,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149) { + if (node.kind === 150) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171) { + if (node.parent.kind !== 172) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -29660,9 +30976,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 222 && - n.parent.kind !== 221 && - n.parent.kind !== 192 && + if (n.parent.kind !== 223 && + n.parent.kind !== 222 && + n.parent.kind !== 193 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -29739,7 +31055,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 147 || node.kind === 146) && + var reportError = (node.kind === 148 || node.kind === 147) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -29772,11 +31088,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 || node.parent.kind === 159 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 220 || node.kind === 147 || node.kind === 146 || node.kind === 148) { + if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -29887,16 +31203,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222: + case 223: return 2097152; - case 225: + case 226: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 221: - case 224: + case 222: + case 225: return 2097152 | 1048576; - case 229: + case 230: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -30044,22 +31360,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221: + case 222: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147: - case 149: + case 148: case 150: + case 151: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -30068,9 +31384,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 155) { + if (node && node.kind === 156) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 ? 793064 : 1920; + var meaning = root.parent.kind === 156 ? 793064 : 1920; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -30104,20 +31420,20 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 221: + case 222: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147: - case 149: + case 148: case 150: + case 151: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145: - case 142: + case 146: + case 143: checkTypeAnnotationAsExpression(node); break; } @@ -30137,7 +31453,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 140) { + if (node.name && node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -30180,42 +31496,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256: - case 225: + case 226: checkUnusedModuleMembers(node); break; - case 221: - case 192: + case 222: + case 193: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222: + case 223: checkUnusedTypeParameters(node); break; - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: checkUnusedLocalsAndParameters(node); break; - case 148: - case 179: - case 220: - case 180: - case 147: case 149: + case 180: + case 221: + case 181: + case 148: case 150: + case 151: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146: - case 151: + case 147: case 152: case 153: - case 156: + case 154: case 157: + case 158: checkUnusedTypeParameters(node); break; } @@ -30224,11 +31540,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -30248,19 +31564,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; + return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 || member.kind === 145) { + if (member.kind === 148 || member.kind === 146) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148) { + else if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -30305,7 +31621,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 199) { + if (node.kind === 200) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -30327,19 +31643,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 || - node.kind === 144 || + if (node.kind === 146 || + node.kind === 145 || + node.kind === 148 || node.kind === 147 || - node.kind === 146 || - node.kind === 149 || - node.kind === 150) { + node.kind === 150 || + node.kind === 151) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -30353,7 +31669,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; + var isDeclaration_1 = node.kind !== 70; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -30374,7 +31690,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; + var isDeclaration_2 = node.kind !== 70; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -30384,13 +31700,13 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -30402,7 +31718,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -30414,7 +31730,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 218 && !node.initializer) { + if (node.kind === 219 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -30424,14 +31740,14 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219); - var container = varDeclList.parent.kind === 200 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); + var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 199 && ts.isFunctionLike(container.parent) || + (container.kind === 200 && ts.isFunctionLike(container.parent) || + container.kind === 227 || container.kind === 226 || - container.kind === 225 || container.kind === 256); if (!namesShareScope) { var name_20 = symbolToString(localDeclarationSymbol); @@ -30442,7 +31758,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142) { + if (ts.getRootDeclaration(node).kind !== 143) { return; } var func = ts.getContainingFunction(node); @@ -30451,10 +31767,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 172) { + if (n.kind === 173) { return visit(n.expression); } - else if (n.kind === 69) { + else if (n.kind === 70) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -30465,7 +31781,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142) { + if (symbol.valueDeclaration.kind === 143) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -30474,7 +31790,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 145 && + if (current.parent.kind === 146 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -30491,19 +31807,19 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169) { - if (node.propertyName && node.propertyName.kind === 140) { + if (node.kind === 170) { + if (node.propertyName && node.propertyName.kind === 141) { checkComputedPropertyName(node.propertyName); } var parent_13 = node.parent.parent; @@ -30517,12 +31833,12 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 142 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -30531,7 +31847,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -30549,9 +31865,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 && node.kind !== 144) { + if (node.kind !== 146 && node.kind !== 145) { checkExportsOnMergedDeclarations(node); - if (node.kind === 218 || node.kind === 169) { + if (node.kind === 219 || node.kind === 170) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -30561,8 +31877,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 && right.kind === 218) || - (left.kind === 218 && right.kind === 142)) { + if ((left.kind === 143 && right.kind === 219) || + (left.kind === 219 && right.kind === 143)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -30589,7 +31905,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 171) { + if (node.modifiers && node.parent.kind === 172) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -30608,7 +31924,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201) { + if (node.thenStatement.kind === 202) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -30625,12 +31941,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219) { + if (node.initializer && node.initializer.kind === 220) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -30648,13 +31964,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -30672,7 +31988,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { 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); @@ -30682,7 +31998,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { @@ -30855,7 +32171,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150))); + return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -30877,12 +32193,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 150) { + if (func.kind === 151) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148) { + else if (func.kind === 149) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -30900,7 +32216,7 @@ var ts; } } } - else if (func.kind !== 148 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -30957,7 +32273,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 && current.label.text === node.label.text) { + if (current.kind === 215 && 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; @@ -30983,7 +32299,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { + if (catchClause.variableDeclaration.name.kind !== 70) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -31051,7 +32367,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 140 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -31102,7 +32418,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 || declaration.kind === 222) { + if (declaration.kind === 222 || declaration.kind === 223) { if (!firstDecl) { firstDecl = declaration; } @@ -31239,7 +32555,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 192) { + if (derivedClassDecl.kind === 193) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -31283,7 +32599,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 || kind === 150; + return kind === 150 || kind === 151; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -31350,7 +32666,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -31445,18 +32761,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185: + case 186: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35: return value_1; - case 36: return -value_1; - case 50: return ~value_1; + case 36: return value_1; + case 37: return -value_1; + case 51: return ~value_1; } return undefined; - case 187: + case 188: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -31466,37 +32782,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 47: return left | right; - case 46: return left & right; - case 44: return left >> right; - case 45: return left >>> right; - case 43: return left << right; - case 48: return left ^ right; - case 37: return left * right; - case 39: return left / right; - case 35: return left + right; - case 36: return left - right; - case 40: return left % right; + case 48: return left | right; + case 47: return left & right; + case 45: return left >> right; + case 46: return left >>> right; + case 44: return left << right; + case 49: return left ^ right; + case 38: return left * right; + case 40: return left / right; + case 36: return left + right; + case 37: return left - right; + case 41: return left % right; } return undefined; case 8: return +e.text; - case 178: + case 179: return evalConstant(e.expression); - case 69: + case 70: + case 174: case 173: - case 172: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69) { + if (e.kind === 70) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 173) { + if (e.kind === 174) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -31510,10 +32826,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 69) { + if (current.kind === 70) { break; } - else if (current.kind === 172) { + else if (current.kind === 173) { current = current.expression; } else { @@ -31573,7 +32889,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 224) { + if (declaration.kind !== 225) { return false; } var enumDeclaration = declaration; @@ -31596,8 +32912,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 === 221 || - (declaration.kind === 220 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 || + (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -31656,7 +32972,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, 221); + var mergedClass = ts.getDeclarationOfKind(symbol, 222); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -31699,22 +33015,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200: + case 201: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229: case 230: + case 231: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169: - case 218: + case 170: + case 219: var name_22 = node.name; if (ts.isBindingPattern(name_22)) { for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { @@ -31723,12 +33039,12 @@ var ts; } break; } - case 221: - case 224: - case 220: case 222: case 225: + case 221: case 223: + case 226: + case 224: if (isGlobalAugmentation) { return; } @@ -31744,17 +33060,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69: + case 70: return node; - case 139: + case 140: do { node = node.left; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; - case 172: + case 173: do { node = node.expression; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; } } @@ -31764,9 +33080,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 ? + error(moduleName, node.kind === 237 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -31787,7 +33103,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 ? + var message = node.kind === 239 ? 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)); @@ -31814,7 +33130,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { checkImportBinding(importClause.namedBindings); } else { @@ -31849,7 +33165,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.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); } } @@ -31865,7 +33181,7 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -31879,7 +33195,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -31903,14 +33219,14 @@ var ts; return; } var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 225 && !ts.isAmbientModule(container)) { + if (container.kind === 226 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { markExportAsReferenced(node); } else { @@ -31918,7 +33234,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { @@ -31970,7 +33286,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 && declaration.kind !== 147) || + return (declaration.kind !== 221 && declaration.kind !== 148) || !!declaration.body; } } @@ -31981,118 +33297,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141: - return checkTypeParameter(node); case 142: + return checkTypeParameter(node); + case 143: return checkParameter(node); + case 146: case 145: - case 144: return checkPropertyDeclaration(node); - case 156: case 157: - case 151: + case 158: case 152: - return checkSignatureDeclaration(node); case 153: return checkSignatureDeclaration(node); + case 154: + return checkSignatureDeclaration(node); + case 148: case 147: - case 146: return checkMethodDeclaration(node); - case 148: - return checkConstructorDeclaration(node); case 149: + return checkConstructorDeclaration(node); case 150: + case 151: return checkAccessorDeclaration(node); - case 155: + case 156: return checkTypeReferenceNode(node); - case 154: + case 155: return checkTypePredicate(node); - case 158: - return checkTypeQuery(node); case 159: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 160: - return checkArrayType(node); + return checkTypeLiteral(node); case 161: - return checkTupleType(node); + return checkArrayType(node); case 162: + return checkTupleType(node); case 163: - return checkUnionOrIntersectionType(node); case 164: + return checkUnionOrIntersectionType(node); + case 165: return checkSourceElement(node.type); - case 220: + case 221: return checkFunctionDeclaration(node); - case 199: - case 226: - return checkBlock(node); case 200: + case 227: + return checkBlock(node); + case 201: return checkVariableStatement(node); - case 202: - return checkExpressionStatement(node); case 203: - return checkIfStatement(node); + return checkExpressionStatement(node); case 204: - return checkDoStatement(node); + return checkIfStatement(node); case 205: - return checkWhileStatement(node); + return checkDoStatement(node); case 206: - return checkForStatement(node); + return checkWhileStatement(node); case 207: - return checkForInStatement(node); + return checkForStatement(node); case 208: - return checkForOfStatement(node); + return checkForInStatement(node); case 209: + return checkForOfStatement(node); case 210: - return checkBreakOrContinueStatement(node); case 211: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 212: - return checkWithStatement(node); + return checkReturnStatement(node); case 213: - return checkSwitchStatement(node); + return checkWithStatement(node); case 214: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 215: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 216: + return checkThrowStatement(node); + case 217: return checkTryStatement(node); - case 218: + case 219: return checkVariableDeclaration(node); - case 169: + case 170: return checkBindingElement(node); - case 221: - return checkClassDeclaration(node); case 222: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 223: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 224: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 225: + return checkEnumDeclaration(node); + case 226: return checkModuleDeclaration(node); - case 230: + case 231: return checkImportDeclaration(node); - case 229: + case 230: return checkImportEqualsDeclaration(node); - case 236: + case 237: return checkExportDeclaration(node); - case 235: + case 236: return checkExportAssignment(node); - case 201: + case 202: checkGrammarStatementInAmbientContext(node); return; - case 217: + case 218: checkGrammarStatementInAmbientContext(node); return; - case 239: + case 240: return checkMissingDeclaration(node); } } @@ -32105,17 +33421,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179: case 180: + case 181: + case 148: case 147: - case 146: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149: case 150: + case 151: checkAccessorDeferred(node); break; - case 192: + case 193: checkClassExpressionDeferred(node); break; } @@ -32187,7 +33503,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 && node.parent.statement === node) { + if (node.parent.kind === 213 && node.parent.statement === node) { return true; } node = node.parent; @@ -32213,24 +33529,24 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225: + case 226: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 224: + case 225: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 192: + case 193: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 221: case 222: + case 223: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 179: + case 180: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -32263,33 +33579,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 && + return name.kind === 70 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141: - case 221: + case 142: case 222: case 223: case 224: + case 225: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139) { + while (node.parent && node.parent.kind === 140) { node = node.parent; } - return node.parent && (node.parent.kind === 155 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172) { + while (node.parent && node.parent.kind === 173) { node = node.parent; } - return node.parent && node.parent.kind === 194; + return node.parent && node.parent.kind === 195; } function forEachEnclosingClass(node, callback) { var result; @@ -32306,13 +33622,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139) { + while (nodeOnRightSide.parent.kind === 140) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -32324,7 +33640,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -32336,20 +33652,20 @@ var ts; default: } } - if (entityName.parent.kind === 235 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 172 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 229); + if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 230); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 194) { + if (entityName.parent.kind === 195) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -32365,20 +33681,20 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 69) { + if (entityName.kind === 70) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 172) { + else if (entityName.kind === 173) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139) { + else if (entityName.kind === 140) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -32387,13 +33703,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } else if (entityName.parent.kind === 246) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { return resolveEntityName(entityName, 1); } return undefined; @@ -32411,12 +33727,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69) { + if (node.kind === 70) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 && - node.parent.parent.kind === 167 && + else if (node.parent.kind === 170 && + node.parent.parent.kind === 168 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -32426,11 +33742,11 @@ var ts; } } switch (node.kind) { - case 69: - case 172: - case 139: + case 70: + case 173: + case 140: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: + case 98: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -32438,21 +33754,21 @@ var ts; return sig.thisParameter; } } - case 95: + case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165: + case 166: return getTypeFromTypeNode(node).symbol; - case 121: + case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148) { + if (constructorDeclaration && constructorDeclaration.kind === 149) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 || node.parent.kind === 236) && + ((node.parent.kind === 231 || node.parent.kind === 237) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -32460,7 +33776,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 173 && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -32524,12 +33840,12 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 || expr.kind === 170); - if (expr.parent.kind === 208) { + ts.Debug.assert(expr.kind === 172 || expr.kind === 171); + if (expr.parent.kind === 209) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 187) { + if (expr.parent.kind === 188) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -32537,7 +33853,7 @@ var ts; var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 170); + ts.Debug.assert(expr.parent.kind === 171); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -32678,7 +33994,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 === 199 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -32718,18 +34034,18 @@ var ts; return true; } switch (node.kind) { - case 229: - case 231: + case 230: case 232: - case 234: - case 238: + case 233: + case 235: + case 239: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236: + case 237: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235: + case 236: return node.expression - && node.expression.kind === 69 + && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -32961,7 +34277,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 172) || (node.kind === 69 && isInTypeQuery(node)) + var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -33108,6 +34424,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -33167,14 +34484,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -33191,28 +34508,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128) { - if (node.kind === 144 || node.kind === 146) { + if (modifier.kind !== 129) { + if (node.kind === 145 || node.kind === 147) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153) { + if (node.kind === 154) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74: - if (node.kind !== 224 && node.parent.kind === 221) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); + case 75: + if (node.kind !== 225 && node.parent.kind === 222) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; + case 113: case 112: case 111: - case 110: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111) { + if (modifier.kind === 112) { lastProtected = modifier; } - else if (modifier.kind === 110) { + else if (modifier.kind === 111) { lastPrivate = modifier; } if (flags & 28) { @@ -33227,11 +34544,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 110) { + if (modifier.kind === 111) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -33240,7 +34557,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113: + case 114: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -33250,10 +34567,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -33262,17 +34579,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 128: + case 129: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 && node.kind !== 144 && node.kind !== 153 && node.kind !== 142) { + else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 82: + case 83: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -33285,45 +34602,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 122: + case 123: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 115: + case 116: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221) { - if (node.kind !== 147 && - node.kind !== 145 && - node.kind !== 149 && - node.kind !== 150) { + if (node.kind !== 222) { + if (node.kind !== 148 && + node.kind !== 146 && + node.kind !== 150 && + node.kind !== 151) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -33335,14 +34652,14 @@ var ts; } flags |= 128; break; - case 118: + case 119: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -33350,7 +34667,7 @@ var ts; break; } } - if (node.kind === 148) { + if (node.kind === 149) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -33365,13 +34682,13 @@ var ts; } return; } - else if ((node.kind === 230 || node.kind === 229) && flags & 2) { + else if ((node.kind === 231 || node.kind === 230) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -33387,38 +34704,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149: case 150: - case 148: + case 151: + case 149: + case 146: case 145: - case 144: + case 148: case 147: - case 146: - case 153: - case 225: + case 154: + case 226: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 179: case 180: - case 142: + case 181: + case 143: return false; default: - if (node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 227 || node.parent.kind === 256) { return false; } switch (node.kind) { - case 220: - return nodeHasAnyModifiersExcept(node, 118); case 221: - return nodeHasAnyModifiersExcept(node, 115); + return nodeHasAnyModifiersExcept(node, 119); case 222: - case 200: + return nodeHasAnyModifiersExcept(node, 116); case 223: - return true; + case 201: case 224: - return nodeHasAnyModifiersExcept(node, 74); + return true; + case 225: + return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); return false; @@ -33430,10 +34747,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147: - case 220: - case 179: + case 148: + case 221: case 180: + case 181: if (!node.asteriskToken) { return false; } @@ -33449,7 +34766,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -33491,11 +34808,11 @@ var ts; } function checkGrammarFunctionLikeDeclaration(node) { var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180) { + if (node.kind === 181) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -33530,7 +34847,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 132 && parameter.type.kind !== 130) { + if (parameter.type.kind !== 133 && parameter.type.kind !== 131) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -33557,7 +34874,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193) { + if (arg.kind === 194) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -33583,7 +34900,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -33596,7 +34913,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -33611,14 +34928,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -33627,19 +34944,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 140) { + if (node.kind !== 141) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 220 || - node.kind === 179 || - node.kind === 147); + ts.Debug.assert(node.kind === 221 || + node.kind === 180 || + node.kind === 148); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -33651,7 +34968,7 @@ var ts; } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -33665,7 +34982,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (name_24.kind === 140) { + if (name_24.kind === 141) { checkGrammarComputedPropertyName(name_24); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { @@ -33674,26 +34991,26 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 || prop.kind !== 147) { + if (mod.kind !== 119 || prop.kind !== 148) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_24.kind === 8) { checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147) { + else if (prop.kind === 148) { currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = GetAccessor; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = SetAccessor; } else { @@ -33750,7 +35067,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219) { + if (forInOrOfStatement.initializer.kind === 220) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -33758,20 +35075,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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); @@ -33795,11 +35112,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 ? + return grammarErrorOnNode(accessor.name, kind === 150 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150) { + else if (kind === 151) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -33818,10 +35135,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -33836,8 +35153,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -33852,10 +35169,10 @@ 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 === 222) { + else if (node.parent.kind === 223) { 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 === 159) { + else if (node.parent.kind === 160) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -33866,9 +35183,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214: + case 215: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 209 + var isMisplacedContinueLabel = node.kind === 210 && !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); @@ -33876,8 +35193,8 @@ var ts; return false; } break; - case 213: - if (node.kind === 210 && !node.label) { + case 214: + if (node.kind === 211 && !node.label) { return false; } break; @@ -33890,13 +35207,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 + var message = node.kind === 211 ? 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 === 210 + var message = node.kind === 211 ? 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); @@ -33908,7 +35225,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 168 || node.name.kind === 167) { + if (node.name.kind === 169 || node.name.kind === 168) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -33918,11 +35235,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 && node.parent.parent.kind !== 208) { + if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -33953,8 +35270,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.originalKeywordKind === 108) { + if (name.kind === 70) { + if (name.originalKeywordKind === 109) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -33979,15 +35296,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203: case 204: case 205: - case 212: case 206: + case 213: case 207: case 208: + case 209: return false; - case 214: + case 215: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -34042,7 +35359,7 @@ var ts; return true; } } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 223) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -34050,7 +35367,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159) { + else if (node.parent.kind === 160) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -34063,13 +35380,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 222 || - node.kind === 223 || + if (node.kind === 223 || + node.kind === 224 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || - node.kind === 228 || + node.kind === 229 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -34078,7 +35395,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 === 200) { + if (ts.isDeclaration(decl) || decl.kind === 201) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -34097,7 +35414,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 === 199 || node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { 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); @@ -34136,46 +35453,46 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139] = [ + _a[140] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143] = [ + _a[144] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177] = [ + _a[178] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195] = [ + _a[196] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196] = [ + _a[197] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224] = [ + _a[225] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225] = [ + _a[226] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226] = [ + _a[227] = [ { name: "statements", test: ts.isStatement } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240] = [ + _a[241] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255] = [ @@ -34191,41 +35508,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return initial; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return initial; } var result = initial; switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: case 287: break; - case 140: + case 141: result = reduceNode(node.expression, f, result); break; - case 142: + case 143: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 143: + case 144: result = reduceNode(node.expression, f, result); break; - case 145: + case 146: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147: + case 148: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34234,12 +35551,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148: + case 149: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 149: + case 150: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34247,51 +35564,51 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 150: + case 151: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 167: case 168: + case 169: result = ts.reduceLeft(node.elements, f, result); break; - case 169: + case 170: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 170: + case 171: result = ts.reduceLeft(node.elements, f, result); break; - case 171: + case 172: result = ts.reduceLeft(node.properties, f, result); break; - case 172: + case 173: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 173: + case 174: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 174: + case 175: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 175: + case 176: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176: + case 177: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179: + case 180: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -34299,117 +35616,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180: + case 181: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178: - case 181: + case 179: case 182: case 183: case 184: - case 190: + case 185: case 191: - case 196: + case 192: + case 197: result = reduceNode(node.expression, f, result); break; - case 185: case 186: + case 187: result = reduceNode(node.operand, f, result); break; - case 187: + case 188: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188: + case 189: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189: + case 190: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192: + case 193: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194: + case 195: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 197: + case 198: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 199: + case 200: result = ts.reduceLeft(node.statements, f, result); break; - case 200: + case 201: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202: + case 203: result = reduceNode(node.expression, f, result); break; - case 203: + case 204: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204: + case 205: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 205: - case 212: + case 206: + case 213: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 206: + case 207: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207: case 208: + case 209: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211: - case 215: + case 212: + case 216: result = reduceNode(node.expression, f, result); break; - case 213: + case 214: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214: + case 215: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216: + case 217: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218: + case 219: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219: + case 220: result = ts.reduceLeft(node.declarations, f, result); break; - case 220: + case 221: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34418,7 +35735,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 221: + case 222: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34426,49 +35743,49 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227: + case 228: result = ts.reduceLeft(node.clauses, f, result); break; - case 230: + case 231: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231: - result = reduceNode(node.name, f, result); - result = reduceNode(node.namedBindings, f, result); - break; case 232: result = reduceNode(node.name, f, result); + result = reduceNode(node.namedBindings, f, result); break; case 233: - case 237: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNode(node.name, f, result); break; case 234: case 238: + result = ts.reduceLeft(node.elements, f, result); + break; + case 235: + case 239: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235: + case 236: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236: + case 237: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 241: + case 242: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242: case 243: + case 244: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -34611,153 +35928,153 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return node; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return node; } switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: return node; - case 140: + case 141: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 142: + case 143: return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 145: + case 146: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: - return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 148: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 149: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 150: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 167: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 168: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 169: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 170: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 171: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 172: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 173: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 174: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 175: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 177: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 180: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 181: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); case 182: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 183: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 184: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 185: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187: + case 188: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 186: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 187: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 190: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 191: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 192: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 193: 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 194: + case 195: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 197: + case 198: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 199: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 200: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 201: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 202: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 203: - 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 204: - 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 205: - 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 206: - 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 207: - 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 208: - 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 209: - 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 210: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 211: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 212: - 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 213: - 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 214: - 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 215: - 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 216: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 217: 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 218: - 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 219: - 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 220: - 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 221: + 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 222: 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 227: + case 228: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230: - 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 231: - 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 232: - 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 233: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 234: - 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 235: - 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 236: - 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 237: - 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 238: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 239: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 242: - 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 243: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + case 244: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -34858,67 +36175,67 @@ var ts; return transformFlags | aggregateTransformFlagsForNode(child); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 && kind <= 166) { + if (kind >= 155 && kind <= 167) { return -3; } switch (kind) { - case 174: case 175: - case 170: - return 537133909; - case 225: - return 546335573; - case 142: - return 538968917; + case 176: + case 171: + return 537922901; + case 226: + return 574729557; + case 143: + return 545262933; + case 181: + return 592227669; case 180: - return 550710101; - case 179: - case 220: - return 550726485; - case 219: - return 538968917; case 221: - case 192: - return 537590613; - case 148: - return 550593365; - case 147: + return 592293205; + case 220: + return 545262933; + case 222: + case 193: + return 539749717; case 149: + return 591760725; + case 148: case 150: - return 550593365; - case 117: - case 130: - case 127: - case 132: - case 120: - case 133: - case 103: - case 141: - case 144: - case 146: case 151: + return 591760725; + case 118: + case 131: + case 128: + case 133: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: - case 222: + case 154: case 223: + case 224: return -3; - case 171: - return 537430869; + case 172: + return 539110741; default: - return 536871765; + return 536874325; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -34956,7 +36273,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -34976,9 +36293,9 @@ var ts; } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -34993,10 +36310,10 @@ var ts; } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -35028,9 +36345,9 @@ var ts; } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -35052,7 +36369,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -35073,7 +36390,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -35083,10 +36400,10 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171) { + if (target.kind === 172) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170) { + else if (target.kind === 171) { emitArrayLiteralAssignment(target, value, location); } else { @@ -35118,8 +36435,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193) { - if (e.kind !== 191) { + if (e.kind !== 194) { + if (e.kind !== 192) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -35148,7 +36465,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167) { + else if (name.kind === 168) { var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); } @@ -35168,7 +36485,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53), defaultValue, ts.createToken(54), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54), defaultValue, ts.createToken(55), value); } function createDestructuringPropertyAccess(expression, propertyName) { if (ts.isComputedPropertyName(propertyName)) { @@ -35206,6 +36523,12 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -35216,8 +36539,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(172); context.enableSubstitution(173); + context.enableSubstitution(174); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -35227,7 +36550,6 @@ var ts; var enabledSubstitutions; var classAliases; var applicableSubstitutions; - var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -35261,15 +36583,32 @@ var ts; } return node; } + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 236: + return visitExportAssignment(node); + case 237: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } function namespaceElementVisitor(node) { return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 236 || - node.kind === 230 || + if (node.kind === 237 || node.kind === 231 || - (node.kind === 229 && - node.moduleReference.kind === 240)) { + node.kind === 232 || + (node.kind === 230 && + node.moduleReference.kind === 241)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -35285,15 +36624,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 148: - return undefined; - case 145: - case 153: case 149: + return undefined; + case 146: + case 154: case 150: - case 147: + case 151: + case 148: return visitorWorker(node); - case 198: + case 199: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -35305,84 +36644,87 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82: - case 77: + case 83: + case 78: return currentNamespace ? undefined : node; - case 112: - case 110: + case 113: case 111: - case 115: - case 118: - case 74: - case 122: - case 128: - case 160: + case 112: + case 116: + case 75: + case 123: + case 129: case 161: - case 159: - case 154: - case 141: - case 117: - case 120: - case 132: - case 130: - case 127: - case 103: + case 162: + case 160: + case 155: + case 142: + case 118: + case 121: case 133: + case 131: + case 128: + case 104: + case 134: + case 158: case 157: + case 159: case 156: - case 158: - case 155: - case 162: case 163: case 164: case 165: case 166: - case 153: - case 143: + case 167: + case 154: + case 144: + case 224: + case 146: + case 149: + return visitConstructor(node); case 223: - case 145: - case 148: - return undefined; - case 222: return ts.createNotEmittedStatement(node); - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); case 251: return visitHeritageClause(node); - case 194: + case 195: return visitExpressionWithTypeArguments(node); - case 147: + case 148: return visitMethodDeclaration(node); - case 149: - return visitGetAccessor(node); case 150: + return visitGetAccessor(node); + case 151: return visitSetAccessor(node); - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: - return visitFunctionExpression(node); case 180: + return visitFunctionExpression(node); + case 181: return visitArrowFunction(node); - case 142: + case 143: return visitParameter(node); - case 178: + case 179: return visitParenthesizedExpression(node); - case 177: - case 195: - return visitAssertionExpression(node); + case 178: case 196: + return visitAssertionExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 197: return visitNonNullExpression(node); - case 224: + case 225: return visitEnumDeclaration(node); - case 184: - return visitAwaitExpression(node); - case 200: + case 201: return visitVariableStatement(node); - case 225: + case 219: + return visitVariableDeclaration(node); + case 226: return visitModuleDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -35392,14 +36734,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256: + case 228: case 227: - case 226: - case 199: + case 200: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 222: case 221: - case 220: if (ts.hasModifier(node, 2)) { break; } @@ -35424,14 +36766,14 @@ var ts; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; @@ -35471,7 +36813,7 @@ var ts; classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); } if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); @@ -35517,7 +36859,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); if (staticProperties.length > 0) { var expressions = []; @@ -35528,7 +36870,7 @@ var ts; } ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -35545,13 +36887,13 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072; + var hasParameterPropertyAssignments = node.transformFlags & 524288; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); } function transformConstructorParameters(constructor) { @@ -35559,7 +36901,7 @@ var ts; ? ts.visitNodes(constructor.parameters, visitor, ts.isParameter) : []; } - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; startLexicalEnvironment(); @@ -35572,7 +36914,7 @@ var ts; statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } @@ -35587,7 +36929,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -35621,24 +36963,24 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 145 + return member.kind === 146 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); } } - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -35646,7 +36988,7 @@ var ts; } return expressions; } - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); @@ -35694,12 +37036,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149: case 150: + case 151: return getAllDecoratorsOfAccessors(node, member); - case 147: + case 148: return getAllDecoratorsOfMethod(member); - case 145: + case 146: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -35777,7 +37119,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 145 + ? member.kind === 146 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -35865,43 +37207,43 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 - || kind === 149 + return kind === 148 || kind === 150 - || kind === 145; + || kind === 151 + || kind === 146; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 147; + return node.kind === 148; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 - || kind === 192 - || kind === 147 - || kind === 149 - || kind === 150; + return kind === 222 + || kind === 193 + || kind === 148 + || kind === 150 + || kind === 151; } function serializeTypeOfNode(node) { switch (node.kind) { - case 145: - case 142: - case 149: - return serializeTypeNode(node.type); + case 146: + case 143: case 150: + return serializeTypeNode(node.type); + case 151: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221: - case 192: - case 147: + case 222: + case 193: + case 148: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 160) { + if (node && node.kind === 161) { return node.elementType; } - else if (node && node.kind === 155) { + else if (node && node.kind === 156) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -35947,52 +37289,52 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103: + case 104: return ts.createVoidZero(); - case 164: + case 165: return serializeTypeNode(node.type); - case 156: case 157: + case 158: return ts.createIdentifier("Function"); - case 160: case 161: + case 162: return ts.createIdentifier("Array"); - case 154: - case 120: + case 155: + case 121: return ts.createIdentifier("Boolean"); - case 132: + case 133: return ts.createIdentifier("String"); - case 166: + case 167: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 99: - case 84: + case 100: + case 85: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130: + case 131: return ts.createIdentifier("Number"); - case 133: + case 134: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155: + case 156: return serializeTypeReferenceNode(node); + case 164: case 163: - case 162: { 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 !== 69) { + if (serializedIndividual.kind !== 70) { serializedUnion = undefined; break; } @@ -36009,10 +37351,10 @@ var ts; return serializedUnion; } } - case 158: case 159: - case 117: - case 165: + case 160: + case 118: + case 166: break; default: ts.Debug.failBadSyntaxKind(node); @@ -36053,7 +37395,7 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69: + case 70: var name_27 = ts.getMutableClone(node); name_27.flags &= ~8; name_27.original = undefined; @@ -36062,13 +37404,13 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } return name_27; - case 139: + case 140: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69) { + if (node.left.kind === 70) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -36081,7 +37423,7 @@ var ts; return ts.createPropertyAccess(left, node.right); } function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53), ts.createIdentifier("Symbol"), ts.createToken(54), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54), ts.createIdentifier("Symbol"), ts.createToken(55), ts.createIdentifier("Object")); } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; @@ -36113,9 +37455,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 83) { + if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83, types, node); + return ts.createHeritageClause(84, types, node); } return undefined; } @@ -36126,6 +37468,12 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; @@ -36176,36 +37524,33 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -36227,42 +37572,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, node.body, true); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); - } - } function visitParameter(node) { if (ts.parameterIsThisKeyword(node)) { return undefined; @@ -36289,14 +37598,14 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); } } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } function visitParenthesizedExpression(node) { var innerExpression = ts.skipOuterExpressions(node.expression, ~2); @@ -36314,6 +37623,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } function shouldEmitEnumDeclaration(node) { return !ts.isConst(node) || compilerOptions.preserveConstEnums @@ -36345,7 +37660,7 @@ var ts; var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); @@ -36388,7 +37703,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -36420,7 +37735,7 @@ var ts; ts.createVariableDeclaration(getDeclarationName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 224) { + if (node.kind === 225) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -36453,7 +37768,7 @@ var ts; var localName = getLocalName(node); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); @@ -36471,7 +37786,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226) { + if (body.kind === 227) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -36494,17 +37809,67 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 226) { + if (body.kind !== 227) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225) { + if (moduleDeclaration.body.kind === 226) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + function visitImportDeclaration(node) { + if (!node.importClause) { + return node; + } + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + return importClause + ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) + : undefined; + } + function visitImportClause(node) { + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + function visitNamedImportBindings(node) { + if (node.kind === 233) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + function visitImportSpecifier(node) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + function visitExportAssignment(node) { + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + function visitExportDeclaration(node) { + if (!node.exportClause) { + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + return undefined; + } + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + return exportClause + ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) + : undefined; + } + function visitNamedExports(node) { + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + function visitExportSpecifier(node) { + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } function shouldEmitImportEqualsDeclaration(node) { return resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) @@ -36512,7 +37877,9 @@ var ts; } function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -36624,57 +37991,32 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(69); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4) === 0) { - enabledSubstitutions |= 4; - context.enableSubstitution(174); - context.enableSubstitution(172); - context.enableSubstitution(173); - context.enableEmitNotification(221); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(148); + context.enableSubstitution(70); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(69); + context.enableSubstitution(70); classAliases = ts.createMap(); } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); context.enableSubstitution(254); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 - || kind === 148 - || kind === 147 - || kind === 149 - || kind === 150; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 226; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224; + return ts.getOriginalNode(node).kind === 225; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - if (enabledSubstitutions & 4 && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -36683,7 +38025,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -36711,17 +38052,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 172: - return substitutePropertyAccessExpression(node); case 173: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 174: - if (enabledSubstitutions & 4) { - return substituteCallExpression(node); - } - break; + return substituteElementAccessExpression(node); } return node; } @@ -36751,8 +38087,8 @@ var ts; if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 225) || - (applicableSubstitutions & 8 && container.kind === 224); + var substitute = (applicableSubstitutions & 2 && container.kind === 226) || + (applicableSubstitutions & 8 && container.kind === 225); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -36760,37 +38096,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -36818,2040 +38127,2429 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6Module(context) { + var entities = createEntitiesMap(); + function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - return ts.visitEachChild(node, visitor, context); - } + currentSourceFile = node; + node = ts.visitEachChild(node, visitor, context); + currentSourceFile = undefined; return node; } function visitor(node) { - switch (node.kind) { - case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 231: - return visitImportClause(node); - case 233: - case 232: - return visitNamedBindings(node); - case 234: - return visitImportSpecifier(node); - case 235: - return visitExportAssignment(node); - case 236: - return visitExportDeclaration(node); - case 237: - return visitNamedExports(node); - case 238: - return visitExportSpecifier(node); - } - return node; - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + if (node.transformFlags & 4) { + return visitorWorker(node); } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; + else if (node.transformFlags & 8) { + return ts.visitEachChild(node, visitor, context); } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, true); - if (node.exportClause === newExportClause) { + else { return node; } - return newExportClause - ? ts.createExportDeclaration(undefined, undefined, newExportClause, node.moduleSpecifier) - : undefined; } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; + function visitorWorker(node) { + switch (node.kind) { + case 242: + return visitJsxElement(node, false); + case 243: + return visitJsxSelfClosingElement(node, false); + case 248: + return visitJsxExpression(node); + default: + ts.Debug.failBadSyntaxKind(node); + return undefined; } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { + function transformJsxChildToExpression(node) { + switch (node.kind) { + case 10: + return visitJsxText(node); + case 248: + return visitJsxExpression(node); + case 242: + return visitJsxElement(node, true); + case 243: + return visitJsxSelfClosingElement(node, true); + default: + ts.Debug.failBadSyntaxKind(node); return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration(undefined, undefined, newImportClause, node.moduleSpecifier); - } } - return node; } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; + function visitJsxElement(node, isChild) { + return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, node); } - function visitNamedBindings(node) { - if (node.kind === 232) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + function visitJsxSelfClosingElement(node, isChild) { + return visitJsxOpeningLikeElement(node, undefined, isChild, node); + } + function visitJsxOpeningLikeElement(node, children, isChild, location) { + var tagName = getTagName(node); + var objectProperties; + var attrs = node.attributes; + if (attrs.length === 0) { + objectProperties = ts.createNull(); } else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + segments.unshift(ts.createObjectLiteral()); } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - } - ts.transformES6Module = transformES6Module; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableEmitNotification(256); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; + objectProperties = ts.singleOrUndefined(segments) + || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; + var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + if (isChild) { + ts.startOnNewLine(element); } - return node; + return element; } - function transformSystemModuleWorker(node) { - ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], ~1 & ts.getEmitFlags(node)); - var _a; + function transformJsxSpreadAttributeToExpression(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); } - function addSystemModuleBody(statements, node, dependencyGroups) { - startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitSourceElement); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - ts.addRange(statements, endLexicalEnvironment()); - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); + function transformJsxAttributeToObjectLiteralElement(node) { + var name = getAttributeName(node); + var expression = transformJsxAttributeInitializer(node.initializer); + return ts.createPropertyAssignment(name, expression); } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; + function transformJsxAttributeInitializer(node) { + if (node === undefined) { + return ts.createLiteral(true); } - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 236 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; + else if (node.kind === 9) { + var decoded = tryDecodeEntities(node.text); + return decoded ? ts.createLiteral(decoded, node) : node; + } + else if (node.kind === 248) { + return visitJsxExpression(node); + } + else { + ts.Debug.failBadSyntaxKind(node); + } + } + function visitJsxText(node) { + var text = ts.getTextOfNode(node, true); + var parts; + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + for (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); + if (!parts) { + parts = []; + } + parts.push(ts.createLiteral(decodeEntities(part))); } + firstNonWhitespace = -1; } - if (!hasExportDeclarationWithExportClause) { - return addExportStarFunction(statements, undefined); + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } } } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); + if (firstNonWhitespace !== -1) { + var part = text.substr(firstNonWhitespace); + if (!parts) { + parts = []; } + parts.push(ts.createLiteral(decodeEntities(part))); } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 236) { - continue; + if (parts) { + return ts.reduceLeft(parts, aggregateJsxTextParts); + } + return undefined; + } + function aggregateJsxTextParts(left, right) { + return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + } + function decodeEntities(text) { + return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { + if (decimal) { + return String.fromCharCode(parseInt(decimal, 10)); } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; + else if (hex) { + return String.fromCharCode(parseInt(hex, 16)); } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + else { + var ch = entities[word]; + return ch ? String.fromCharCode(ch) : match; } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); + }); } - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 230: - if (!entry.importClause) { - break; - } - case 229: - ts.Debug.assert(importVariableName !== undefined); - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 236: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); - } - else { - statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); - } - return ts.createArrayLiteral(setters, undefined, true); + function tryDecodeEntities(text) { + var decoded = decodeEntities(text); + return decoded === text ? undefined : decoded; } - function visitSourceElement(node) { - switch (node.kind) { - case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 236: - return visitExportDeclaration(node); - case 235: - return visitExportAssignment(node); - default: - return visitNestedNode(node); + function getTagName(node) { + if (node.kind === 242) { + return getTagName(node.openingElement); } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; + else { + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); + } + else { + return ts.createExpressionFromEntityName(name_31); + } } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 200: - return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); - case 221: - return visitClassDeclaration(node); - case 206: - return visitForStatement(node); - case 207: - return visitForInStatement(node); - case 208: - return visitForOfStatement(node); - case 204: - return visitDoStatement(node); - case 205: - return visitWhileStatement(node); - case 214: - return visitLabeledStatement(node); - case 212: - return visitWithStatement(node); - case 213: - return visitSwitchStatement(node); - case 227: - return visitCaseBlock(node); - case 249: - return visitCaseClause(node); - case 250: - return visitDefaultClause(node); - case 216: - return visitTryStatement(node); - case 252: - return visitCatchClause(node); - case 199: - return visitBlock(node); - case 202: - return visitExpressionStatement(node); - default: - return node; + function getAttributeName(node) { + var name = node.name; + if (/^[A-Za-z_]\w*$/.test(name.text)) { + return name; + } + else { + return ts.createLiteral(name.text); } } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + function visitJsxExpression(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); + } + } + ts.transformJsx = transformJsx; + function createEntitiesMap() { + return ts.createMap({ + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }); + } +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFileExternalHelpersModuleName; + var enabledSubstitutions; + var applicableSubstitutions; + var currentSuperContainer; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; } - return undefined; + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; + return ts.visitEachChild(node, visitor, context); } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + function visitor(node) { + if (node.transformFlags & 16) { + return visitorWorker(node); } - return undefined; + else if (node.transformFlags & 32) { + return ts.visitEachChild(node, visitor, context); + } + return node; } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; + function visitorWorker(node) { + switch (node.kind) { + case 119: + return undefined; + case 185: + return visitAwaitExpression(node); + case 148: + return visitMethodDeclaration(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; } - return undefined; } - function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + } + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; } - return undefined; + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; } - return undefined; + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; } - function visitVariableStatement(node) { - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || - enclosingBlockScopedContainer.kind === 256; - if (!shouldHoist) { + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { return node; } - var isExported = ts.hasModifier(node, 1); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); + var func = ts.createFunctionExpression(undefined, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; } - return undefined; + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + ts.setOriginalNode(func, node); + return func; } - function transformVariable(node, isExported) { - hoistBindingElement(node, isExported); - if (!node.initializer) { - return; + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, node.body, true); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4); + } + } + return block; } - var name = node.name; - if (ts.isIdentifier(name)) { - return ts.createAssignment(name, node.initializer); + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); } else { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } } } - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1)) { - var name_31 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_31, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_31); + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; } - ts.setOriginalNode(newNode, node); - node = newNode; } - hoistFunctionDeclaration(node); return undefined; } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_32 = getDeclarationName(originalNode); - if (originalNode.kind === 224) { - hoistVariableDeclaration(name_32); + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(175); + context.enableSubstitution(173); + context.enableSubstitution(174); + context.enableEmitNotification(222); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(149); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173: + return substitutePropertyAccessExpression(node); + case 174: + return substituteElementAccessExpression(node); + case 175: + if (enabledSubstitutions & 1) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } - return [ - node, - createExportStatement(name_32, name_32) - ]; } return node; } - function visitClassDeclaration(node) { - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, node.heritageClauses, node.members, node)), node)); - if (ts.hasModifier(node, 1)) { - if (!ts.hasModifier(node, 512)) { - recordExportName(name); + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } - statements.push(createDeclarationExport(node)); } - return statements; + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 + || kind === 149 + || kind === 148 + || kind === 150 + || kind === 151; + } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64) { + return visitorWorker(node); + } + else if (node.transformFlags & 128) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 188: + return visitBinaryExpression(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function visitBinaryExpression(node) { + var left = ts.visitNode(node.left, visitor, ts.isExpression); + var right = ts.visitNode(node.right, visitor, ts.isExpression); + if (node.operatorToken.kind === 61) { + var target = void 0; + var value = void 0; + if (ts.isElementAccessExpression(left)) { + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); + value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + } + else if (ts.isPropertyAccessExpression(left)) { + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); + value = ts.createPropertyAccess(expressionTemp, left.name, left); + } + else { + target = left; + value = left; + } + return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + } + else if (node.operatorToken.kind === 39) { + return ts.createMathPow(left, right, node); + } + else { + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + } + ts.transformES2016 = transformES2016; +})(ts || (ts = {})); +var ts; +(function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentSourceFile; + var currentText; + var currentParent; + var currentNode; + var enclosingVariableStatement; + var enclosingBlockScopeContainer; + var enclosingBlockScopeContainerParent; + var enclosingFunction; + var enclosingNonArrowFunction; + var enclosingNonAsyncFunctionBody; + var convertedLoopState; + var enabledSubstitutions; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + currentText = node.text; + return ts.visitNode(node, visitor, ts.isSourceFile); } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3) === 0; + function visitor(node) { + return saveStateAndInvoke(node, dispatcher); } - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); + 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; + if (ts.nodeStartsNewLexicalEnvironment(node)) { + convertedLoopState = undefined; } + onBeforeVisitNode(node); + var visited = f(node); + convertedLoopState = savedConvertedLoopState; + enclosingFunction = savedEnclosingFunction; + enclosingNonArrowFunction = savedEnclosingNonArrowFunction; + enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; + enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; + enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; + enclosingVariableStatement = savedEnclosingVariableStatement; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return visited; } - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + function shouldCheckNode(node) { + return (node.transformFlags & 256) !== 0 || + node.kind === 215 || + (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; + function visitorWorker(node) { + if (shouldCheckNode(node)) { + return visitJavaScript(node); + } + else if (node.transformFlags & 512) { + return ts.visitEachChild(node, visitor, context); } else { - return ts.visitEachChild(node, visitNestedNode, context); + return node; } } - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; + function visitorForConvertedLoopWorker(node) { + var result; + if (shouldCheckNode(node)) { + result = visitJavaScript(node); } else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + result = visitNodesInConvertedLoop(node); } - return node; + return result; } - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + function visitNodesInConvertedLoop(node) { + switch (node.kind) { + case 212: + return visitReturnStatement(node); + case 201: + return visitVariableStatement(node); + case 214: + return visitSwitchStatement(node); + case 211: + case 210: + return visitBreakOrContinueStatement(node); + case 98: + return visitThisKeyword(node); + case 70: + return visitIdentifier(node); + default: + return ts.visitEachChild(node, visitor, context); } - return node; } - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + function visitJavaScript(node) { + switch (node.kind) { + case 83: + return node; + case 222: + return visitClassDeclaration(node); + case 193: + return visitClassExpression(node); + case 143: + return visitParameter(node); + case 221: + return visitFunctionDeclaration(node); + case 181: + return visitArrowFunction(node); + case 180: + return visitFunctionExpression(node); + case 219: + return visitVariableDeclaration(node); + case 70: + return visitIdentifier(node); + case 220: + return visitVariableDeclarationList(node); + case 215: + return visitLabeledStatement(node); + case 205: + return visitDoStatement(node); + case 206: + return visitWhileStatement(node); + case 207: + return visitForStatement(node); + case 208: + return visitForInStatement(node); + case 209: + return visitForOfStatement(node); + case 203: + return visitExpressionStatement(node); + case 172: + return visitObjectLiteralExpression(node); + case 254: + return visitShorthandPropertyAssignment(node); + case 171: + return visitArrayLiteralExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 179: + return visitParenthesizedExpression(node, true); + case 188: + return visitBinaryExpression(node, true); + case 12: + case 13: + case 14: + case 15: + return visitTemplateLiteral(node); + case 177: + return visitTaggedTemplateExpression(node); + case 190: + return visitTemplateExpression(node); + case 191: + return visitYieldExpression(node); + case 96: + return visitSuperKeyword(); + case 191: + return ts.visitEachChild(node, visitor, context); + case 148: + return visitMethodDeclaration(node); + case 256: + return visitSourceFileNode(node); + case 201: + return visitVariableStatement(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); } - return node; } - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + function onBeforeVisitNode(node) { + if (currentNode) { + if (ts.isBlockScope(currentNode, currentParent)) { + enclosingBlockScopeContainer = currentNode; + enclosingBlockScopeContainerParent = currentParent; + } + if (ts.isFunctionLike(currentNode)) { + enclosingFunction = currentNode; + if (currentNode.kind !== 181) { + enclosingNonArrowFunction = currentNode; + if (!(ts.getEmitFlags(currentNode) & 2097152)) { + enclosingNonAsyncFunctionBody = currentNode; + } + } + } + switch (currentNode.kind) { + case 201: + enclosingVariableStatement = currentNode; + break; + case 220: + case 219: + case 170: + case 168: + case 169: + break; + default: + enclosingVariableStatement = undefined; + } } - return node; + currentParent = currentNode; + currentNode = node; } function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return 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; } - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return 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()) + ])); } - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; + function visitThisKeyword(node) { + ts.Debug.assert(convertedLoopState !== undefined); + if (enclosingFunction && enclosingFunction.kind === 181) { + convertedLoopState.containsLexicalThis = true; + return node; } - return node; + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); + function visitIdentifier(node) { + if (!convertedLoopState) { + return node; + } + if (ts.isGeneratedIdentifier(node)) { + return node; + } + if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + return node; + } + return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); + function visitBreakOrContinueStatement(node) { + if (convertedLoopState) { + var jump = node.kind === 211 ? 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 === 211) { + convertedLoopState.nonLocalJumps |= 2; + labelMarker = "break"; + } + else { + convertedLoopState.nonLocalJumps |= 4; + labelMarker = "continue"; + } + } + else { + if (node.kind === 211) { + labelMarker = "break-" + node.label.text; + setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); + } + else { + labelMarker = "continue-" + node.label.text; + setLabeledJump(convertedLoopState, false, node.label.text, labelMarker); + } + } + var returnExpression = ts.createLiteral(labelMarker); + if (convertedLoopState.loopOutParameters.length) { + var outParams = convertedLoopState.loopOutParameters; + var expr = void 0; + for (var i = 0; i < outParams.length; i++) { + var copyExpr = copyOutParameter(outParams[i], 1); + if (i === 0) { + expr = copyExpr; + } + else { + expr = ts.createBinary(expr, 25, copyExpr); + } + } + returnExpression = ts.createBinary(expr, 25, returnExpression); + } + return ts.createReturn(returnExpression); + } + } + return ts.visitEachChild(node, visitor, context); } - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; + function visitClassDeclaration(node) { + var modifierFlags = ts.getModifierFlags(node); + var isExported = modifierFlags & 1; + var isDefault = modifierFlags & 512; + var modifiers = isExported && !isDefault + ? ts.filter(node.modifiers, isExportModifier) + : undefined; + var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(getDeclarationName(node, true), undefined, transformClassLikeDeclarationToExpression(node)) + ]), node); + ts.setOriginalNode(statement, node); + ts.startOnNewLine(statement); + if (isExported && isDefault) { + var statements = [statement]; + statements.push(ts.createExportAssignment(undefined, undefined, false, getDeclarationName(node, false))); + return statements; } - return node; + return statement; } - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); + function isExportModifier(node) { + return node.kind === 83; } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; + function visitClassExpression(node) { + return transformClassLikeDeclarationToExpression(node); + } + function transformClassLikeDeclarationToExpression(node) { + if (node.name) { + enableSubstitutionsForBlockScopedBindings(); } - else { - previousOnEmitNode(emitContext, node, emitCallback); + var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + if (ts.getEmitFlags(node) & 524288) { + ts.setEmitFlags(classFunction, 524288); } + var inner = ts.createPartiallyEmittedExpression(classFunction); + inner.end = node.end; + ts.setEmitFlags(inner, 49152); + var outer = ts.createPartiallyEmittedExpression(inner); + outer.end = ts.skipTrivia(currentText, node.pos); + ts.setEmitFlags(outer, 49152); + return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement + ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] + : [])); } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - return node; + function transformClassBody(node, extendsClauseElement) { + var statements = []; + startLexicalEnvironment(); + addExtendsHelperIfNeeded(statements, node, extendsClauseElement); + addConstructor(statements, node, extendsClauseElement); + addClassMembers(statements, node); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); + var localName = getLocalName(node); + var outer = ts.createPartiallyEmittedExpression(localName); + outer.end = closingBraceLocation.end; + ts.setEmitFlags(outer, 49152); + var statement = ts.createReturn(outer); + statement.pos = closingBraceLocation.pos; + ts.setEmitFlags(statement, 49152 | 12288); + statements.push(statement); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + ts.setEmitFlags(block, 49152); + return block; } - function substituteExpression(node) { - switch (node.kind) { - case 69: - return substituteExpressionIdentifier(node); - case 187: - return substituteBinaryExpression(node); - case 185: - case 186: - return substituteUnaryExpression(node); + function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { + if (extendsClauseElement) { + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), extendsClauseElement)); } - return node; } - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } + function addConstructor(statements, node, extendsClauseElement) { + var constructor = ts.getFirstConstructorWithBody(node); + var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256); } - return node; + statements.push(constructorFunction); } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); + function transformConstructorParameters(constructor, hasSynthesizedSuper) { + if (constructor && !hasSynthesizedSuper) { + return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); } - return node; + return []; } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128); - var left = node.left; - switch (left.kind) { - case 69: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 171: - case 170: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; + function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + statementOffset = 1; } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 69: - return isExportedBinding(node); - case 171: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 170: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; + else if (constructor) { + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); + if (constructor) { + addDefaultValueAssignmentsIfNeeded(statements, constructor); + addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + if (superCaptureStatus === 1 || superCaptureStatus === 2) { + statementOffset++; } - else { - return false; + if (constructor) { + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); + ts.addRange(statements, body); } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); + if (extendsClauseElement + && superCaptureStatus !== 2 + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); } - else { - return hasExportedReferenceInDestructuringElement(node); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + if (!constructor) { + ts.setEmitFlags(block, 49152); } + return block; } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 56 - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); + function isSufficientlyCoveredByReturnStatements(statement) { + if (statement.kind === 212) { + return true; } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); + else if (statement.kind === 204) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); + else if (statement.kind === 200) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); + return false; + } + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0; } - else { - return false; + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2; } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 69 - || kind === 171 - || kind === 170; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 186 || - (node.kind === 185 && (operator === 41 || operator === 42))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128); - var call = createExportExpression(operand, expr); - if (node.kind === 185) { - return call; - } - else { - return operator === 41 - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1; + } + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } } - return node; - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2; } - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(m)], undefined, ts.createBlock([ - ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) - ], undefined, true))); - return exportStarFunction; - } - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, undefined, [exportName, value]); - } - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + if (superCallExpression) { + return 1; + } + return 0; } - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { + function visitParameter(node) { + if (node.dotDotDotToken) { return undefined; } - if (name.originalKeywordKind && languageVersion === 0) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); + else if (ts.isBindingPattern(node.name)) { + return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), undefined, node), node); + } + else if (node.initializer) { + return ts.setOriginalNode(ts.createParameter(node.name, undefined, node), node); } else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + return node; } } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 262144) !== 0; + } + function addDefaultValueAssignmentsIfNeeded(statements, node) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + if (dotDotDotToken) { continue; } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); } } - return dependencyGroups; } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { + var temp = ts.getGeneratedNameForNode(parameter); + if (name.elements.length > 0) { + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; + else if (initializer) { + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); } - exportedFunctionDeclarations.push(createDeclarationExport(node)); } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) + ], parameter), 32 | 1024 | 12288), undefined, parameter); + statement.startsOnNewLine = true; + ts.setEmitFlags(statement, 12288 | 1024 | 8388608); + statements.push(statement); + } + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + } + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { return; } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } + var declarationName = ts.getMutableClone(parameter.name); + ts.setEmitFlags(declarationName, 1536); + var expressionName = ts.getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = ts.createLoopVariable(); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) + ]), parameter), 8388608)); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) + ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ + ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + ])); + ts.setEmitFlags(forStatement, 8388608); + ts.startOnNewLine(forStatement); + statements.push(forStatement); + } + function addCaptureThisForNodeIfNeeded(statements, node) { + if (node.transformFlags & 65536 && node.kind !== 181) { + captureThisForNode(statements, node, ts.createThis()); } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 | 8388608); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + function addClassMembers(statements, node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + switch (member.kind) { + case 199: + statements.push(transformSemicolonClassElementToStatement(member)); + break; + case 148: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + break; + case 150: + case 151: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + } + break; + case 149: + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } } } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, true); + function transformSemicolonClassElementToStatement(member) { + return ts.createEmptyStatement(member); } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, false); + function transformClassMethodDeclarationToStatement(receiver, member) { + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); + var func = transformFunctionLikeToExpression(member, member, undefined); + ts.setEmitFlags(func, 49152); + ts.setSourceMapRange(func, sourceMapRange); + var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); + ts.setOriginalNode(statement, member); + ts.setCommentRange(statement, commentRange); + ts.setEmitFlags(statement, 1536); + return statement; } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; + function transformAccessorsToStatement(receiver, accessors) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + ts.setEmitFlags(statement, 49152); + return statement; } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableSubstitution(254); - context.enableEmitNotification(256); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; + function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var target = ts.getMutableClone(receiver); + ts.setEmitFlags(target, 49152 | 1024); + ts.setSourceMapRange(target, firstAccessor.name); + var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); + ts.setEmitFlags(propertyName, 49152 | 512); + ts.setSourceMapRange(propertyName, firstAccessor.name); + var properties = []; + if (getAccessor) { + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384); + var getter = ts.createPropertyAssignment("get", getterFunction); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); + properties.push(getter); } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; + if (setAccessor) { + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384); + var setter = ts.createPropertyAssignment("set", setterFunction); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); + properties.push(setter); } - return node; - var _a; - } - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); + properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + target, + propertyName, + ts.createObjectLiteral(properties, undefined, true) + ]); + if (startsOnNewLine) { + call.startsOnNewLine = true; } - return updated; - } - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); + return call; } - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16); - return transformAsynchronousModule(node, define, undefined, false); + function visitArrowFunction(node) { + if (node.transformFlags & 32768) { + enableSubstitutionsForCapturedThis(); + } + var func = transformFunctionLikeToExpression(node, node, undefined); + ts.setEmitFlags(func, 256); + return func; } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); + function visitFunctionExpression(node) { + return transformFunctionLikeToExpression(node, node, node.name); } - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(body, 2); - } - return body; + function visitFunctionDeclaration(node) { + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node), node); } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, exportEquals); - ts.setEmitFlags(statement, 12288 | 49152); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); - ts.setEmitFlags(statement, 49152); - statements.push(statement); - } + function transformFunctionLikeToExpression(node, location, name) { + var savedContainingNonArrowFunction = enclosingNonArrowFunction; + if (node.kind !== 181) { + enclosingNonArrowFunction = node; } + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + enclosingNonArrowFunction = savedContainingNonArrowFunction; + return expression; } - function visitor(node) { - switch (node.kind) { - case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 236: - return visitExportDeclaration(node); - case 235: - return visitExportAssignment(node); - case 200: - return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); - case 221: - return visitClassDeclaration(node); - case 202: - return visitExpressionStatement(node); - default: - return node; + function transformFunctionBody(node) { + var multiLine = false; + var singleLine = false; + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + startLexicalEnvironment(); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); } - } - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; + addCaptureThisForNodeIfNeeded(statements, node); + addDefaultValueAssignmentsIfNeeded(statements, node); + addRestParameterIfNeeded(statements, node, false); + if (!multiLine && statements.length > 0) { + multiLine = true; } - var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - statements.push(ts.createStatement(createRequireCall(node), node)); + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + if (!multiLine && body.multiLine) { + multiLine = true; } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); + } + else { + ts.Debug.assert(node.kind === 181); + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; } else { - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); - } + multiLine = true; } - statements.push(ts.createVariableStatement(undefined, ts.createConstDeclarationList(variables), node)); } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = ts.createReturn(expression, body); + ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); + statements.push(returnStatement); + closeBraceLocation = body; } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ]))); + var lexicalEnvironment = endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); + var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + ts.setEmitFlags(block, 32); + } + if (closeBraceLocation) { + ts.setTokenSourceMapRange(block, 17, closeBraceLocation); + } + ts.setOriginalNode(block, node.body); + return block; } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; + function visitExpressionStatement(node) { + switch (node.expression.kind) { + case 179: + return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); + case 188: + return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } - ts.setEmitFlags(node.name, 128); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), node)); + return ts.visitEachChild(node, visitor, context); + } + function visitParenthesizedExpression(node, needsDestructuringValue) { + if (needsDestructuringValue) { + switch (node.expression.kind) { + case 179: + return ts.createParen(visitParenthesizedExpression(node.expression, true), node); + case 188: + return ts.createParen(visitBinaryExpression(node.expression, true), node); + } + } + return ts.visitEachChild(node, visitor, context); + } + function visitBinaryExpression(node, needsDestructuringValue) { + ts.Debug.assert(ts.isDestructuringAssignment(node)); + return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + } + function visitVariableStatement(node) { + if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var assignments = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); + if (decl.initializer) { + var assignment = void 0; + if (ts.isBindingPattern(decl.name)) { + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, undefined, visitor); + } + else { + assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + } + (assignments || (assignments = [])).push(assignment); + } + } + if (assignments) { + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); + return undefined; } } - else { - if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), node)); - } + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclarationList(node) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); } - addExportImportAssignments(statements, node); - return statements; + 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; } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; + function shouldEmitExplicitInitializerForLetDeclaration(node) { + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072; + var isDeclaredInLoop = flags & 262144; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + || (isCapturedInFunction + && isDeclaredInLoop + && ts.isBlock(enclosingBlockScopeContainer) + && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + var emitExplicitInitializer = !emittedAsTopLevel + && enclosingBlockScopeContainer.kind !== 208 + && enclosingBlockScopeContainer.kind !== 209 + && (!resolver.isDeclarationWithCollidingName(node) + || (isDeclaredInLoop + && !isCapturedInFunction + && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + return emitExplicitInitializer; + } + function visitVariableDeclarationInLetDeclarationList(node) { + var name = node.name; + if (ts.isBindingPattern(name)) { + return visitVariableDeclaration(node); } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); - } - } - return ts.singleOrMany(statements); + if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { + var clone_5 = ts.getMutableClone(node); + clone_5.initializer = ts.createVoidZero(); + return clone_5; } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), node); + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + var recordTempVariablesInLine = !enclosingVariableStatement + || !ts.hasModifier(enclosingVariableStatement, 1); + return ts.flattenVariableDestructuring(node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); } + return ts.visitEachChild(node, visitor, context); } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; + function visitLabeledStatement(node) { + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); } + convertedLoopState.labels[node.label.text] = node.label.text; } - return undefined; + var result; + if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { + result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + } + else { + result = ts.visitEachChild(node, visitor, context); + } + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + return result; } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + function visitDoStatement(node) { + return convertIterationStatementBodyIfNecessary(node); } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + function visitWhileStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForInStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForOfStatement(node) { + return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + } + function convertForOfToFor(node, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + var counter = ts.createLoopVariable(); + var rhsReference = expression.kind === 70 + ? ts.createUniqueName(expression.text) + : ts.createTempVariable(undefined); + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarationList = ts.createVariableDeclarationList(declarations, initializer); + ts.setOriginalNode(declarationList, initializer); + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(ts.createVariableStatement(undefined, declarationList)); } else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) + ], ts.moveRangePos(initializer, -1)), ts.moveRangeEnd(initializer, -1))); } } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); - } else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); + var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); + if (ts.isDestructuringAssignment(assignment)) { + statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, false, hoistVariableDeclaration, visitor))); + } + else { + assignment.end = initializer.end; + statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); } } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); } } - return ts.reduceEachChild(node, collectExportMembers, names); + ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); + var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + ts.setEmitFlags(body, 1536 | 12288); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), + ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) + ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + ts.setEmitFlags(forStatement, 8192); + return forStatement; } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), specifier.name))); + function visitObjectLiteralExpression(node) { + var properties = node.properties; + var numProperties = properties.length; + var numInitialProperties = numProperties; + for (var i = 0; i < numProperties; i++) { + var property = properties[i]; + if (property.transformFlags & 16777216 + || property.name.kind === 141) { + 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), 524288)); + 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); } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512)) { - addExportDefault(statements, getDeclarationName(node), node); + function shouldConvertIterationStatementBody(node) { + return (resolver.getNodeCheckFlags(node) & 65536) !== 0; + } + function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); + visit(node.name); + function visit(node) { + if (node.kind === 70) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + visit(element.name); + } + } + } } } - function visitVariableStatement(node) { - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 || - originalKind === 224 || - originalKind === 221) { - if (!ts.hasModifier(node, 1)) { - return node; + function convertIterationStatementBodyIfNecessary(node, convert) { + if (!shouldConvertIterationStatementBody(node)) { + var saveAllowedNonLabeledJumps = void 0; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 | 4; } - return ts.setOriginalNode(ts.createVariableStatement(undefined, node.declarationList), node); - } - var resultStatements = []; - if (ts.hasModifier(node, 1)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); + var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; } + return result; } - else { - resultStatements.push(node); - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); + var functionName = ts.createUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 207: + case 208: + case 209: + var initializer = node.initializer; + if (initializer && initializer.kind === 220) { + loopInitializer = initializer; } + break; + } + var loopParameters = []; + var loopOutParameters = []; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) { + for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); } } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); + var outerConvertedLoopState = convertedLoopState; + convertedLoopState = { loopOutParameters: loopOutParameters }; + if (outerConvertedLoopState) { + if (outerConvertedLoopState.argumentsName) { + convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; + } + if (outerConvertedLoopState.thisName) { + convertedLoopState.thisName = outerConvertedLoopState.thisName; + } + if (outerConvertedLoopState.hoistedLocalVariables) { + convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; } } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var currentState = convertedLoopState; + convertedLoopState = outerConvertedLoopState; + if (loopOutParameters.length) { + var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; + copyOutParameters(loopOutParameters, 1, statements_3); + loopBody = ts.createBlock(statements_3, undefined, true); } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); + if (!ts.isBlock(loopBody)) { + loopBody = ts.createBlock([loopBody], undefined, true); } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); - addExportMemberAssignment(statements, node); + var isAsyncBlockContainingAwait = enclosingNonArrowFunction + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 + && (node.statement.transformFlags & 16777216) !== 0; + var loopBodyFlags = 0; + if (currentState.containsLexicalThis) { + loopBodyFlags |= 256; } - else { - statements.push(node); + if (isAsyncBlockContainingAwait) { + loopBodyFlags |= 2097152; } - if (node.name) { - addExportMemberAssignments(statements, node.name); + var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ])); + var statements = [convertedLoopVariable]; + var extraVariableDeclarations; + if (currentState.argumentsName) { + if (outerConvertedLoopState) { + outerConvertedLoopState.argumentsName = currentState.argumentsName; + } + else { + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, undefined, ts.createIdentifier("arguments"))); + } } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration(undefined, undefined, name, undefined, node.heritageClauses, node.members, node), node)); - addExportMemberAssignment(statements, node); + if (currentState.thisName) { + if (outerConvertedLoopState) { + outerConvertedLoopState.thisName = currentState.thisName; + } + else { + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, undefined, ts.createIdentifier("this"))); + } } - else { - statements.push(node); + if (currentState.hoistedLocalVariables) { + if (outerConvertedLoopState) { + outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; + } + else { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; + extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); + } + } } - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); + if (loopOutParameters.length) { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; + extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); + } } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 224 || origKind === 225) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); + if (extraVariableDeclarations) { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - else if (origKind === 221) { - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; - } + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var loop; + if (convert) { + loop = convert(node, convertedLoopBodyStatements); } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - if (ts.hasModifier(original, 1) && - original.kind === 224 && - ts.isFirstDeclarationOfKind(original, 224)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); + 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); } - addExportMemberAssignments(statements, original.name); + statements.push(currentParent.kind === 215 + ? ts.createLabel(currentParent.label, loop) + : loop); return statements; } - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - ts.setEmitFlags(transformedStatement, 49152); - statements.push(transformedStatement); + function copyOutParameter(outParam, copyDirection) { + var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; + return ts.createBinary(target, 57, source); } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + function copyOutParameters(outParams, copyDirection, statements) { + for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { + var outParam = outParams_1[_i]; + statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + } } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; + function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { + var outerConvertedLoopState = convertedLoopState; + var statements = []; + var isSimpleLoop = !(state.nonLocalJumps & ~4) && + !state.labeledNonLocalBreaks && + !state.labeledNonLocalContinues; + var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; + if (isSimpleLoop) { + statements.push(ts.createStatement(callResult)); + copyOutParameters(state.loopOutParameters, 0, statements); } else { - previousOnEmitNode(emitContext, node, emitCallback); + var loopResultName = ts.createUniqueName("state"); + var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)])); + statements.push(stateVariable); + copyOutParameters(state.loopOutParameters, 0, statements); + if (state.nonLocalJumps & 8) { + var returnStatement = void 0; + if (outerConvertedLoopState) { + outerConvertedLoopState.nonLocalJumps |= 8; + returnStatement = ts.createReturn(loopResultName); + } + else { + returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + } + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); + } + if (state.nonLocalJumps & 2) { + statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); + } + if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { + var caseClauses = []; + processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerConvertedLoopState, caseClauses); + processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerConvertedLoopState, caseClauses); + statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + } } + return statements; } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = ts.createMap(); + } + state.labeledNonLocalBreaks[labelText] = labelMarker; } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = ts.createMap(); } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); + state.labeledNonLocalContinues[labelText] = labelMarker; } - return node; } - function substituteExpression(node) { - switch (node.kind) { - case 69: - return substituteExpressionIdentifier(node); - case 187: - return substituteBinaryExpression(node); - case 186: - case 185: - return substituteUnaryExpression(node); + function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { + if (!table) { + return; } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; + for (var labelText in table) { + var labelMarker = table[labelText]; + var statements = []; + if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + var label = ts.createIdentifier(labelText); + statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + statements.push(ts.createReturn(loopResultName)); } + caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); } - return node; } - function substituteUnaryExpression(node) { - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128); - var transformedUnaryExpression = void 0; - if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); - ts.setEmitFlags(transformedUnaryExpression, 128); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); + function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { + var name = decl.name; + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + processLoopVariableDeclaration(element, loopParameters, loopOutParameters); } - return nestedExportAssignment; } } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); - if (container) { - if (container.kind === 256) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); - } + else { + loopParameters.push(ts.createParameter(name)); + if (resolver.getNodeCheckFlags(decl) & 2097152) { + var outParamName = ts.createUniqueName("out_" + name.text); + loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } - return undefined; } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - if (languageVersion >= 1) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), node); - } - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - if (name_35.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), node); + function addObjectLiteralMembers(expressions, node, receiver, start) { + var properties = node.properties; + var numProperties = properties.length; + for (var i = start; i < numProperties; i++) { + var property = properties[i]; + switch (property.kind) { + case 150: + case 151: + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property === accessors.firstAccessor) { + expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } - } + break; + case 253: + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 254: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 148: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; } } - return undefined; } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, name); + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; } - return ts.createCall(ts.createIdentifier("require"), undefined, args); + return expression; } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + if (startsOnNewLine) { + expression.startsOnNewLine = true; } - return statement; + return expression; } - function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 && languageVersion === 0 - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + function visitMethodDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); + return ts.createPropertyAssignment(node.name, functionExpression, node); } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 128); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + function visitShorthandPropertyAssignment(node) { + return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; + function visitYieldExpression(node) { + return ts.visitEachChild(node, visitor, context); } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); -var ts; -(function (ts) { - var entities = createEntitiesMap(); - function transformJsx(context) { - var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - node = ts.visitEachChild(node, visitor, context); - currentSourceFile = undefined; - return node; + function visitArrayLiteralExpression(node) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); } - function visitor(node) { - if (node.transformFlags & 4) { - return visitorWorker(node); + function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { + var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 96) { + ts.setEmitFlags(thisArg, 128); } - else if (node.transformFlags & 8) { - return ts.visitEachChild(node, visitor, context); + var resultingCall; + if (node.transformFlags & 1048576) { + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - return node; + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - } - function visitorWorker(node) { - switch (node.kind) { - case 241: - return visitJsxElement(node, false); - case 242: - return visitJsxSelfClosingElement(node, false); - case 248: - return visitJsxExpression(node); - default: - ts.Debug.failBadSyntaxKind(node); - return undefined; + if (node.expression.kind === 96) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; } + return resultingCall; } - function transformJsxChildToExpression(node) { - switch (node.kind) { - case 244: - return visitJsxText(node); - case 248: - return visitJsxExpression(node); - case 241: - return visitJsxElement(node, true); - case 242: - return visitJsxSelfClosingElement(node, true); - default: - ts.Debug.failBadSyntaxKind(node); - return undefined; + function visitNewExpression(node) { + ts.Debug.assert((node.transformFlags & 1048576) !== 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, []); + } + function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { + var numElements = elements.length; + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); + })); + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 + ? ts.createArraySlice(segments[0]) + : segments[0]; } + return ts.createArrayConcat(segments.shift(), segments); } - function visitJsxElement(node, isChild) { - return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, node); + function partitionSpreadElement(node) { + return ts.isSpreadElementExpression(node) + ? visitSpanOfSpreadElements + : visitSpanOfNonSpreadElements; } - function visitJsxSelfClosingElement(node, isChild) { - return visitJsxOpeningLikeElement(node, undefined, isChild, node); + function visitSpanOfSpreadElements(chunk) { + return ts.map(chunk, visitExpressionOfSpreadElement); } - function visitJsxOpeningLikeElement(node, children, isChild, location) { - var tagName = getTagName(node); - var objectProperties; - var attrs = node.attributes; - if (attrs.length === 0) { - objectProperties = ts.createNull(); - } - else { - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - segments.unshift(ts.createObjectLiteral()); - } - objectProperties = ts.singleOrUndefined(segments) - || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); - } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); - if (isChild) { - ts.startOnNewLine(element); - } - return element; + function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); } - function transformJsxSpreadAttributeToExpression(node) { + function visitExpressionOfSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } - function transformJsxAttributeToObjectLiteralElement(node) { - var name = getAttributeName(node); - var expression = transformJsxAttributeInitializer(node.initializer); - return ts.createPropertyAssignment(name, expression); + function visitTemplateLiteral(node) { + return ts.createLiteral(node.text, node); } - function transformJsxAttributeInitializer(node) { - if (node === undefined) { - return ts.createLiteral(true); - } - else if (node.kind === 9) { - var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, node) : node; - } - else if (node.kind === 248) { - return visitJsxExpression(node); + function visitTaggedTemplateExpression(node) { + var tag = ts.visitNode(node.tag, visitor, ts.isExpression); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var templateArguments = [temp]; + var cookedStrings = []; + var rawStrings = []; + var template = node.template; + if (ts.isNoSubstitutionTemplateLiteral(template)) { + cookedStrings.push(ts.createLiteral(template.text)); + rawStrings.push(getRawLiteral(template)); } else { - ts.Debug.failBadSyntaxKind(node); + cookedStrings.push(ts.createLiteral(template.head.text)); + rawStrings.push(getRawLiteral(template.head)); + for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { + var templateSpan = _a[_i]; + cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); + rawStrings.push(getRawLiteral(templateSpan.literal)); + templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); + } } + return ts.createParen(ts.inlineExpressions([ + ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), + ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), + ts.createCall(tag, undefined, templateArguments) + ])); } - function visitJsxText(node) { - var text = ts.getTextOfNode(node, true); - var parts; - var firstNonWhitespace = 0; - var lastNonWhitespace = -1; - for (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } - } + function getRawLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 12 || node.kind === 15; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + return ts.createLiteral(text, node); + } + function visitTemplateExpression(node) { + var expressions = []; + addTemplateHead(expressions, node); + addTemplateSpans(expressions, node); + var expression = ts.reduceLeft(expressions, ts.createAdd); + if (ts.nodeIsSynthesized(expression)) { + ts.setTextRange(expression, node); } - if (firstNonWhitespace !== -1) { - var part = text.substr(firstNonWhitespace); - if (!parts) { - parts = []; - } - parts.push(ts.createLiteral(decodeEntities(part))); + return expression; + } + function shouldAddTemplateHead(node) { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function addTemplateHead(expressions, node) { + if (!shouldAddTemplateHead(node)) { + return; } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); + expressions.push(ts.createLiteral(node.head.text)); + } + function addTemplateSpans(expressions, node) { + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span_6 = _a[_i]; + expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); + if (span_6.literal.text.length !== 0) { + expressions.push(ts.createLiteral(span_6.literal.text)); + } } - return undefined; } - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function visitSuperKeyword() { + return enclosingNonAsyncFunctionBody + && ts.isClassElement(enclosingNonAsyncFunctionBody) + && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) + && currentParent.kind !== 175 + ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") + : ts.createIdentifier("_super"); } - function decodeEntities(text) { - return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { - if (decimal) { - return String.fromCharCode(parseInt(decimal, 10)); - } - else if (hex) { - return String.fromCharCode(parseInt(hex, 16)); - } - else { - var ch = entities[word]; - return ch ? String.fromCharCode(ch) : match; - } - }); + function visitSourceFileNode(node) { + var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + var statements = []; + startLexicalEnvironment(); + ts.addRange(statements, prologue); + addCaptureThisForNodeIfNeeded(statements, node); + ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); + ts.addRange(statements, endLexicalEnvironment()); + var clone = ts.getMutableClone(node); + clone.statements = ts.createNodeArray(statements, node.statements); + return clone; } - function tryDecodeEntities(text) { - var decoded = decodeEntities(text); - return decoded === text ? undefined : decoded; + function onEmitNode(emitContext, node, emitCallback) { + var savedEnclosingFunction = enclosingFunction; + if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { + enclosingFunction = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + enclosingFunction = savedEnclosingFunction; } - function getTagName(node) { - if (node.kind === 241) { - return getTagName(node.openingElement); + function enableSubstitutionsForBlockScopedBindings() { + if ((enabledSubstitutions & 2) === 0) { + enabledSubstitutions |= 2; + context.enableSubstitution(70); } - else { - 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_36); - } + } + function enableSubstitutionsForCapturedThis() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(98); + context.enableEmitNotification(149); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(181); + context.enableEmitNotification(180); + context.enableEmitNotification(221); } } - function getAttributeName(node) { - var name = node.name; - if (/^[A-Za-z_]\w*$/.test(name.text)) { - return name; + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); } - else { - return ts.createLiteral(name.text); + if (ts.isIdentifier(node)) { + return substituteIdentifier(node); } + return node; } - function visitJsxExpression(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); - } - } - ts.transformJsx = transformJsx; - function createEntitiesMap() { - return ts.createMap({ - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; + function substituteIdentifier(node) { + if (enabledSubstitutions & 2) { + var original = ts.getParseTreeNode(node, ts.isIdentifier); + if (original && isNameOfDeclarationWithCollidingName(original)) { + return ts.getGeneratedNameForNode(original); + } } - return ts.visitEachChild(node, visitor, context); + return node; } - function visitor(node) { - if (node.transformFlags & 16) { - return visitorWorker(node); + function isNameOfDeclarationWithCollidingName(node) { + var parent = node.parent; + switch (parent.kind) { + case 170: + case 222: + case 225: + case 219: + return parent.name === node + && resolver.isDeclarationWithCollidingName(parent); } - else if (node.transformFlags & 32) { - return ts.visitEachChild(node, visitor, context); + return false; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 98: + return substituteThisKeyword(node); } - else { - return node; + return node; + } + function substituteExpressionIdentifier(node) { + if (enabledSubstitutions & 2) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); + if (declaration) { + return ts.getGeneratedNameForNode(declaration.name); + } } + return node; } - function visitorWorker(node) { - switch (node.kind) { - case 187: - return visitBinaryExpression(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + function substituteThisKeyword(node) { + if (enabledSubstitutions & 1 + && enclosingFunction + && ts.getEmitFlags(enclosingFunction) & 256) { + return ts.createIdentifier("_this", node); } + return node; } - function visitBinaryExpression(node) { - var left = ts.visitNode(node.left, visitor, ts.isExpression); - var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60) { - var target = void 0; - var value = void 0; - if (ts.isElementAccessExpression(left)) { - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); + function getLocalName(node, allowComments, allowSourceMaps) { + return getDeclarationName(node, allowComments, allowSourceMaps, 262144); + } + function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && !ts.isGeneratedIdentifier(node.name)) { + var name_33 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= 1536; } - else if (ts.isPropertyAccessExpression(left)) { - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); + if (!allowComments) { + emitFlags |= 49152; } - else { - target = left; - value = left; + if (emitFlags) { + ts.setEmitFlags(name_33, emitFlags); } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + return name_33; } - else if (node.operatorToken.kind === 38) { - return ts.createMathPow(left, right, node); + return ts.getGeneratedNameForNode(node); + } + function getClassMemberPrefix(node, member) { + var expression = getLocalName(node); + return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); + } + function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { + if (!constructor || !hasExtendsClause) { + return false; } - else { - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + var parameter = ts.singleOrUndefined(constructor.parameters); + if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + return false; + } + var statement = ts.firstOrUndefined(constructor.body.statements); + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { + return false; } + var statementExpression = statement.expression; + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + return false; + } + var callTarget = statementExpression.expression; + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { + return false; + } + var callArgument = ts.singleOrUndefined(statementExpression.arguments); + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { + return false; + } + var expression = callArgument.expression; + return ts.isIdentifier(expression) && expression === parameter.name; } } - ts.transformES7 = transformES7; + ts.transformES2015 = transformES2015; })(ts || (ts = {})); var ts; (function (ts) { + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -38897,7 +40595,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024) { + if (node.transformFlags & 4096) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -38912,10 +40610,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512) { + else if (transformFlags & 2048) { return visitGenerator(node); } - else if (transformFlags & 1024) { + else if (transformFlags & 4096) { return ts.visitEachChild(node, visitor, context); } else { @@ -38924,13 +40622,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 213: - return visitSwitchStatement(node); case 214: + return visitSwitchStatement(node); + case 215: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -38938,30 +40636,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); - case 149: case 150: + case 151: return visitAccessorDeclaration(node); - case 200: + case 201: return visitVariableStatement(node); - case 206: - return visitForStatement(node); case 207: + return visitForStatement(node); + case 208: return visitForInStatement(node); - case 210: + case 211: return visitBreakStatement(node); - case 209: + case 210: return visitContinueStatement(node); - case 211: + case 212: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 | 8388608)) { + else if (node.transformFlags & (4096 | 33554432)) { return ts.visitEachChild(node, visitor, context); } else { @@ -38971,21 +40669,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187: - return visitBinaryExpression(node); case 188: + return visitBinaryExpression(node); + case 189: return visitConditionalExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 170: - return visitArrayLiteralExpression(node); case 171: + return visitArrayLiteralExpression(node); + case 172: return visitObjectLiteralExpression(node); - case 173: - return visitElementAccessExpression(node); case 174: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -38993,9 +40691,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39025,7 +40723,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -39098,7 +40796,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -39128,23 +40826,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 - && kind <= 68; + return kind >= 58 + && kind <= 69; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57: return 35; case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; - case 63: return 43; + case 63: return 41; case 64: return 44; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; + case 69: return 49; } } function visitRightAssociativeBinaryExpression(node) { @@ -39152,10 +40850,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172: + case 173: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173: + case 174: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -39164,7 +40862,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -39177,13 +40875,13 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24) { + else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - 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; + var clone_6 = ts.getMutableClone(node); + clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -39191,7 +40889,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -39207,7 +40905,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { visit(node.left); visit(node.right); } @@ -39250,7 +40948,7 @@ var ts; function visitArrayLiteralExpression(node) { return visitElements(node.elements, node.multiLine); } - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); var temp = declareLocal(); var hasAssignedTemp = false; @@ -39301,24 +40999,24 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - 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; + var clone_7 = ts.getMutableClone(node); + clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_7; } return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, false), node), node); + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node); } return ts.visitEachChild(node, visitor, context); } function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, false)), undefined, [], node), node); + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), undefined, [], node), node); } return ts.visitEachChild(node, visitor, context); } @@ -39347,35 +41045,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199: + case 200: return transformAndEmitBlock(node); - case 202: - return transformAndEmitExpressionStatement(node); case 203: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 204: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 205: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 206: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 207: + return transformAndEmitForStatement(node); + case 208: return transformAndEmitForInStatement(node); - case 209: - return transformAndEmitContinueStatement(node); case 210: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 211: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 212: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 213: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 214: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 215: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 216: + return transformAndEmitThrowStatement(node); + case 217: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -39760,7 +41458,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304) !== 0; + return node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -39790,12 +41488,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_7 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_7, node); - ts.setCommentRange(clone_7, node); - return clone_7; + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); + return clone_8; } } } @@ -39901,7 +41599,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69); + context.enableSubstitution(70); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -40100,7 +41798,7 @@ var ts; } return expression; } - return ts.createNode(193); + return ts.createNode(194); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -40188,7 +41886,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -40456,1456 +42154,1129 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var resolver = context.getEmitResolver(); + function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; - var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var convertedLoopState; - var enabledSubstitutions; + context.enableSubstitution(173); + context.enableSubstitution(253); return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - currentText = node.text; - return ts.visitNode(node, visitor, ts.isSourceFile); - } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); - } - 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; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 214 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); - } - function visitorWorker(node) { - if (shouldCheckNode(node)) { - return visitJavaScript(node); - } - else if (node.transformFlags & 128) { - return ts.visitEachChild(node, visitor, context); - } - else { - return node; - } + return node; } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); - } - else { - result = visitNodesInConvertedLoop(node); + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); } - return result; - } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 211: - return visitReturnStatement(node); - case 200: - return visitVariableStatement(node); - case 213: - return visitSwitchStatement(node); - case 210: - case 209: - return visitBreakOrContinueStatement(node); - case 97: - return visitThisKeyword(node); - case 69: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); } + return node; } - function visitJavaScript(node) { - switch (node.kind) { - case 82: - return node; - case 221: - return visitClassDeclaration(node); - case 192: - return visitClassExpression(node); - case 142: - return visitParameter(node); - case 220: - return visitFunctionDeclaration(node); - case 180: - return visitArrowFunction(node); - case 179: - return visitFunctionExpression(node); - case 218: - return visitVariableDeclaration(node); - case 69: - return visitIdentifier(node); - case 219: - return visitVariableDeclarationList(node); - case 214: - return visitLabeledStatement(node); - case 204: - return visitDoStatement(node); - case 205: - return visitWhileStatement(node); - case 206: - return visitForStatement(node); - case 207: - return visitForInStatement(node); - case 208: - return visitForOfStatement(node); - case 202: - return visitExpressionStatement(node); - case 171: - return visitObjectLiteralExpression(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 170: - return visitArrayLiteralExpression(node); - case 174: - return visitCallExpression(node); - case 175: - return visitNewExpression(node); - case 178: - return visitParenthesizedExpression(node, true); - case 187: - return visitBinaryExpression(node, true); - case 11: - case 12: - case 13: - case 14: - return visitTemplateLiteral(node); - case 176: - return visitTaggedTemplateExpression(node); - case 189: - return visitTemplateExpression(node); - case 190: - return visitYieldExpression(node); - case 95: - return visitSuperKeyword(node); - case 190: - return ts.visitEachChild(node, visitor, context); - case 147: - return visitMethodDeclaration(node); - case 256: - return visitSourceFileNode(node); - case 200: - return visitVariableStatement(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, node); } + return node; } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 180) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 2097152)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 200: - enclosingVariableStatement = currentNode; - break; - case 219: - case 218: - case 169: - case 167: - case 168: - break; - default: - enclosingVariableStatement = undefined; - } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); } - currentParent = currentNode; - currentNode = node; - } - 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; - } - 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()) - ])); + return node; } - function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180) { - convertedLoopState.containsLexicalThis = true; - return node; + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.createLiteral(name, name); } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + return undefined; } - function visitIdentifier(node) { - if (!convertedLoopState) { - return node; - } - if (ts.isGeneratedIdentifier(node)) { - return node; - } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70); + context.enableSubstitution(188); + context.enableSubstitution(186); + context.enableSubstitution(187); + context.enableSubstitution(254); + context.enableEmitNotification(256); + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var bindingNameExportSpecifiersMap; + var bindingNameExportSpecifiersForFileMap = ts.createMap(); + var hasExportStarsToExportValues; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { return node; } - return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); - } - function visitBreakOrContinueStatement(node) { - if (convertedLoopState) { - var jump = node.kind === 210 ? 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 === 210) { - convertedLoopState.nonLocalJumps |= 2; - labelMarker = "break"; - } - else { - convertedLoopState.nonLocalJumps |= 4; - labelMarker = "continue"; - } - } - else { - if (node.kind === 210) { - labelMarker = "break-" + node.label.text; - setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); - } - else { - labelMarker = "continue-" + node.label.text; - setLabeledJump(convertedLoopState, false, node.label.text, labelMarker); - } - } - var returnExpression = ts.createLiteral(labelMarker); - if (convertedLoopState.loopOutParameters.length) { - var outParams = convertedLoopState.loopOutParameters; - var expr = void 0; - for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1); - if (i === 0) { - expr = copyExpr; - } - else { - expr = ts.createBinary(expr, 24, copyExpr); - } - } - returnExpression = ts.createBinary(expr, 24, returnExpression); - } - return ts.createReturn(returnExpression); - } - } - return ts.visitEachChild(node, visitor, context); - } - function visitClassDeclaration(node) { - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1; - var isDefault = modifierFlags & 512; - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, true), undefined, transformClassLikeDeclarationToExpression(node)) - ]), node); - ts.setOriginalNode(statement, node); - ts.startOnNewLine(statement); - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment(undefined, undefined, false, getDeclarationName(node, false))); - return statements; - } - return statement; - } - function isExportModifier(node) { - return node.kind === 82; - } - function visitClassExpression(node) { - return transformClassLikeDeclarationToExpression(node); - } - function transformClassLikeDeclarationToExpression(node) { - if (node.name) { - enableSubstitutionsForBlockScopedBindings(); - } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (ts.getEmitFlags(node) & 524288) { - ts.setEmitFlags(classFunction, 524288); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule_1(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + return updated; } - var inner = ts.createPartiallyEmittedExpression(classFunction); - inner.end = node.end; - ts.setEmitFlags(inner, 49152); - var outer = ts.createPartiallyEmittedExpression(inner); - outer.end = ts.skipTrivia(currentText, node.pos); - ts.setEmitFlags(outer, 49152); - return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement - ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] - : [])); + return node; + var _a; } - function transformClassBody(node, extendsClauseElement) { - var statements = []; + function transformCommonJSModule(node) { startLexicalEnvironment(); - addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); - addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16); - var localName = getLocalName(node); - var outer = ts.createPartiallyEmittedExpression(localName); - outer.end = closingBraceLocation.end; - ts.setEmitFlags(outer, 49152); - var statement = ts.createReturn(outer); - statement.pos = closingBraceLocation.pos; - ts.setEmitFlags(statement, 49152 | 12288); - statements.push(statement); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); - ts.setEmitFlags(block, 49152); - return block; - } - function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { - if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), extendsClauseElement)); + addExportEqualsIfNeeded(statements, false); + var updated = updateSourceFile(node, statements); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); } + return updated; } - function addConstructor(statements, node, extendsClauseElement) { - var constructor = ts.getFirstConstructorWithBody(node); - var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); - if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 256); - } - statements.push(constructorFunction); + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, true); } - function transformConstructorParameters(constructor, hasSynthesizedSuper) { - if (constructor && !hasSynthesizedSuper) { - return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); - } - return []; + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16); + return transformAsynchronousModule(node, define, undefined, false); } - function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { - var statements = []; + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter("require"), + ts.createParameter("exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ]))) + ]); + } + function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); - var statementOffset = -1; - if (hasSynthesizedSuper) { - statementOffset = 1; - } - else if (constructor) { - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); - } - if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); - ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); - } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); - if (superCaptureStatus === 1 || superCaptureStatus === 2) { - statementOffset++; - } - if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); - ts.addRange(statements, body); - } - if (extendsClauseElement - && superCaptureStatus !== 2 - && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { - statements.push(ts.createReturn(ts.createIdentifier("_this"))); - } + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); - if (!constructor) { - ts.setEmitFlags(block, 49152); + addExportEqualsIfNeeded(statements, true); + var body = ts.createBlock(statements, undefined, true); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(body, 2); } - return block; + return body; } - function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 211) { - return true; - } - else if (statement.kind === 203) { - var ifStatement = statement; - if (ifStatement.elseStatement) { - return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && - isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(exportEquals.expression, exportEquals); + ts.setEmitFlags(statement, 12288 | 49152); + statements.push(statement); } - } - else if (statement.kind === 199) { - var lastStatement = ts.lastOrUndefined(statement.statements); - if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { - return true; + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); + ts.setEmitFlags(statement, 49152); + statements.push(statement); } } - return false; } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { - if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); - } - return 0; - } - if (!ctor) { - statements.push(ts.createReturn(createDefaultSuperCallOrThis())); - return 2; + function visitor(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 237: + return visitExportDeclaration(node); + case 236: + return visitExportAssignment(node); + case 201: + return visitVariableStatement(node); + case 221: + return visitFunctionDeclaration(node); + case 222: + return visitClassDeclaration(node); + case 203: + return visitExpressionStatement(node); + default: + return node; } - if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); - enableSubstitutionsForCapturedThis(); - return 1; + } + function visitImportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - var firstStatement; - var superCallExpression; - var ctorStatements = ctor.body.statements; - if (statementOffset < ctorStatements.length) { - firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + var statements = []; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + statements.push(ts.createStatement(createRequireCall(node), node)); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); + } + else { + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); + } + } + statements.push(ts.createVariableStatement(undefined, ts.createConstDeclarationList(variables), node)); } } - if (superCallExpression && statementOffset === ctorStatements.length - 1) { - statements.push(ts.createReturn(superCallExpression)); - return 2; - } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); - if (superCallExpression) { - return 1; + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) + ]))); } - return 0; - } - function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); + addExportImportAssignments(statements, node); + return ts.singleOrMany(statements); } - function visitParameter(node) { - if (node.dotDotDotToken) { + function visitImportEqualsDeclaration(node) { + if (!ts.contains(externalImports, node)) { return undefined; } - else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), undefined, node), node); - } - else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(node.name, undefined, node), node); + ts.setEmitFlags(node.name, 128); + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1)) { + statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), node)); + } + else { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) + ], undefined, languageVersion >= 2 ? 2 : 0), node)); + } } else { - return node; + if (ts.hasModifier(node, 1)) { + statements.push(ts.createStatement(createExportAssignment(node.name, node.name), node)); + } } + addExportImportAssignments(statements, node); + return statements; } - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536) !== 0; - } - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; + function visitExportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - 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; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) + ]), node)); } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); } + return ts.singleOrMany(statements); } - } - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); - } - } - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 32 | 1024 | 12288), undefined, parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 | 1024 | 8388608); - statements.push(statement); - } - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 && !inConstructorWithSynthesizedSuper; - } - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; + else { + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), node); } - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536); - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 8388608)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608); - ts.startOnNewLine(forStatement); - statements.push(forStatement); } - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 && node.kind !== 180) { - captureThisForNode(statements, node, ts.createThis()); + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; } + var statements = []; + addExportDefault(statements, node.expression, node); + return statements; } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 | 8388608); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + function addExportDefault(statements, expression, location) { + tryAddExportDefaultCompat(statements); + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); } - function addClassMembers(statements, node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - switch (member.kind) { - case 198: - statements.push(transformSemicolonClassElementToStatement(member)); - break; - case 147: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); - break; - case 149: - case 150: - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); - } - break; - case 148: - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; + function tryAddExportDefaultCompat(statements) { + var original = ts.getOriginalNode(currentSourceFile); + ts.Debug.assert(original.kind === 256); + if (!original.symbol.exports["___esModule"]) { + if (languageVersion === 0) { + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); } } } - function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); - } - function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = ts.getCommentRange(member); - var sourceMapRange = ts.getSourceMapRange(member); - var func = transformFunctionLikeToExpression(member, member, undefined); - ts.setEmitFlags(func, 49152); - ts.setSourceMapRange(func, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); - ts.setOriginalNode(statement, member); - ts.setCommentRange(statement, commentRange); - ts.setEmitFlags(statement, 1536); - return statement; - } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); - ts.setEmitFlags(statement, 49152); - return statement; - } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { - var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 49152 | 1024); - ts.setSourceMapRange(target, firstAccessor.name); - var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - ts.setEmitFlags(propertyName, 49152 | 512); - ts.setSourceMapRange(propertyName, firstAccessor.name); - var properties = []; - if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); - ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - var getter = ts.createPropertyAssignment("get", getterFunction); - ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); - properties.push(getter); - } - if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); - ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - var setter = ts.createPropertyAssignment("set", setterFunction); - ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); - properties.push(setter); + function addExportImportAssignments(statements, node) { + if (ts.isImportEqualsDeclaration(node)) { + addExportMemberAssignments(statements, node.name); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); - var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - target, - propertyName, - ts.createObjectLiteral(properties, undefined, true) - ]); - if (startsOnNewLine) { - call.startsOnNewLine = true; + else { + var names = ts.reduceEachChild(node, collectExportMembers, []); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); + } } - return call; } - function visitArrowFunction(node) { - if (node.transformFlags & 8192) { - enableSubstitutionsForCapturedThis(); + function collectExportMembers(names, node) { + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); + } } - var func = transformFunctionLikeToExpression(node, node, undefined); - ts.setEmitFlags(func, 256); - return func; - } - function visitFunctionExpression(node) { - return transformFunctionLikeToExpression(node, node, node.name); - } - function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node), node); + return ts.reduceEachChild(node, collectExportMembers, names); } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180) { - enclosingNonArrowFunction = node; + function addExportMemberAssignments(statements, name) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), specifier.name))); + } } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } - function transformFunctionBody(node) { - var multiLine = false; - var singleLine = false; - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + function addExportMemberAssignment(statements, node) { + if (ts.hasModifier(node, 512)) { + addExportDefault(statements, getDeclarationName(node), node); } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, false); - if (!multiLine && statements.length > 0) { - multiLine = true; + else { + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - if (!multiLine && body.multiLine) { - multiLine = true; + } + function visitVariableStatement(node) { + var originalKind = ts.getOriginalNode(node).kind; + if (originalKind === 226 || + originalKind === 225 || + originalKind === 222) { + if (!ts.hasModifier(node, 1)) { + return node; } + return ts.setOriginalNode(ts.createVariableStatement(undefined, node.declarationList), node); } - else { - ts.Debug.assert(node.kind === 180); - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } + var resultStatements = []; + if (ts.hasModifier(node, 1)) { + var variables = ts.getInitializedVariables(node.declarationList); + if (variables.length > 0) { + var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + resultStatements.push(inlineAssignments); } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); - ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); - statements.push(returnStatement); - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16, closeBraceLocation); } - ts.setOriginalNode(block, node.body); - return block; - } - function visitExpressionStatement(node) { - switch (node.expression.kind) { - case 178: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 187: - return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); + else { + resultStatements.push(node); } - return ts.visitEachChild(node, visitor, context); - } - function visitParenthesizedExpression(node, needsDestructuringValue) { - if (needsDestructuringValue) { - switch (node.expression.kind) { - case 178: - return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 187: - return ts.createParen(visitBinaryExpression(node.expression, true), node); - } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + addExportMemberAssignmentsForBindingName(resultStatements, decl.name); } - return ts.visitEachChild(node, visitor, context); - } - function visitBinaryExpression(node, needsDestructuringValue) { - ts.Debug.assert(ts.isDestructuringAssignment(node)); - return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + return resultStatements; } - function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { - var assignments = void 0; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); - if (decl.initializer) { - var assignment = void 0; - if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); - } - else { - assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); - } - (assignments || (assignments = [])).push(assignment); + function addExportMemberAssignmentsForBindingName(resultStatements, name) { + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + addExportMemberAssignmentsForBindingName(resultStatements, element.name); } } - if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24, acc); }), node); - } - else { - return undefined; - } - } - return ts.visitEachChild(node, visitor, context); - } - function visitVariableDeclarationList(node) { - 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 & 2097152 - && (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)); + else { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + var sourceFileId = ts.getOriginalNodeId(currentSourceFile); + if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { + bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + } + bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; + addExportMemberAssignments(resultStatements, name); + } } - return declarationList; - } - function shouldEmitExplicitInitializerForLetDeclaration(node) { - var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 131072; - var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) - || (isCapturedInFunction - && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); - var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 - && enclosingBlockScopeContainer.kind !== 208 - && (!resolver.isDeclarationWithCollidingName(node) - || (isDeclaredInLoop - && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); - return emitExplicitInitializer; } - function visitVariableDeclarationInLetDeclarationList(node) { + function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return visitVariableDeclaration(node); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } - if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { - var clone_8 = ts.getMutableClone(node); - clone_8.initializer = ts.createVoidZero(); - return clone_8; + else { + return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); } - return ts.visitEachChild(node, visitor, context); } - function visitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - var recordTempVariablesInLine = !enclosingVariableStatement - || !ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenVariableDestructuring(context, node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + function visitFunctionDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1)) { + var isAsync = ts.hasModifier(node, 256); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); + addExportMemberAssignment(statements, node); } - 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; + else { + statements.push(node); } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + if (node.name) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1)) { + statements.push(ts.setOriginalNode(ts.createClassDeclaration(undefined, undefined, name, undefined, node.heritageClauses, node.members, node), node)); + addExportMemberAssignment(statements, node); } else { - result = ts.visitEachChild(node, visitor, context); + statements.push(node); } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + if (node.name && !(node.decorators && node.decorators.length)) { + addExportMemberAssignments(statements, node.name); } - return result; - } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + return ts.singleOrMany(statements); } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitExpressionStatement(node) { + var original = ts.getOriginalNode(node); + var origKind = original.kind; + if (origKind === 225 || origKind === 226) { + return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); + } + else if (origKind === 222) { + var classDecl = original; + if (classDecl.name) { + var statements = [node]; + addExportMemberAssignments(statements, classDecl.name); + return statements; + } + } + return node; } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { + var statements = [node]; + if (ts.hasModifier(original, 1) && + original.kind === 225 && + ts.isFirstDeclarationOfKind(original, 225)) { + addVarForExportedEnumOrNamespaceDeclaration(statements, original); + } + addExportMemberAssignments(statements, original.name); + return statements; } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { + var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); + ts.setEmitFlags(transformedStatement, 49152); + statements.push(transformedStatement); } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); } - function convertForOfToFor(node, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(undefined); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); - ts.setOriginalNode(declarationList, initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement(undefined, declarationList)); - } - else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), ts.moveRangeEnd(initializer, -1))); - } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256) { + bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + bindingNameExportSpecifiersMap = undefined; } else { - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, false, hoistVariableDeclaration, visitor))); - } - else { - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); - } + previousOnEmitNode(emitContext, node, emitCallback); } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } - ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - ts.setEmitFlags(body, 1536 | 12288); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - ts.setEmitFlags(forStatement, 8192); - return forStatement; + return node; } - function visitObjectLiteralExpression(node) { - var properties = node.properties; - var numProperties = properties.length; - var numInitialProperties = numProperties; - for (var i = 0; i < numProperties; i++) { - var property = properties[i]; - if (property.transformFlags & 4194304 - || property.name.kind === 140) { - numInitialProperties = i; - break; + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, node); } + return ts.createPropertyAssignment(name, exportedOrImportedName, node); } - 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), 524288)); - if (node.multiLine) { - assignment.startsOnNewLine = true; + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 188: + return substituteBinaryExpression(node); + case 187: + case 186: + return substituteUnaryExpression(node); } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); + return node; } - function shouldConvertIterationStatementBody(node) { - return (resolver.getNodeCheckFlags(node) & 65536) !== 0; + function substituteExpressionIdentifier(node) { + return trySubstituteExportedName(node) + || trySubstituteImportedName(node) + || node; } - function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { - if (!state.hoistedLocalVariables) { - state.hoistedLocalVariables = []; - } - visit(node.name); - function visit(node) { - if (node.kind === 69) { - state.hoistedLocalVariables.push(node); - } - else { - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - visit(element.name); - } + function substituteBinaryExpression(node) { + var left = node.left; + if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { + ts.setEmitFlags(node, 128); + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, node); } + return nestedExportAssignment; } } + return node; } - function convertIterationStatementBodyIfNecessary(node, 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); - if (convertedLoopState) { - convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + function substituteUnaryExpression(node) { + var operator = node.operator; + var operand = node.operand; + if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { + ts.setEmitFlags(node, 128); + var transformedUnaryExpression = void 0; + if (node.kind === 187) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); + ts.setEmitFlags(transformedUnaryExpression, 128); + } + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, transformedUnaryExpression || node); + } + return nestedExportAssignment; } - return result; } - var functionName = ts.createUniqueName("_loop"); - var loopInitializer; - switch (node.kind) { - case 206: - case 207: - case 208: - var initializer = node.initializer; - if (initializer && initializer.kind === 219) { - loopInitializer = initializer; + return node; + } + function trySubstituteExportedName(node) { + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 262144) === 0) { + var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); + if (container) { + if (container.kind === 256) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); } - break; - } - var loopParameters = []; - var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) { - for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); } } - var outerConvertedLoopState = convertedLoopState; - convertedLoopState = { loopOutParameters: loopOutParameters }; - if (outerConvertedLoopState) { - if (outerConvertedLoopState.argumentsName) { - convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; - } - if (outerConvertedLoopState.thisName) { - convertedLoopState.thisName = outerConvertedLoopState.thisName; - } - if (outerConvertedLoopState.hoistedLocalVariables) { - convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; + return undefined; + } + function trySubstituteImportedName(node) { + if ((ts.getEmitFlags(node) & 262144) === 0) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (ts.isImportClause(declaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(declaration)) { + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), node); + } } } - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); - var currentState = convertedLoopState; - convertedLoopState = outerConvertedLoopState; - if (loopOutParameters.length) { - var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; - copyOutParameters(loopOutParameters, 1, statements_3); - loopBody = ts.createBlock(statements_3, undefined, true); - } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], undefined, true); - } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 4194304) !== 0; - var loopBodyFlags = 0; - if (currentState.containsLexicalThis) { - loopBodyFlags |= 256; - } - if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 2097152; + return undefined; + } + function getModuleMemberName(name) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), name, name); + } + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (ts.isDefined(moduleName)) { + args.push(moduleName); } - var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ])); - var statements = [convertedLoopVariable]; - var extraVariableDeclarations; - if (currentState.argumentsName) { - if (outerConvertedLoopState) { - outerConvertedLoopState.argumentsName = currentState.argumentsName; - } - else { - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, undefined, ts.createIdentifier("arguments"))); - } + return ts.createCall(ts.createIdentifier("require"), undefined, args); + } + function createExportStatement(name, value, location) { + var statement = ts.createStatement(createExportAssignment(name, value)); + statement.startsOnNewLine = true; + if (location) { + ts.setSourceMapRange(statement, location); } - if (currentState.thisName) { - if (outerConvertedLoopState) { - outerConvertedLoopState.thisName = currentState.thisName; + return statement; + } + function createExportAssignment(name, value) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(amdDependency.name)); } else { - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, undefined, ts.createIdentifier("this"))); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - if (currentState.hoistedLocalVariables) { - if (outerConvertedLoopState) { - outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; + for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { + var importNode = externalImports_1[_b]; + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 128); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(importAliasName)); } else { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { - var identifier = _c[_b]; - extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); - } - } - } - if (loopOutParameters.length) { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { - var outParam = loopOutParameters_1[_d]; - extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); + unaliasedModuleNames.push(externalModuleName); } } - if (extraVariableDeclarations) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); - } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); - var loop; - if (convert) { - loop = convert(node, convertedLoopBodyStatements); + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function updateSourceFile(node, statements) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + return updated; + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70); + context.enableSubstitution(188); + context.enableSubstitution(186); + context.enableSubstitution(187); + context.enableEmitNotification(256); + var exportFunctionForFileMap = []; + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStarsToExportValues; + var exportFunctionForFile; + var contextObjectForFile; + var exportedLocalNames; + var exportedFunctionDeclarations; + var enclosingBlockScopedContainer; + var currentParent; + var currentNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; } - 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); + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + currentNode = node; + var updated = transformSystemModuleWorker(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + exportFunctionForFile = undefined; + contextObjectForFile = undefined; + exportedLocalNames = undefined; + exportedFunctionDeclarations = undefined; + return updated; } - statements.push(currentParent.kind === 214 - ? ts.createLabel(currentParent.label, loop) - : loop); - return statements; + return node; } - function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56, source); + function transformSystemModuleWorker(node) { + ts.Debug.assert(!exportFunctionForFile); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + exportFunctionForFile = ts.createUniqueName("exports"); + contextObjectForFile = ts.createUniqueName("context"); + exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; + var dependencyGroups = collectDependencyGroups(externalImports); + var statements = []; + addSystemModuleBody(statements, node, dependencyGroups); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); + var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(exportFunctionForFile), + ts.createParameter(contextObjectForFile) + ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName + ? [moduleName, dependencies, body] + : [dependencies, body])) + ], ~1 & ts.getEmitFlags(node)); + var _a; } - function copyOutParameters(outParams, copyDirection, statements) { - for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { - var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); - } + function addSystemModuleBody(statements, node, dependencyGroups) { + startLexicalEnvironment(); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitSourceElement); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) + ]))); + var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); + ts.addRange(statements, endLexicalEnvironment()); + ts.addRange(statements, exportedFunctionDeclarations); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ]), true))); } - function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { - var outerConvertedLoopState = convertedLoopState; - var statements = []; - var isSimpleLoop = !(state.nonLocalJumps & ~4) && - !state.labeledNonLocalBreaks && - !state.labeledNonLocalContinues; - var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37), call) : call; - if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); - copyOutParameters(state.loopOutParameters, 0, statements); + function addExportStarIfNeeded(statements) { + if (!hasExportStarsToExportValues) { + return; } - else { - var loopResultName = ts.createUniqueName("state"); - var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)])); - statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 0, statements); - if (state.nonLocalJumps & 8) { - var returnStatement = void 0; - if (outerConvertedLoopState) { - outerConvertedLoopState.nonLocalJumps |= 8; - returnStatement = ts.createReturn(loopResultName); - } - else { - returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { + var externalImport = externalImports_2[_i]; + if (externalImport.kind === 237 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32, ts.createLiteral("object")), returnStatement)); } - if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32, ts.createLiteral("break")), ts.createBreak())); - } - if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { - var caseClauses = []; - processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerConvertedLoopState, caseClauses); - processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerConvertedLoopState, caseClauses); - statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + if (!hasExportDeclarationWithExportClause) { + return addExportStarFunction(statements, undefined); } } - return statements; - } - function setLabeledJump(state, isBreak, labelText, labelMarker) { - if (isBreak) { - if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = ts.createMap(); + var exportedNames = []; + if (exportedLocalNames) { + for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { + var exportedLocalName = exportedLocalNames_1[_a]; + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); } - state.labeledNonLocalBreaks[labelText] = labelMarker; } - else { - if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = ts.createMap(); + for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { + var externalImport = externalImports_3[_b]; + if (externalImport.kind !== 237) { + continue; } - state.labeledNonLocalContinues[labelText] = labelMarker; - } - } - function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { - if (!table) { - return; - } - for (var labelText in table) { - var labelMarker = table[labelText]; - var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { - var label = ts.createIdentifier(labelText); - statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; } - else { - setLabeledJump(outerLoop, isBreak, labelText, labelMarker); - statements.push(ts.createReturn(loopResultName)); + for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { + var element = _d[_c]; + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); } - caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ]))); + return addExportStarFunction(statements, exportedNamesStorageRef); } - function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { - var name = decl.name; - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - processLoopVariableDeclaration(element, loopParameters, loopOutParameters); + function generateSetters(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 231: + if (!entry.importClause) { + break; + } + case 230: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 237: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + } + else { + statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); + } + break; } } + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); } - else { - loopParameters.push(ts.createParameter(name)); - if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); - loopOutParameters.push({ originalName: name, outParamName: outParamName }); - } - } + return ts.createArrayLiteral(setters, undefined, true); } - function addObjectLiteralMembers(expressions, node, receiver, start) { - var properties = node.properties; - var numProperties = properties.length; - for (var i = start; i < numProperties; i++) { - var property = properties[i]; - switch (property.kind) { - case 149: - case 150: - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); - } - break; - case 253: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 254: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 147: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } + function visitSourceElement(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 237: + return visitExportDeclaration(node); + case 236: + return visitExportAssignment(node); + default: + return visitNestedNode(node); } } - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function visitNestedNode(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var currentGrandparent = currentParent; + currentParent = currentNode; + currentNode = node; + if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { + enclosingBlockScopedContainer = currentParent; } - return expression; + var result = visitNestedNodeWorker(node); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return result; } - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function visitNestedNodeWorker(node) { + switch (node.kind) { + case 201: + return visitVariableStatement(node); + case 221: + return visitFunctionDeclaration(node); + case 222: + return visitClassDeclaration(node); + case 207: + return visitForStatement(node); + case 208: + return visitForInStatement(node); + case 209: + return visitForOfStatement(node); + case 205: + return visitDoStatement(node); + case 206: + return visitWhileStatement(node); + case 215: + return visitLabeledStatement(node); + case 213: + return visitWithStatement(node); + case 214: + return visitSwitchStatement(node); + case 228: + return visitCaseBlock(node); + case 249: + return visitCaseClause(node); + case 250: + return visitDefaultClause(node); + case 217: + return visitTryStatement(node); + case 252: + return visitCatchClause(node); + case 200: + return visitBlock(node); + case 203: + return visitExpressionStatement(node); + default: + return node; } - return expression; } - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function visitImportDeclaration(node) { + if (node.importClause && ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); } - return expression; - } - function visitMethodDeclaration(node) { - ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); - ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); + return undefined; } - function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + function visitImportEqualsDeclaration(node) { + if (ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + return undefined; } - function visitYieldExpression(node) { - return ts.visitEachChild(node, visitor, context); + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + var statements = []; + ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); + return statements; + } + return undefined; } - function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + function visitExportSpecifier(specifier) { + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); } - function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + return createExportStatement(ts.createLiteral("default"), node.expression); } - function visitImmediateSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); + function visitVariableStatement(node) { + var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || + enclosingBlockScopedContainer.kind === 256; + if (!shouldHoist) { + return node; + } + var isExported = ts.hasModifier(node, 1); + var expressions = []; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, isExported); + if (visited) { + expressions.push(visited); + } + } + if (expressions.length) { + return ts.createStatement(ts.inlineExpressions(expressions), node); + } + return undefined; } - function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95) { - ts.setEmitFlags(thisArg, 128); + function transformVariable(node, isExported) { + hoistBindingElement(node, isExported); + if (!node.initializer) { + return; } - var resultingCall; - if (node.transformFlags & 262144) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + var name = node.name; + if (ts.isIdentifier(name)) { + return ts.createAssignment(name, node.initializer); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); - } - if (node.expression.kind === 95) { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128); - var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis - ? ts.createAssignment(ts.createIdentifier("_this"), initializer) - : initializer; + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } - return resultingCall; } - function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 262144) !== 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, []); + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1)) { + var name_38 = node.name || ts.getGeneratedNameForNode(node); + var isAsync = ts.hasModifier(node, 256); + var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); + recordExportedFunctionDeclaration(node); + if (!ts.hasModifier(node, 512)) { + recordExportName(name_38); + } + ts.setOriginalNode(newNode, node); + node = newNode; + } + hoistFunctionDeclaration(node); + return undefined; } - function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { - var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { - return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); - })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 - ? ts.createArraySlice(segments[0]) - : segments[0]; + function visitExpressionStatement(node) { + var originalNode = ts.getOriginalNode(node); + if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { + var name_39 = getDeclarationName(originalNode); + if (originalNode.kind === 225) { + hoistVariableDeclaration(name_39); + } + return [ + node, + createExportStatement(name_39, name_39) + ]; } - return ts.createArrayConcat(segments.shift(), segments); + return node; } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; + function visitClassDeclaration(node) { + var name = getDeclarationName(node); + hoistVariableDeclaration(name); + var statements = []; + statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, node.heritageClauses, node.members, node)), node)); + if (ts.hasModifier(node, 1)) { + if (!ts.hasModifier(node, 512)) { + recordExportName(name); + } + statements.push(createDeclarationExport(node)); + } + return statements; } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.map(chunk, visitExpressionOfSpreadElement); + function shouldHoistLoopInitializer(node) { + return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3) === 0; } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + function visitForStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var expressions = []; + for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, false); + if (visited) { + expressions.push(visited); + } + } + ; + return ts.createFor(expressions.length + ? ts.inlineExpressions(expressions) + : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } } - function visitExpressionOfSpreadElement(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); + function transformForBinding(node) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + hoistBindingElement(firstDeclaration, false); + var name = firstDeclaration.name; + return ts.isIdentifier(name) + ? name + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } - function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); + function visitForInStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } } - function visitTaggedTemplateExpression(node) { - var tag = ts.visitNode(node.tag, visitor, ts.isExpression); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var templateArguments = [temp]; - var cookedStrings = []; - var rawStrings = []; - var template = node.template; - if (ts.isNoSubstitutionTemplateLiteral(template)) { - cookedStrings.push(ts.createLiteral(template.text)); - rawStrings.push(getRawLiteral(template)); + function visitForOfStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + return updated; } else { - cookedStrings.push(ts.createLiteral(template.head.text)); - rawStrings.push(getRawLiteral(template.head)); - for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { - var templateSpan = _a[_i]; - cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); - rawStrings.push(getRawLiteral(templateSpan.literal)); - templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); - } + return ts.visitEachChild(node, visitNestedNode, context); } - return ts.createParen(ts.inlineExpressions([ - ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), - ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), - ts.createCall(tag, undefined, templateArguments) - ])); } - function getRawLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, node); + function visitDoStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; } - function visitTemplateExpression(node) { - var expressions = []; - addTemplateHead(expressions, node); - addTemplateSpans(expressions, node); - var expression = ts.reduceLeft(expressions, ts.createAdd); - if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + function visitWhileStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; } - return expression; + return node; } - function shouldAddTemplateHead(node) { - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + function visitLabeledStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; } - function addTemplateHead(expressions, node) { - if (!shouldAddTemplateHead(node)) { - return; + function visitWithStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + function visitSwitchStatement(node) { + var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); + if (caseBlock !== node.caseBlock) { + var updated = ts.getMutableClone(node); + updated.caseBlock = caseBlock; + return updated; + } + return node; + } + function visitCaseBlock(node) { + var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); + if (clauses !== node.clauses) { + var updated = ts.getMutableClone(node); + updated.clauses = clauses; + return updated; } - expressions.push(ts.createLiteral(node.head.text)); + return node; } - function addTemplateSpans(expressions, node) { - for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { - var span_6 = _a[_i]; - expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); - if (span_6.literal.text.length !== 0) { - expressions.push(ts.createLiteral(span_6.literal.text)); - } + function visitCaseClause(node) { + var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); + if (statements !== node.statements) { + var updated = ts.getMutableClone(node); + updated.statements = statements; + return updated; } + return node; } - function visitSuperKeyword(node) { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 174 - ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") - : ts.createIdentifier("_super"); + function visitDefaultClause(node) { + return ts.visitEachChild(node, visitNestedNode, context); } - function visitSourceFileNode(node) { - var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; - var statements = []; - startLexicalEnvironment(); - ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); - ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); - ts.addRange(statements, endLexicalEnvironment()); - var clone = ts.getMutableClone(node); - clone.statements = ts.createNodeArray(statements, node.statements); - return clone; + function visitTryStatement(node) { + return ts.visitEachChild(node, visitNestedNode, context); } - function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + function visitCatchClause(node) { + var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); + if (block !== node.block) { + var updated = ts.getMutableClone(node); + updated.block = block; + return updated; } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + return node; } - function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2) === 0) { - enabledSubstitutions |= 2; - context.enableSubstitution(69); - } + function visitBlock(node) { + return ts.visitEachChild(node, visitNestedNode, context); } - function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1) === 0) { - enabledSubstitutions |= 1; - context.enableSubstitution(97); - context.enableEmitNotification(148); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(180); - context.enableEmitNotification(179); - context.enableEmitNotification(220); + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256) { + exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + exportFunctionForFile = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); } } function onSubstituteNode(emitContext, node) { @@ -41913,122 +43284,320 @@ var ts; if (emitContext === 1) { return substituteExpression(node); } - if (ts.isIdentifier(node)) { - return substituteIdentifier(node); + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 188: + return substituteBinaryExpression(node); + case 186: + case 187: + return substituteUnaryExpression(node); } return node; } - function substituteIdentifier(node) { - if (enabledSubstitutions & 2) { - var original = ts.getParseTreeNode(node, ts.isIdentifier); - if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + function substituteExpressionIdentifier(node) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + var importBinding = createImportBinding(importDeclaration); + if (importBinding) { + return importBinding; } } return node; } - function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 169: - case 221: - case 224: - case 218: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind)) { + return substituteAssignmentExpression(node); } - return false; + return node; } - function substituteExpression(node) { - switch (node.kind) { - case 69: - return substituteExpressionIdentifier(node); - case 97: - return substituteThisKeyword(node); + function substituteAssignmentExpression(node) { + ts.setEmitFlags(node, 128); + var left = node.left; + switch (left.kind) { + case 70: + var exportDeclaration = resolver.getReferencedExportContainer(left); + if (exportDeclaration) { + return createExportExpression(left, node); + } + break; + case 172: + case 171: + if (hasExportedReferenceInDestructuringPattern(left)) { + return substituteDestructuring(node); + } + break; } return node; } - function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2) { - var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + function isExportedBinding(name) { + var container = resolver.getReferencedExportContainer(name); + return container && container.kind === 256; + } + function hasExportedReferenceInDestructuringPattern(node) { + switch (node.kind) { + case 70: + return isExportedBinding(node); + case 172: + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (hasExportedReferenceInObjectDestructuringElement(property)) { + return true; + } + } + break; + case 171: + for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { + var element = _c[_b]; + if (hasExportedReferenceInArrayDestructuringElement(element)) { + return true; + } + } + break; + } + return false; + } + function hasExportedReferenceInObjectDestructuringElement(node) { + if (ts.isShorthandPropertyAssignment(node)) { + return isExportedBinding(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringElement(node.initializer); + } + else { + return false; + } + } + function hasExportedReferenceInArrayDestructuringElement(node) { + if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else { + return hasExportedReferenceInDestructuringElement(node); + } + } + function hasExportedReferenceInDestructuringElement(node) { + if (ts.isBinaryExpression(node)) { + var left = node.left; + return node.operatorToken.kind === 57 + && isDestructuringPattern(left) + && hasExportedReferenceInDestructuringPattern(left); + } + else if (ts.isIdentifier(node)) { + return isExportedBinding(node); + } + else if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else if (isDestructuringPattern(node)) { + return hasExportedReferenceInDestructuringPattern(node); + } + else { + return false; + } + } + function isDestructuringPattern(node) { + var kind = node.kind; + return kind === 70 + || kind === 172 + || kind === 171; + } + function substituteDestructuring(node) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); + } + function substituteUnaryExpression(node) { + var operand = node.operand; + var operator = node.operator; + var substitute = ts.isIdentifier(operand) && + (node.kind === 187 || + (node.kind === 186 && (operator === 42 || operator === 43))); + if (substitute) { + var exportDeclaration = resolver.getReferencedExportContainer(operand); + if (exportDeclaration) { + var expr = ts.createPrefix(node.operator, operand, node); + ts.setEmitFlags(expr, 128); + var call = createExportExpression(operand, expr); + if (node.kind === 186) { + return call; + } + else { + return operator === 42 + ? ts.createSubtract(call, ts.createLiteral(1)) + : ts.createAdd(call, ts.createLiteral(1)); + } } } return node; } - function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 256) { - return ts.createIdentifier("_this", node); + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function addExportStarFunction(statements, localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); } - return node; + statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(m)], undefined, ts.createBlock([ + ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ])), + ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) + ], undefined, true))); + return exportStarFunction; } - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144); + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; + return ts.createCall(exportFunctionForFile, undefined, [exportName, value]); } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_39 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; + function createExportStatement(name, value) { + return ts.createStatement(createExportExpression(name, value)); + } + function createDeclarationExport(node) { + var declarationName = getDeclarationName(node); + var exportName = ts.hasModifier(node, 512) ? ts.createLiteral("default") : declarationName; + return createExportStatement(exportName, declarationName); + } + function createImportBinding(importDeclaration) { + var importAlias; + var name; + if (ts.isImportClause(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); + name = ts.createIdentifier("default"); + } + else if (ts.isImportSpecifier(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); + name = importDeclaration.propertyName || importDeclaration.name; + } + else { + return undefined; + } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + } + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + continue; } - if (emitFlags) { - ts.setEmitFlags(name_39, emitFlags); + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); } - return name_39; } - return ts.getGeneratedNameForNode(node); + return dependencyGroups; } - function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); - return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); + function getNameOfDependencyGroup(dependencyGroup) { + return dependencyGroup.name; } - function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { - if (!constructor || !hasExtendsClause) { - return false; + function recordExportName(name) { + if (!exportedLocalNames) { + exportedLocalNames = []; } - var parameter = ts.singleOrUndefined(constructor.parameters); - if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { - return false; + exportedLocalNames.push(name); + } + function recordExportedFunctionDeclaration(node) { + if (!exportedFunctionDeclarations) { + exportedFunctionDeclarations = []; } - var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202) { - return false; + exportedFunctionDeclarations.push(createDeclarationExport(node)); + } + function hoistBindingElement(node, isExported) { + if (ts.isOmittedExpression(node)) { + return; } - var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174) { - return false; + var name = node.name; + if (ts.isIdentifier(name)) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + if (isExported) { + recordExportName(name); + } } - var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95) { - return false; + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); } - var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191) { - return false; + } + function hoistExportedBindingElement(node) { + hoistBindingElement(node, true); + } + function hoistNonExportedBindingElement(node) { + hoistBindingElement(node, false); + } + function updateSourceFile(node, statements, nodeEmitFlags) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + ts.setEmitFlags(updated, nodeEmitFlags); + return updated; + } + } + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; } - var expression = callArgument.expression; - return ts.isIdentifier(expression) && expression === parameter.name; + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 230: + return undefined; + case 236: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + return node.isExportEquals ? undefined : node; } } - ts.transformES6 = transformES6; + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -42039,11 +43608,19 @@ var ts; if (jsx === 2) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); + if (languageVersion < 4) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3) { + transformers.push(ts.transformES2016); + } if (languageVersion < 2) { - transformers.push(ts.transformES6); + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -42063,7 +43640,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -42203,7 +43780,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { if (disabled) { @@ -42406,7 +43983,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } function getSourceMappingURL() { @@ -42470,7 +44047,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -42508,7 +44085,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 219) { + if (node.kind === 220) { declarationListContainerEnd = end; } } @@ -42584,7 +44161,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -42602,7 +44179,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { if (!writer.isAtStartOfLine()) { writer.write(" "); } @@ -42625,7 +44202,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -42736,7 +44313,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -42780,7 +44357,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230); + ts.Debug.assert(aliasEmitInfo.node.kind === 231); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -42811,7 +44388,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -42851,10 +44428,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218) { + if (declaration.kind === 219) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 || declaration.kind === 234 || declaration.kind === 231) { + else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -42865,7 +44442,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 230) { + if (moduleElementEmitInfo.node.kind === 231) { moduleElementEmitInfo.isVisible = true; } else { @@ -42873,12 +44450,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -42990,67 +44567,67 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 165: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: case 166: + case 167: return writeTextOfNode(currentText, type); - case 194: + case 195: return emitExpressionWithTypeArguments(type); - case 155: + case 156: return emitTypeReference(type); - case 158: + case 159: return emitTypeQuery(type); - case 160: - return emitArrayType(type); case 161: - return emitTupleType(type); + return emitArrayType(type); case 162: - return emitUnionType(type); + return emitTupleType(type); case 163: - return emitIntersectionType(type); + return emitUnionType(type); case 164: + return emitIntersectionType(type); + case 165: return emitParenType(type); - case 156: case 157: + case 158: return emitSignatureDeclarationWithJsDocComments(type); - case 159: + case 160: return emitTypeLiteral(type); - case 69: + case 70: return emitEntityName(type); - case 139: + case 140: return emitEntityName(type); - case 154: + case 155: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69) { + if (entityName.kind === 70) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 ? entityName.left : entityName.expression; - var right = entityName.kind === 139 ? entityName.right : entityName.name; + var left = entityName.kind === 140 ? entityName.left : entityName.expression; + var right = entityName.kind === 140 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 229 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 172); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -43131,7 +44708,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -43152,11 +44729,11 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -43170,7 +44747,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 || + else if (node.kind === 230 || (node.parent.kind === 256 && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { @@ -43182,7 +44759,7 @@ var ts; }); } else { - if (node.kind === 230) { + if (node.kind === 231) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -43200,23 +44777,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220: + case 221: return writeFunctionDeclaration(node); - case 200: + case 201: return writeVariableStatement(node); - case 222: + case 223: return writeInterfaceDeclaration(node); - case 221: + case 222: return writeClassDeclaration(node); - case 223: - return writeTypeAliasDeclaration(node); case 224: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 225: + return writeEnumDeclaration(node); + case 226: return writeModuleDeclaration(node); - case 229: - return writeImportEqualsDeclaration(node); case 230: + return writeImportEqualsDeclaration(node); + case 231: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -43231,7 +44808,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 222 && !noDeclare) { + else if (node.kind !== 223 && !noDeclare) { write("declare "); } } @@ -43271,7 +44848,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -43281,7 +44858,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -43304,7 +44881,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 232) { + if (node.importClause.namedBindings.kind === 233) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -43321,13 +44898,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; var moduleSpecifier; - if (parent.kind === 229) { + if (parent.kind === 230) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225) { + else if (parent.kind === 226) { moduleSpecifier = parent.name; } else { @@ -43395,7 +44972,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226) { + while (node.body && node.body.kind !== 227) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -43429,7 +45006,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -43465,7 +45042,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -43475,49 +45052,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - (node.parent.parent && node.parent.parent.kind === 159)) { - ts.Debug.assert(node.parent.kind === 147 || - node.parent.kind === 146 || - node.parent.kind === 156 || + if (node.parent.kind === 157 || + node.parent.kind === 158 || + (node.parent.parent && node.parent.parent.kind === 160)) { + ts.Debug.assert(node.parent.kind === 148 || + node.parent.kind === 147 || node.parent.kind === 157 || - node.parent.kind === 151 || - node.parent.kind === 152); + node.parent.kind === 158 || + node.parent.kind === 152 || + node.parent.kind === 153); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 221: + case 222: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222: + case 223: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151: + case 152: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 148: case 147: - case 146: 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 === 221) { + else if (node.parent.parent.kind === 222) { 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 220: + case 221: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -43545,16 +45122,16 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93) { + else if (!isImplementsList && node.expression.kind === 94) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 222) { 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; @@ -43634,17 +45211,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 218 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 145 || node.kind === 144 || - (node.kind === 142 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 || node.kind === 145 || + (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 || node.kind === 144) && node.parent.kind === 159) { + if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -43657,14 +45234,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218) { + if (node.kind === 219) { 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 : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 145 || node.kind === 144) { + else if (node.kind === 146 || node.kind === 145) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -43672,7 +45249,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 === 221) { + else if (node.parent.kind === 222) { 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 : @@ -43698,7 +45275,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193) { + if (element.kind !== 194) { elements.push(element); } } @@ -43764,7 +45341,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 149 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -43777,7 +45354,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 + return accessor.kind === 150 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -43786,7 +45363,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150) { + if (accessorWithTypeAnnotation.kind === 151) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -43832,17 +45409,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220) { + if (node.kind === 221) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 || node.kind === 148) { + else if (node.kind === 148 || node.kind === 149) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220) { + if (node.kind === 221) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148) { + else if (node.kind === 149) { write("constructor"); } else { @@ -43862,15 +45439,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153) { + if (node.kind === 154) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 152 || node.kind === 157) { + if (node.kind === 153 || node.kind === 158) { write("new "); } - else if (node.kind === 156) { + else if (node.kind === 157) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -43881,20 +45458,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153) { + if (node.kind === 154) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 156 || node.kind === 157; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159) { + var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -43908,23 +45485,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152: + case 153: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 151: + case 152: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153: + case 154: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 148: case 147: - case 146: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -43932,7 +45509,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 === 221) { + else if (node.parent.kind === 222) { 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 : @@ -43945,7 +45522,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220: + case 221: 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 : @@ -43977,9 +45554,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - node.parent.parent.kind === 159) { + if (node.parent.kind === 157 || + node.parent.kind === 158 || + node.parent.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -43995,22 +45572,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148: + case 149: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 152: + case 153: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 151: + case 152: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44018,7 +45595,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 === 221) { + else if (node.parent.parent.kind === 222) { 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 : @@ -44030,7 +45607,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 220: + case 221: 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 : @@ -44041,12 +45618,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 167) { + if (bindingPattern.kind === 168) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168) { + else if (bindingPattern.kind === 169) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -44057,10 +45634,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193) { + if (bindingElement.kind === 194) { write(" "); } - else if (bindingElement.kind === 169) { + else if (bindingElement.kind === 170) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -44070,7 +45647,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69); + ts.Debug.assert(bindingElement.name.kind === 70); if (bindingElement.dotDotDotToken) { write("..."); } @@ -44082,37 +45659,37 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220: - case 225: - case 229: - case 222: case 221: + case 226: + case 230: case 223: + case 222: case 224: + case 225: return emitModuleElement(node, isModuleElementVisible(node)); - case 200: + case 201: return emitModuleElement(node, isVariableStatementVisible(node)); - case 230: + case 231: return emitModuleElement(node, !node.importClause); - case 236: + case 237: return emitExportDeclaration(node); + case 149: case 148: case 147: - case 146: return writeFunctionDeclaration(node); - case 152: - case 151: case 153: + case 152: + case 154: return emitSignatureDeclarationWithJsDocComments(node); - case 149: case 150: + case 151: return emitAccessorDeclaration(node); + case 146: case 145: - case 144: return emitPropertyDeclaration(node); case 255: return emitEnumMemberDeclaration(node); - case 235: + case 236: return emitExportAssignment(node); case 256: return emitSourceFile(node); @@ -44132,7 +45709,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { if (isBundledEmit && !addBundledFileReference) { return; } @@ -44169,8 +45746,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); @@ -44348,191 +45931,205 @@ var ts; function pipelineEmitInIdentifierNameContext(node) { var kind = node.kind; switch (kind) { - case 69: + case 70: return emitIdentifier(node); } } function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { - case 12: case 13: case 14: + case 15: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 74: - case 77: - case 82: - case 103: - case 110: + case 75: + case 78: + case 83: + case 104: case 111: case 112: case 113: - case 115: + case 114: + case 116: case 117: case 118: + case 119: case 120: + case 121: case 122: - case 130: + case 123: + case 124: + case 125: + case 126: + case 127: case 128: + case 129: + case 130: + case 131: case 132: case 133: + case 134: + case 135: + case 136: case 137: + case 138: + case 139: writeTokenText(kind); return; - case 139: - return emitQualifiedName(node); case 140: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 141: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 142: - return emitParameter(node); + return emitTypeParameter(node); case 143: - return emitDecorator(node); + return emitParameter(node); case 144: - return emitPropertySignature(node); + return emitDecorator(node); case 145: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 146: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 147: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 148: - return emitConstructor(node); + return emitMethodDeclaration(node); case 149: + return emitConstructor(node); case 150: - return emitAccessorDeclaration(node); case 151: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 152: - return emitConstructSignature(node); + return emitCallSignature(node); case 153: - return emitIndexSignature(node); + return emitConstructSignature(node); case 154: - return emitTypePredicate(node); + return emitIndexSignature(node); case 155: - return emitTypeReference(node); + return emitTypePredicate(node); case 156: - return emitFunctionType(node); + return emitTypeReference(node); case 157: - return emitConstructorType(node); + return emitFunctionType(node); case 158: - return emitTypeQuery(node); + return emitConstructorType(node); case 159: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 160: - return emitArrayType(node); + return emitTypeLiteral(node); case 161: - return emitTupleType(node); + return emitArrayType(node); case 162: - return emitUnionType(node); + return emitTupleType(node); case 163: - return emitIntersectionType(node); + return emitUnionType(node); case 164: + return emitIntersectionType(node); + case 165: return emitParenthesizedType(node); - case 194: + case 195: return emitExpressionWithTypeArguments(node); - case 165: - return emitThisType(node); case 166: - return emitLiteralType(node); + return emitThisType(); case 167: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 168: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 169: + return emitArrayBindingPattern(node); + case 170: return emitBindingElement(node); - case 197: - return emitTemplateSpan(node); case 198: - return emitSemicolonClassElement(node); + return emitTemplateSpan(node); case 199: - return emitBlock(node); + return emitSemicolonClassElement(); case 200: - return emitVariableStatement(node); + return emitBlock(node); case 201: - return emitEmptyStatement(node); + return emitVariableStatement(node); case 202: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 203: - return emitIfStatement(node); + return emitExpressionStatement(node); case 204: - return emitDoStatement(node); + return emitIfStatement(node); case 205: - return emitWhileStatement(node); + return emitDoStatement(node); case 206: - return emitForStatement(node); + return emitWhileStatement(node); case 207: - return emitForInStatement(node); + return emitForStatement(node); case 208: - return emitForOfStatement(node); + return emitForInStatement(node); case 209: - return emitContinueStatement(node); + return emitForOfStatement(node); case 210: - return emitBreakStatement(node); + return emitContinueStatement(node); case 211: - return emitReturnStatement(node); + return emitBreakStatement(node); case 212: - return emitWithStatement(node); + return emitReturnStatement(node); case 213: - return emitSwitchStatement(node); + return emitWithStatement(node); case 214: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 215: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 216: - return emitTryStatement(node); + return emitThrowStatement(node); case 217: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 218: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 219: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 220: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 221: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 222: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 223: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 224: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 225: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 226: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 227: + return emitModuleBlock(node); + case 228: return emitCaseBlock(node); - case 229: - return emitImportEqualsDeclaration(node); case 230: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 231: - return emitImportClause(node); + return emitImportDeclaration(node); case 232: - return emitNamespaceImport(node); + return emitImportClause(node); case 233: - return emitNamedImports(node); + return emitNamespaceImport(node); case 234: - return emitImportSpecifier(node); + return emitNamedImports(node); case 235: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 236: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 237: - return emitNamedExports(node); + return emitExportDeclaration(node); case 238: - return emitExportSpecifier(node); + return emitNamedExports(node); case 239: - return; + return emitExportSpecifier(node); case 240: + return; + case 241: return emitExternalModuleReference(node); - case 244: + case 10: return emitJsxText(node); - case 243: + case 244: return emitJsxOpeningElement(node); case 245: return emitJsxClosingElement(node); @@ -44567,73 +46164,73 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 10: case 11: + case 12: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 84: - case 93: - case 95: - case 99: - case 97: + case 85: + case 94: + case 96: + case 100: + case 98: writeTokenText(kind); return; - case 170: - return emitArrayLiteralExpression(node); case 171: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 172: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 173: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 174: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 175: - return emitNewExpression(node); + return emitCallExpression(node); case 176: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 177: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 178: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 179: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 180: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 181: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 182: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 183: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 184: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 185: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 186: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 187: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 188: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 189: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 190: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 191: - return emitSpreadElementExpression(node); + return emitYieldExpression(node); case 192: - return emitClassExpression(node); + return emitSpreadElementExpression(node); case 193: + return emitClassExpression(node); + case 194: return; - case 195: - return emitAsExpression(node); case 196: + return emitAsExpression(node); + case 197: return emitNonNullExpression(node); - case 241: - return emitJsxElement(node); case 242: + return emitJsxElement(node); + case 243: return emitJsxSelfClosingElement(node); case 288: return emitPartiallyEmittedExpression(node); @@ -44669,7 +46266,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -44739,7 +46336,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 ? "get " : "set "); + write(node.kind === 150 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -44767,7 +46364,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } function emitTypePredicate(node) { @@ -44821,7 +46418,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -44889,7 +46486,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -44904,7 +46501,7 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21)) < 0; + return text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -44921,11 +46518,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488); } function emitTaggedTemplateExpression(node) { @@ -44985,16 +46584,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 185 - && ((node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) - || (node.operator === 36 && (operand.operator === 36 || operand.operator === 42))); + return operand.kind === 186 + && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) + || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24; + var isCommaOperator = node.operatorToken.kind !== 25; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -45055,16 +46654,16 @@ var ts; emitExpression(node.expression); emit(node.literal); } - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); write(" "); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } else { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); emitBlockStatements(node); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } } function emitBlockStatements(node) { @@ -45080,7 +46679,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -45088,16 +46687,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88, node.pos, node); + var openParenPos = writeToken(89, node.pos, node); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitExpression(node.expression); - writeToken(18, node.expression.end, node); + writeToken(19, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80, node.thenStatement.end, node); - if (node.elseStatement.kind === 203) { + writeToken(81, node.thenStatement.end, node); + if (node.elseStatement.kind === 204) { write(" "); emit(node.elseStatement); } @@ -45126,9 +46725,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -45138,28 +46737,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219) { + if (node.kind === 220) { emit(node); } else { @@ -45168,17 +46767,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75, node.pos); + writeToken(76, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70, node.pos); + writeToken(71, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94, node.pos, node); + writeToken(95, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -45189,11 +46788,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96, node.pos); + var openParenPos = writeToken(97, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); write(" "); emit(node.caseBlock); } @@ -45218,11 +46817,12 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); write(";"); } function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -45249,13 +46849,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -45278,7 +46878,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { if (ts.getEmitFlags(body) & 32) { return true; } @@ -45302,14 +46902,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16, body.statements.end, body); + writeToken(17, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -45387,7 +46987,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225) { + while (body.kind === 226) { write("."); emit(body.name); body = body.body; @@ -45410,9 +47010,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15, node.pos); + writeToken(16, node.pos); emitList(node, node.clauses, 65); - writeToken(16, node.clauses.end); + writeToken(17, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -45423,7 +47023,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -45543,7 +47143,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -45581,11 +47181,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72, node.pos); + var openParenPos = writeToken(73, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emit(node.variableDeclaration); - writeToken(18, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -45692,7 +47292,7 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192) { + if ((languageVersion < 4) && (!awaiterEmitted && node.flags & 8192)) { writeLines(awaiterHelper); if (languageVersion < 2) { writeLines(generatorHelper); @@ -46001,7 +47601,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -46108,19 +47708,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 69: + case 70: return makeUniqueName(getTextOfNode(node)); + case 226: case 225: - case 224: return generateNameForModuleOrEnum(node); - case 230: - case 236: + case 231: + case 237: return generateNameForImportOrExportDeclaration(node); - case 220: case 221: - case 235: + case 222: + case 236: return generateNameForExportDefault(); - case 192: + case 193: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -46190,6 +47790,68 @@ var ts; } } ts.emitFiles = emitFiles; + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -46643,7 +48305,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -46721,7 +48383,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -46742,14 +48404,14 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -46759,16 +48421,16 @@ var ts; return false; } switch (node.kind) { - case 229: + case 230: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235: + case 236: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221: + case 222: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -46777,29 +48439,29 @@ var ts; break; case 251: var heritageClause = node; - if (heritageClause.token === 106) { + if (heritageClause.token === 107) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222: + case 223: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 226: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: - case 220: + case 221: + case 181: + case 221: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -46807,20 +48469,20 @@ var ts; return true; } break; - case 200: + case 201: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218: + case 219: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174: case 175: + case 176: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -46828,7 +48490,7 @@ var ts; return true; } break; - case 142: + case 143: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -46844,12 +48506,12 @@ var ts; return true; } break; - case 145: + case 146: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113) { + if (modifier.kind !== 114) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -46859,14 +48521,14 @@ var ts; return true; } break; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177: + case 178: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 143: + case 144: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, 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)); } @@ -46894,18 +48556,18 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112: - case 110: + case 113: case 111: - case 128: - case 122: + case 112: + case 129: + case 123: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 113: - case 82: - case 74: - case 77: - case 115: + case 114: + case 83: + case 75: + case 78: + case 116: } } } @@ -46938,7 +48600,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -46977,9 +48639,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 231: case 230: - case 229: - case 236: + case 237: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -46991,7 +48653,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225: + case 226: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -47018,7 +48680,7 @@ var ts; } } } - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -47026,7 +48688,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -47036,13 +48698,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -47066,7 +48728,7 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -47075,16 +48737,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -47111,12 +48773,11 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -47126,10 +48787,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -47151,7 +48812,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -47162,7 +48823,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } } } @@ -47188,7 +48849,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -47208,7 +48869,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -47378,7 +49039,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -47387,10 +49048,10 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } if (emitFilesSeen.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -47398,7 +49059,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -47411,24 +49072,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -47443,7 +49104,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -47453,15 +49114,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -47470,7 +49131,7 @@ var ts; "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -47479,18 +49140,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -47501,11 +49162,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -47514,12 +49175,12 @@ var ts; "lf": 1 }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -47528,7 +49189,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -47537,59 +49198,59 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -47612,30 +49273,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -47646,7 +49307,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -47661,22 +49322,24 @@ var ts; "es3": 0, "es5": 1, "es6": 2, - "es2015": 2 + "es2015": 2, + "es2016": 3, + "es2017": 4, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -47693,10 +49356,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -47819,7 +49482,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -47846,7 +49509,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -47869,7 +49532,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; function getOptionNameMap() { @@ -47889,10 +49552,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -48507,7 +50167,7 @@ var ts; reportDiagnostic(diagnostic, host); } } - function reportEmittedFiles(files, host) { + function reportEmittedFiles(files) { if (!files || files.length == 0) { return; } @@ -48566,10 +50226,10 @@ var ts; }); return count; } - function getDiagnosticText(message) { - var args = []; + function getDiagnosticText(_message) { + var _args = []; for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; + _args[_i - 1] = arguments[_i]; } var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; @@ -48841,7 +50501,7 @@ var ts; } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && ts.isWatchSet(compilerOptions) && ts.sys.watchFile) { - sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); + sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (_fileName, removed) { return sourceFileChanged(sourceFile, removed); }); } return sourceFile; } @@ -48963,7 +50623,7 @@ var ts; var emitOutput = program.emit(); diagnostics = diagnostics.concat(emitOutput.diagnostics); reportDiagnostics(ts.sortAndDeduplicateDiagnostics(diagnostics), compilerHost); - reportEmittedFiles(emitOutput.emittedFiles, compilerHost); + reportEmittedFiles(emitOutput.emittedFiles); if (emitOutput.emitSkipped && diagnostics.length > 0) { return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } @@ -49105,3 +50765,5 @@ if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnviron ts.sys.tryEnableSourceMapsForHost(); } ts.executeCommandLine(ts.sys.args); + +//# sourceMappingURL=tsc.js.map diff --git a/lib/tsserver.js b/lib/tsserver.js index f5437988c1a20..be6578b076203 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -20,6 +20,418 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +444,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -46,6 +490,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -63,10 +667,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -77,7 +938,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -129,7 +990,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -150,7 +1018,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -192,6 +1060,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -335,13 +1209,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -442,6 +1335,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -454,8 +1359,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -488,8 +1393,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -708,8 +1613,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -810,7 +1715,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -841,7 +1746,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -866,11 +1771,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -933,7 +1838,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1086,7 +1991,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1383,7 +2288,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1398,7 +2303,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1508,6 +2413,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1571,10 +2484,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1596,6 +2509,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1908,7 +2828,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1980,6 +2900,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2121,7 +3046,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2137,9 +3062,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2927,7 +3852,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2964,10194 +3889,8756 @@ var ts; 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" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { - function tokenIsIdentifierOrKeyword(token) { - return token >= 69; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ - "abstract": 115, - "any": 117, - "as": 116, - "boolean": 120, - "break": 70, - "case": 71, - "catch": 72, - "class": 73, - "continue": 75, - "const": 74, - "constructor": 121, - "debugger": 76, - "declare": 122, - "default": 77, - "delete": 78, - "do": 79, - "else": 80, - "enum": 81, - "export": 82, - "extends": 83, - "false": 84, - "finally": 85, - "for": 86, - "from": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 44, - ">>>": 45, - "&": 46, - "|": 47, - "^": 48, - "!": 49, - "~": 50, - "&&": 51, - "||": 52, - "?": 53, - ":": 54, - "=": 56, - "+=": 57, - "-=": 58, - "*=": 59, - "**=": 60, - "/=": 61, - "%=": 62, - "<<=": 63, - ">>=": 64, - ">>>=": 65, - "&=": 66, - "|=": 67, - "^=": 68, - "@": 55 - }); - var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - function lookupInUnicodeMap(code, map) { - if (code < map[0]) { - return false; - } - var lo = 0; - var hi = map.length; - var mid; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - if (code < map[mid]) { - hi = mid; - } - else { - lo = mid + 2; - } - } - return false; - } - function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); - } - ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; - function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + function trace(host) { + host.trace(ts.formatMessage.apply(undefined, arguments)); } - function makeReverseMap(source) { - var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } - return result; + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; } - var tokenStrings = makeReverseMap(textToToken); - function tokenToString(t) { - return tokenStrings[t]; + ts.isTraceEnabled = isTraceEnabled; + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; } - ts.tokenToString = tokenToString; - function stringToToken(s) { - return textToToken[s]; + ts.createResolvedModule = createResolvedModule; + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - ts.stringToToken = stringToToken; - function computeLineStarts(text) { - var result = new Array(); - var pos = 0; - var lineStart = 0; - while (pos < text.length) { - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 13: - if (text.charCodeAt(pos) === 10) { - pos++; + function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + function tryReadFromField(fieldName) { + if (ts.hasProperty(jsonContent, fieldName)) { + var typesFile = jsonContent[fieldName]; + if (typeof typesFile === "string") { + var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); } - case 10: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > 127 && isLineBreak(ch)) { - result.push(lineStart); - lineStart = pos; + return typesFilePath_1; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); } - break; + } } } - result.push(lineStart); - return result; - } - ts.computeLineStarts = computeLineStarts; - function getPositionOfLineAndCharacter(sourceFile, line, character) { - return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); - } - ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; - function computePositionOfLineAndCharacter(lineStarts, line, character) { - ts.Debug.assert(line >= 0 && line < lineStarts.length); - return lineStarts[line] + character; - } - ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; - function getLineStarts(sourceFile) { - return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); - } - ts.getLineStarts = getLineStarts; - function computeLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position); - if (lineNumber < 0) { - lineNumber = ~lineNumber - 1; - ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); + var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { + return typesFilePath; } - return { - line: lineNumber, - character: position - lineStarts[lineNumber] - }; - } - ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; - function getLineAndCharacterOfPosition(sourceFile, position) { - return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); - } - ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function isWhiteSpace(ch) { - return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); - } - ts.isWhiteSpace = isWhiteSpace; - function isWhiteSpaceSingleLine(ch) { - return ch === 32 || - ch === 9 || - ch === 11 || - ch === 12 || - ch === 160 || - ch === 133 || - ch === 5760 || - ch >= 8192 && ch <= 8203 || - ch === 8239 || - ch === 8287 || - ch === 12288 || - ch === 65279; - } - ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; - function isLineBreak(ch) { - return ch === 10 || - ch === 13 || - ch === 8232 || - ch === 8233; - } - ts.isLineBreak = isLineBreak; - function isDigit(ch) { - return ch >= 48 && ch <= 57; + if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + } + var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + return mainFilePath; + } + return undefined; } - function isOctalDigit(ch) { - return ch >= 48 && ch <= 55; + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } } - ts.isOctalDigit = isOctalDigit; - function couldStartTrivia(text, pos) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - case 10: - case 9: - case 11: - case 12: - case 32: - case 47: - case 60: - case 61: - case 62: - return true; - case 35: - return pos === 0; - default: - return ch > 127; + var typeReferenceExtensions = [".d.ts"]; + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); } + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); } - ts.couldStartTrivia = couldStartTrivia; - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } - if (ts.positionIsSynthesized(pos)) { - return pos; + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } + var typeRoots; while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - if (stopAtComments) { - break; - } - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; - case 60: - case 61: - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; - case 35: - if (pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - continue; - } - break; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - pos++; - continue; - } - break; + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); } - return pos; + var parent_1 = ts.getDirectoryPath(currentDirectory); + if (parent_1 === currentDirectory) { + break; + } + currentDirectory = parent_1; } + return typeRoots; } - ts.skipTrivia = skipTrivia; - var mergeConflictMarkerLength = "<<<<<<<".length; - function isConflictMarkerTrivia(text, pos) { - ts.Debug.assert(pos >= 0); - 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++) { - if (text.charCodeAt(pos + i) !== ch) { - return false; + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + skipTsx: true, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + var primarySearchPaths = typeRoots; + for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { + var typeRoot = primarySearchPaths_1[_i]; + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); + if (resolvedFile_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); } + return { + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + failedLookupLocations: failedLookupLocations + }; } - return ch === 61 || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32; } } - return false; - } - function scanConflictMarkerTrivia(text, pos, error) { - if (error) { - error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } } - var ch = text.charCodeAt(pos); - var len = text.length; - if (ch === 60 || ch === 62) { - while (pos < len && !isLineBreak(text.charCodeAt(pos))) { - pos++; + var resolvedFile; + var initialLocationForSecondaryLookup; + if (containingFile) { + initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); + } + if (initialLocationForSecondaryLookup !== undefined) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + if (traceEnabled) { + if (resolvedFile) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } } } else { - ts.Debug.assert(ch === 61); - while (pos < len) { - var ch_1 = text.charCodeAt(pos); - if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { - break; + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + return { + resolvedTypeReferenceDirective: resolvedFile + ? { primary: false, resolvedFileName: resolvedFile } + : undefined, + failedLookupLocations: failedLookupLocations + }; + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } } - pos++; } } - return pos; + return result; } - var shebangTriviaRegex = /^#!.*/; - function isShebangTrivia(text, pos) { - ts.Debug.assert(pos === 0); - return shebangTriviaRegex.test(text); + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + 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; + 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]); + } + } + 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) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; } - function scanShebangTrivia(text, pos) { - var shebang = shebangTriviaRegex.exec(text)[0]; - pos = pos + shebang.length; - return pos; + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } } - function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { - var pendingPos; - var pendingEnd; - var pendingKind; - var pendingHasTrailingNewLine; - var hasPendingCommentRange = false; - var collecting = trailing || pos === 0; - var accumulator = initial; - scan: while (pos >= 0 && pos < text.length) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (trailing) { - break scan; - } - collecting = true; - if (hasPendingCommentRange) { - pendingHasTrailingNewLine = true; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - var nextChar = text.charCodeAt(pos + 1); - var hasTrailingNewLine = false; - if (nextChar === 47 || nextChar === 42) { - var kind = nextChar === 47 ? 2 : 3; - var startPos = pos; - pos += 2; - if (nextChar === 47) { - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - hasTrailingNewLine = true; - break; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - } - if (collecting) { - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); - if (!reduce && accumulator) { - return accumulator; - } - hasPendingCommentRange = false; - } - pendingPos = startPos; - pendingEnd = pos; - pendingKind = kind; - pendingHasTrailingNewLine = hasTrailingNewLine; - hasPendingCommentRange = true; - } - continue; - } - break scan; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - if (hasPendingCommentRange && isLineBreak(ch)) { - pendingHasTrailingNewLine = true; - } - pos++; - continue; - } - break scan; + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; } } - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } } - return accumulator; - } - function forEachLeadingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, false, cb, state); - } - ts.forEachLeadingCommentRange = forEachLeadingCommentRange; - function forEachTrailingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, true, cb, state); - } - ts.forEachTrailingCommentRange = forEachTrailingCommentRange; - function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, false, cb, state, initial); - } - ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; - function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, true, cb, state, initial); + return undefined; } - ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { - if (!comments) { - comments = []; + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - return comments; - } - function getLeadingCommentRanges(text, pos) { - return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - ts.getTrailingCommentRanges = getTrailingCommentRanges; - function getShebang(text) { - return shebangTriviaRegex.test(text) - ? shebangTriviaRegex.exec(text)[0] - : undefined; + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + var isExternalLibraryImport = false; + if (!resolvedFileName) { + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + } + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); + isExternalLibraryImport = resolvedFileName !== undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + } + } + if (resolvedFileName && host.realpath) { + var originalFileName = resolvedFileName; + resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + } + } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } - ts.getShebang = getShebang; - function isIdentifierStart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); } - ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); + function directoryProbablyExists(directoryName, host) { + return !host.directoryExists || host.directoryExists(directoryName); } - ts.isIdentifierPart = isIdentifierPart; - function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { - return false; + ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; } - for (var i = 1, n = name.length; i < n; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { - return false; + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); } - return true; } - ts.isIdentifierText = isIdentifierText; - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0; } - var pos; - var end; - var startPos; - var tokenPos; - var token; - var tokenValue; - var precedingLineBreak; - var hasExtendedUnicodeEscape; - var tokenIsUnterminated; - setText(text, start, length); - return { - getStartPos: function () { return startPos; }, - getTextPos: function () { return pos; }, - getToken: function () { return token; }, - getTokenPos: function () { return tokenPos; }, - getTokenText: function () { return text.substring(tokenPos, pos); }, - getTokenValue: function () { return tokenValue; }, - hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, - hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, - isUnterminated: function () { return tokenIsUnterminated; }, - reScanGreaterToken: reScanGreaterToken, - reScanSlashToken: reScanSlashToken, - reScanTemplateToken: reScanTemplateToken, - scanJsxIdentifier: scanJsxIdentifier, - scanJsxAttributeValue: scanJsxAttributeValue, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scanJSDocToken: scanJSDocToken, - scan: scan, - getText: getText, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead, - scanRange: scanRange - }; - function error(message, length) { - if (onError) { - onError(message, length || 0); + function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - function scanNumber() { - var start = pos; - while (isDigit(text.charCodeAt(pos))) - pos++; - if (text.charCodeAt(pos) === 46) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; + return ts.forEach(extensions, function (ext) { + return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); + }); + } + function tryFile(fileName, failedLookupLocation, 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); } - var end = pos; - if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { - pos++; - if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) - pos++; - if (isDigit(text.charCodeAt(pos))) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - end = pos; + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocation.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); + if (result) { + return result; } - else { - error(ts.Diagnostics.Digit_expected); + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); } } - return "" + +(text.substring(start, end)); } - function scanOctalDigits() { - var start = pos; - while (isOctalDigit(text.charCodeAt(pos))) { - pos++; + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } - return +(text.substring(start, pos)); + failedLookupLocation.push(packageJsonPath); } - function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); + var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; } - function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; } - function scanHexDigits(minCount, scanAsManyAsPossible) { - var digits = 0; - var value = 0; - while (digits < minCount || scanAsManyAsPossible) { - var ch = text.charCodeAt(pos); - if (ch >= 48 && ch <= 57) { - value = value * 16 + ch - 48; - } - else if (ch >= 65 && ch <= 70) { - value = value * 16 + ch - 65 + 10; - } - else if (ch >= 97 && ch <= 102) { - value = value * 16 + ch - 97 + 10; + } + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var packageResult = void 0; + if (!typesOnly) { + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + return packageResult; + } } - else { - break; + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; } - pos++; - digits++; } - if (digits < minCount) { - value = -1; + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory || checkOneLevel) { + break; } - return value; + directory = parentPath; } - function scanString(allowEscapes) { - if (allowEscapes === void 0) { allowEscapes = true; } - var quote = text.charCodeAt(pos); - pos++; - var result = ""; - var start = pos; - while (true) { - if (pos >= end) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - var ch = text.charCodeAt(pos); - if (ch === quote) { - result += text.substring(start, pos); - pos++; - break; - } - if (ch === 92 && allowEscapes) { - result += text.substring(start, pos); - result += scanEscapeSequence(); - start = pos; - continue; - } - if (isLineBreak(ch)) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - pos++; - } - return result; + return undefined; + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var failedLookupLocations = []; + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); } - function scanTemplateAndSetTokenValue() { - var startedWithBacktick = text.charCodeAt(pos) === 96; - pos++; - var start = pos; - var contents = ""; - var resultingToken; - while (true) { - if (pos >= end) { - contents += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - var currChar = text.charCodeAt(pos); - if (currChar === 96) { - contents += text.substring(start, pos); - pos++; - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { - contents += text.substring(start, pos); - pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; - break; - } - if (currChar === 92) { - contents += text.substring(start, pos); - contents += scanEscapeSequence(); - start = pos; - continue; - } - if (currChar === 13) { - contents += text.substring(start, pos); - pos++; - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - contents += "\n"; - start = pos; - continue; - } - pos++; - } - ts.Debug.assert(resultingToken !== undefined); - tokenValue = contents; - return resultingToken; + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } - function scanEscapeSequence() { - pos++; - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - return ""; - } - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 48: - return "\0"; - case 98: - return "\b"; - case 116: - return "\t"; - case 110: - return "\n"; - case 118: - return "\v"; - case 102: - return "\f"; - case 114: - return "\r"; - case 39: - return "\'"; - case 34: - return "\""; - case 117: - if (pos < end && text.charCodeAt(pos) === 123) { - hasExtendedUnicodeEscape = true; - pos++; - return scanExtendedUnicodeEscape(); - } - return scanHexadecimalEscape(4); - case 120: - return scanHexadecimalEscape(2); - case 13: - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - case 10: - case 8232: - case 8233: - return ""; - default: - return String.fromCharCode(ch); - } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); } - function scanHexadecimalEscape(numDigits) { - var escapedValue = scanExactNumberOfHexDigits(numDigits); - if (escapedValue >= 0) { - return String.fromCharCode(escapedValue); + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + return referencedSourceFile; } - else { - error(ts.Diagnostics.Hexadecimal_digit_expected); - return ""; + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; } + containingDirectory = parentPath; } - function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1); - var isInvalidExtendedEscape = false; - if (escapedValue < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - isInvalidExtendedEscape = true; - } - else if (escapedValue > 0x10FFFF) { - error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); - isInvalidExtendedEscape = true; - } - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - isInvalidExtendedEscape = true; - } - else if (text.charCodeAt(pos) === 125) { - pos++; - } - else { - error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); - isInvalidExtendedEscape = true; - } - if (isInvalidExtendedEscape) { - return ""; + } +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.externalHelpersModuleNameText = "tslib"; + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; + if (declaration.kind === kind) { + return declaration; + } } - return utf16EncodeAsString(escapedValue); } - function utf16EncodeAsString(codePoint) { - ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); - if (codePoint <= 65535) { - return String.fromCharCode(codePoint); + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; + return { + string: function () { return str_1; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str_1 += " "; }, + increaseIndent: function () { }, + decreaseIndent: function () { }, + clear: function () { return str_1 = ""; }, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; } - var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; - var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; - return String.fromCharCode(codeUnit1, codeUnit2); } - function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { - var start_1 = pos; - pos += 2; - var value = scanExactNumberOfHexDigits(4); - pos = start_1; - return value; + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = ts.createMap(); + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { + if (!sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + } + sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + } + ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; + function moduleResolutionIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; + } + ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function typeDirectiveIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + } + ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; + function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { + if (names.length !== newResolutions.length) { + return false; + } + for (var i = 0; i < names.length; i++) { + var newResolution = newResolutions[i]; + var oldResolution = oldResolutions && oldResolutions[names[i]]; + var changed = oldResolution + ? !newResolution || !comparer(oldResolution, newResolution) + : newResolution; + if (changed) { + return true; } - return -1; } - function scanIdentifierParts() { - var result = ""; - var start = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch, languageVersion)) { - pos++; - } - else if (ch === 92) { - ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { - break; - } - result += text.substring(start, pos); - result += String.fromCharCode(ch); - pos += 6; - start = pos; - } - else { - break; - } + return false; + } + ts.hasChangesInResolutions = hasChangesInResolutions; + function containsParseError(node) { + aggregateChildData(node); + return (node.flags & 2097152) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.flags & 4194304)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.flags |= 2097152; } - result += text.substring(start, pos); - return result; + node.flags |= 4194304; } - function getIdentifierToken() { - var len = tokenValue.length; - if (len >= 2 && len <= 11) { - var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; - } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 256) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 200: + case 228: + case 207: + case 208: + case 209: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + function isDefined(value) { + return value !== undefined; + } + ts.isDefined = isDefined; + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = ts.getLineStarts(sourceFile); + var lineIndex = line; + var sourceText = sourceFile.text; + if (lineIndex + 1 === lineStarts.length) { + return sourceText.length - 1; + } + else { + var start = lineStarts[lineIndex]; + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); + while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { + pos--; } - return token = 69; + return pos; } - function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; - var numberOfDigits = 0; - while (true) { - var ch = text.charCodeAt(pos); - var valueOfCh = ch - 48; - if (!isDigit(ch) || valueOfCh >= base) { - break; - } - value = value * base + valueOfCh; - pos++; - numberOfDigits++; + } + ts.getEndLinePosition = getEndLinePosition; + function nodeIsMissing(node) { + if (node === undefined) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { + if (nodeIsMissing(node)) { + return node.pos; + } + if (isJSDocNode(node)) { + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); + } + if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { + return getTokenPosOfNode(node.jsDocComments[0]); + } + if (node.kind === 286 && node._children.length > 0) { + return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function isJSDocNode(node) { + return node.kind >= 257 && node.kind <= 282; + } + ts.isJSDocNode = isJSDocNode; + function isJSDocTag(node) { + return node.kind >= 273 && node.kind <= 285; + } + ts.isJSDocTag = isJSDocTag; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + function getLiteralText(node, sourceFile, languageVersion) { + if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText('"', node.text, '"'); + } + if (!nodeIsSynthesized(node) && node.parent) { + var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); + if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + return node.text; } - if (numberOfDigits === 0) { - return -1; + return text; + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText('"', node.text, '"'); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 13: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + ts.getLiteralText = getLiteralText; + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; } - return value; } - function scan() { - startPos = pos; - hasExtendedUnicodeEscape = false; - precedingLineBreak = false; - tokenIsUnterminated = false; - while (true) { - tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var ch = text.charCodeAt(pos); - if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - if (skipTrivia) { - continue; - } - else { - return token = 6; - } - } - switch (ch) { - case 10: - case 13: - precedingLineBreak = true; - if (skipTrivia) { - pos++; - continue; - } - else { - if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { - pos += 2; - } - else { - pos++; - } - return token = 4; - } - case 9: - case 11: - case 12: - case 32: - if (skipTrivia) { - pos++; - continue; - } - else { - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - } - case 33: - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; - } - return pos += 2, token = 31; - } - pos++; - return token = 49; - case 34: - case 39: - tokenValue = scanString(); - return token = 9; - case 96: - return token = scanTemplateAndSetTokenValue(); - case 37: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; - } - pos++; - return token = 40; - case 38: - if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; - } - pos++; - return token = 46; - case 40: - pos++; - return token = 17; - case 41: - pos++; - return token = 18; - case 42: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; - } - if (text.charCodeAt(pos + 1) === 42) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; - } - return pos += 2, token = 38; - } - pos++; - return token = 37; - case 43: - if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - pos++; - return token = 35; - case 44: - pos++; - return token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 46: - if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); - return token = 8; - } - if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; - } - pos++; - return token = 21; - case 47: - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < end) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - if (skipTrivia) { - continue; - } - else { - return token = 2; - } - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - var commentClosed = false; - while (pos < end) { - var ch_2 = text.charCodeAt(pos); - if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - commentClosed = true; - break; - } - if (isLineBreak(ch_2)) { - precedingLineBreak = true; - } - pos++; - } - if (!commentClosed) { - error(ts.Diagnostics.Asterisk_Slash_expected); - } - if (skipTrivia) { - continue; - } - else { - tokenIsUnterminated = !commentClosed; - return token = 3; - } - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; - } - pos++; - return token = 39; - case 48: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { - pos += 2; - var value = scanMinimumNumberOfHexDigits(1); - if (value < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { - pos += 2; - var value = scanBinaryOrOctalDigits(2); - if (value < 0) { - error(ts.Diagnostics.Binary_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { - pos += 2; - var value = scanBinaryOrOctalDigits(8); - if (value < 0) { - error(ts.Diagnostics.Octal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - return token = 8; - } - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - tokenValue = scanNumber(); - return token = 8; - case 58: - pos++; - return token = 54; - case 59: - pos++; - return token = 23; - case 60: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 60) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; - } - return pos += 2, token = 43; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; - } - if (languageVariant === 1 && - text.charCodeAt(pos + 1) === 47 && - text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; - } - pos++; - return token = 25; - case 61: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; - } - return pos += 2, token = 30; - } - if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; - } - pos++; - return token = 56; - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - pos++; - return token = 27; - case 63: - pos++; - return token = 53; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 94: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; - case 123: - pos++; - return token = 15; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; - } - pos++; - return token = 47; - case 125: - pos++; - return token = 16; - case 126: - pos++; - return token = 50; - case 64: - pos++; - return token = 55; - case 92: - var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - default: - if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else if (isWhiteSpaceSingleLine(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - } - } + return false; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + } + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || + isCatchClauseVariableDeclaration(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isAmbientModule(node) { + return node && node.kind === 226 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isShorthandAmbientModuleSymbol(moduleSymbol) { + return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + } + ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; + function isShorthandAmbientModule(node) { + return node.kind === 226 && (!node.body); + } + function isBlockScopedContainerTopLevel(node) { + return node.kind === 256 || + node.kind === 226 || + isFunctionLike(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 512); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; } - function reScanGreaterToken() { - if (token === 27) { - if (text.charCodeAt(pos) === 62) { - if (text.charCodeAt(pos + 1) === 62) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; - } - return pos += 2, token = 45; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - pos++; - return token = 44; - } - if (text.charCodeAt(pos) === 61) { - pos++; - return token = 29; - } + switch (node.parent.kind) { + case 256: + return ts.isExternalModule(node.parent); + case 227: + return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isBlockScope(node, parentNode) { + switch (node.kind) { + case 256: + case 228: + case 252: + case 226: + case 207: + case 208: + case 209: + case 149: + case 148: + case 150: + case 151: + case 221: + case 180: + case 181: + return true; + case 200: + return parentNode && !isFunctionLike(parentNode); + } + return false; + } + ts.isBlockScope = isBlockScope; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isBlockScope(current, current.parent)) { + return current; } - return token; + current = current.parent; } - function reScanSlashToken() { - if (token === 39 || token === 61) { - var p = tokenPos + 1; - var inEscape = false; - var inCharacterClass = false; - while (true) { - if (p >= end) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - var ch = text.charCodeAt(p); - if (isLineBreak(ch)) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - if (inEscape) { - inEscape = false; - } - else if (ch === 47 && !inCharacterClass) { - p++; - break; - } - else if (ch === 91) { - inCharacterClass = true; - } - else if (ch === 92) { - inEscape = true; - } - else if (ch === 93) { - inCharacterClass = false; - } - p++; - } - while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { - p++; - } - pos = p; - tokenValue = text.substring(tokenPos, pos); - token = 10; + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function isCatchClauseVariableDeclaration(declaration) { + return declaration && + declaration.kind === 219 && + declaration.parent && + declaration.parent.kind === 252; + } + ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForArrowFunction(sourceFile, node) { + var pos = ts.skipTrivia(sourceFile.text, node.pos); + if (node.body && node.body.kind === 200) { + var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; + if (startLine < endLine) { + return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); } - return token; } - function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); - pos = tokenPos; - return token = scanTemplateAndSetTokenValue(); + return ts.createTextSpanFromBounds(pos, node.end); + } + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 256: + 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 219: + case 170: + case 222: + case 193: + case 223: + case 226: + case 225: + case 255: + case 221: + case 180: + case 148: + case 150: + case 151: + case 224: + errorNode = node.name; + break; + case 181: + return getErrorSpanForArrowFunction(sourceFile, node); } - function reScanJsxToken() { - pos = tokenPos = startPos; - return token = scanJsxToken(); + if (errorNode === undefined) { + return getSpanOfTokenAtPosition(sourceFile, node.pos); } - function scanJsxToken() { - startPos = tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var char = text.charCodeAt(pos); - if (char === 60) { - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - return token = 26; + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; + function isDeclarationFile(file) { + return file.isDeclarationFile; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 225 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function isConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2) + || !!(ts.getCombinedModifierFlags(node) & 2048); + } + ts.isConst = isConst; + function isLet(node) { + return !!(ts.getCombinedNodeFlags(node) & 1); + } + ts.isLet = isLet; + function isSuperCall(n) { + return n.kind === 175 && n.expression.kind === 96; + } + ts.isSuperCall = isSuperCall; + function isPrologueDirective(node) { + return node.kind === 203 && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getLeadingCommentRangesOfNodeFromText(node, text) { + return ts.getLeadingCommentRanges(text, node.pos); + } + ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; + function getJsDocComments(node, sourceFileOfNode) { + return getJsDocCommentsFromText(node, sourceFileOfNode.text); + } + ts.getJsDocComments = getJsDocComments; + function getJsDocCommentsFromText(node, text) { + var commentRanges = (node.kind === 143 || + node.kind === 142 || + node.kind === 180 || + node.kind === 181) ? + ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : + getLeadingCommentRangesOfNodeFromText(node, text); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 42 && + text.charCodeAt(comment.pos + 3) !== 47; + } + } + ts.getJsDocCommentsFromText = getJsDocCommentsFromText; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isPartOfTypeNode(node) { + if (155 <= node.kind && node.kind <= 167) { + return true; + } + switch (node.kind) { + case 118: + case 131: + case 133: + case 121: + case 134: + case 136: + case 128: + return true; + case 104: + return node.parent.kind !== 184; + case 195: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 70: + if (node.parent.kind === 140 && node.parent.right === node) { + node = node.parent; } - pos++; - return token = 25; - } - if (char === 123) { - pos++; - return token = 15; - } - while (pos < end) { - pos++; - char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { - break; + else if (node.parent.kind === 173 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140: + case 173: + case 98: + var parent_2 = node.parent; + if (parent_2.kind === 159) { + return false; + } + if (155 <= parent_2.kind && parent_2.kind <= 167) { + return true; } + switch (parent_2.kind) { + case 195: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); + case 142: + return node === parent_2.constraint; + case 146: + case 145: + case 143: + case 219: + return node === parent_2.type; + case 221: + case 180: + case 181: + case 149: + case 148: + case 147: + case 150: + case 151: + return node === parent_2.type; + case 152: + case 153: + case 154: + return node === parent_2.type; + case 178: + return node === parent_2.type; + case 175: + case 176: + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; + case 177: + return false; + } + } + return false; + } + ts.isPartOfTypeNode = isPartOfTypeNode; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 212: + return visitor(node); + case 228: + case 200: + case 204: + case 205: + case 206: + case 207: + case 208: + case 209: + case 213: + case 214: + case 249: + case 250: + case 215: + case 217: + case 252: + return ts.forEachChild(node, traverse); } - return token = 244; } - function scanJsxIdentifier() { - if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { - pos++; + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 191: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); } - else { - break; + case 225: + case 223: + case 226: + case 224: + case 222: + case 193: + return; + default: + if (isFunctionLike(node)) { + var name_4 = node.name; + if (name_4 && name_4.kind === 141) { + traverse(name_4.expression); + return; + } + } + else if (!isPartOfTypeNode(node)) { + ts.forEachChild(node, traverse); } - } - tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); } - return token; } - function scanJsxAttributeValue() { - startPos = pos; - switch (text.charCodeAt(pos)) { - case 34: - case 39: - tokenValue = scanString(false); - return token = 9; - default: - return scan(); + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 170: + case 255: + case 143: + case 253: + case 146: + case 145: + case 254: + case 219: + return true; } } - function scanJSDocToken() { - if (pos >= end) { - return token = 1; + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 150 || node.kind === 151); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 222 || node.kind === 193); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + return node && isFunctionLikeKind(node.kind); + } + ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 149: + case 180: + case 221: + case 181: + case 148: + case 147: + case 150: + case 151: + case 152: + case 153: + case 154: + case 157: + case 158: + return true; + } + return false; + } + ts.isFunctionLikeKind = isFunctionLikeKind; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 148: + case 147: + case 149: + case 150: + case 151: + case 221: + case 180: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 207: + case 208: + case 209: + case 205: + case 206: + return true; + case 215: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 200 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 148 && node.parent.kind === 172; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 148 && + (node.parent.kind === 172 || + node.parent.kind === 193); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; + function isIdentifierTypePredicate(predicate) { + return predicate && predicate.kind === 1; + } + ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; } - startPos = pos; - tokenPos = pos; - var ch = text.charCodeAt(pos); - switch (ch) { - case 9: - case 11: - case 12: - case 32: - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - case 64: - pos++; - return token = 55; - case 10: - case 13: - pos++; - return token = 4; - case 42: - pos++; - return token = 37; - case 123: - pos++; - return token = 15; - case 125: - pos++; - return token = 16; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 61: - pos++; - return token = 56; - case 44: - pos++; - return token = 24; + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; } - if (isIdentifierStart(ch, 2)) { - pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { - pos++; - } - return token = 69; + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; } - else { - return pos += 1, token = 0; + switch (node.kind) { + case 141: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 181: + if (!includeArrowFunctions) { + continue; + } + case 221: + case 180: + case 226: + case 146: + case 145: + case 148: + case 147: + case 149: + case 150: + case 151: + case 152: + case 153: + case 154: + case 225: + case 256: + return node; } } - function speculationHelper(callback, isLookahead) { - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var saveTokenValue = tokenValue; - var savePrecedingLineBreak = precedingLineBreak; - var result = callback(); - if (!result || isLookahead) { - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, stopOnFunctions) { + while (true) { + node = node.parent; + if (!node) { + return node; + } + switch (node.kind) { + case 141: + node = node.parent; + break; + case 221: + case 180: + case 181: + if (!stopOnFunctions) { + continue; + } + case 146: + case 145: + case 148: + case 147: + case 149: + case 150: + case 151: + return node; + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; } - return result; } - function scanRange(start, length, callback) { - var saveEnd = end; - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var savePrecedingLineBreak = precedingLineBreak; - var saveTokenValue = tokenValue; - var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; - var saveTokenIsUnterminated = tokenIsUnterminated; - setText(text, start, length); - var result = callback(); - end = saveEnd; - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - precedingLineBreak = savePrecedingLineBreak; - tokenValue = saveTokenValue; - hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; - tokenIsUnterminated = saveTokenIsUnterminated; - return result; + } + ts.getSuperContainer = getSuperContainer; + function getImmediatelyInvokedFunctionExpression(func) { + if (func.kind === 180 || func.kind === 181) { + var prev = func; + var parent_3 = func.parent; + while (parent_3.kind === 179) { + prev = parent_3; + parent_3 = parent_3.parent; + } + if (parent_3.kind === 175 && parent_3.expression === prev) { + return parent_3; + } } - function lookAhead(callback) { - return speculationHelper(callback, true); + } + ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; + function isSuperProperty(node) { + var kind = node.kind; + return (kind === 173 || kind === 174) + && node.expression.kind === 96; + } + ts.isSuperProperty = isSuperProperty; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 156: + return node.typeName; + case 195: + ts.Debug.assert(isEntityNameExpression(node.expression)); + return node.expression; + case 70: + case 140: + return node; + } } - function tryScan(callback) { - return speculationHelper(callback, false); + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function isCallLikeExpression(node) { + switch (node.kind) { + case 175: + case 176: + case 177: + case 144: + return true; + default: + return false; } - function getText() { - return text; + } + ts.isCallLikeExpression = isCallLikeExpression; + function getInvokedExpression(node) { + if (node.kind === 177) { + return node.tag; } - function setText(newText, start, length) { - text = newText || ""; - end = length === undefined ? text.length : start + length; - setTextPos(start || 0); + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 222: + return true; + case 146: + return node.parent.kind === 222; + case 150: + case 151: + case 148: + return node.body !== undefined + && node.parent.kind === 222; + case 143: + return node.parent.body !== undefined + && (node.parent.kind === 149 + || node.parent.kind === 148 + || node.parent.kind === 151) + && node.parent.parent.kind === 222; } - function setOnError(errorCallback) { - onError = errorCallback; + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + return node.decorators !== undefined + && nodeCanBeDecorated(node); + } + ts.nodeIsDecorated = nodeIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 222: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 148: + case 151: + return ts.forEach(node.parameters, nodeIsDecorated); } - function setScriptTarget(scriptTarget) { - languageVersion = scriptTarget; + } + ts.childIsDecorated = childIsDecorated; + function isJSXTagName(node) { + var parent = node.parent; + if (parent.kind === 244 || + parent.kind === 243 || + parent.kind === 245) { + return parent.tagName === node; } - function setLanguageVariant(variant) { - languageVariant = variant; + return false; + } + ts.isJSXTagName = isJSXTagName; + function isPartOfExpression(node) { + switch (node.kind) { + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: + case 171: + case 172: + case 173: + case 174: + case 175: + case 176: + case 177: + case 196: + case 178: + case 197: + case 179: + case 180: + case 193: + case 181: + case 184: + case 182: + case 183: + case 186: + case 187: + case 188: + case 189: + case 192: + case 190: + case 12: + case 194: + case 242: + case 243: + case 191: + case 185: + return true; + case 140: + while (node.parent.kind === 140) { + node = node.parent; + } + return node.parent.kind === 159 || isJSXTagName(node); + case 70: + if (node.parent.kind === 159 || isJSXTagName(node)) { + return true; + } + case 8: + case 9: + case 98: + var parent_4 = node.parent; + switch (parent_4.kind) { + case 219: + case 143: + case 146: + case 145: + case 255: + case 253: + case 170: + return parent_4.initializer === node; + case 203: + case 204: + case 205: + case 206: + case 212: + case 213: + case 214: + case 249: + case 216: + case 214: + return parent_4.expression === node; + case 207: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || + forStatement.condition === node || + forStatement.incrementor === node; + case 208: + case 209: + var forInStatement = parent_4; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || + forInStatement.expression === node; + case 178: + case 196: + return node === parent_4.expression; + case 198: + return node === parent_4.expression; + case 141: + return node === parent_4.expression; + case 144: + case 248: + case 247: + return true; + case 195: + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); + default: + if (isPartOfExpression(parent_4)) { + return true; + } + } } - function setTextPos(textPos) { - ts.Debug.assert(textPos >= 0); - pos = textPos; - startPos = textPos; - tokenPos = textPos; - token = 0; - precedingLineBreak = false; - tokenValue = undefined; - hasExtendedUnicodeEscape = false; - tokenIsUnterminated = false; + return false; + } + ts.isPartOfExpression = isPartOfExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 230 && node.moduleReference.kind === 241; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 230 && node.moduleReference.kind !== 241; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.flags & 1048576); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 175 && + expression.expression.kind === 70 && + expression.expression.text === "require" && + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + } + ts.isRequireCall = isRequireCall; + function isSingleOrDoubleQuote(charCode) { + return charCode === 39 || charCode === 34; + } + ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; + function isDeclarationOfFunctionExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219) { + var declaration = s.valueDeclaration; + return declaration.initializer && declaration.initializer.kind === 180; } + return false; } - ts.createScanner = createScanner; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file - }, - { - name: "inlineSourceMap", - type: "boolean" - }, - { - name: "inlineSources", - type: "boolean" - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2 - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true + ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + function getSpecialPropertyAssignmentKind(expression) { + if (!isInJavaScriptFile(expression)) { + return 0; + } + if (expression.kind !== 188) { + return 0; + } + var expr = expression; + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { + return 0; + } + var lhs = expr.left; + if (lhs.expression.kind === 70) { + var lhsId = lhs.expression; + if (lhsId.text === "exports") { + return 1; } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true + else if (lhsId.text === "module" && lhs.name.text === "exports") { + return 2; } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.ts", - "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", - "es2016.array.include": "lib.es2016.array.include.d.ts", - "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } - ]; - ts.typingOptionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean" - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" + else if (lhs.expression.kind === 98) { + return 4; + } + else if (lhs.expression.kind === 173) { + var innerPropertyAccess = lhs.expression; + if (innerPropertyAccess.expression.kind === 70) { + var innerPropertyAccessIdentifier = innerPropertyAccess.expression; + if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { + return 1; + } + if (innerPropertyAccess.name.text === "prototype") { + return 3; + } } } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false - }; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; + return 0; + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getExternalModuleName(node) { + if (node.kind === 231) { + return node.moduleSpecifier; } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + if (node.kind === 230) { + var reference = node.moduleReference; + if (reference.kind === 241) { + return reference.expression; } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); } - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - var key = trimString((value || "")).toLowerCase(); - var map = opt.type; - if (key in map) { - return map[key]; + if (node.kind === 237) { + return node.moduleSpecifier; } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + if (node.kind === 226 && node.name.kind === 9) { + return node.name; } } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; + ts.getExternalModuleName = getExternalModuleName; + function getNamespaceDeclarationNode(node) { + if (node.kind === 230) { + return node; } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { + return importClause.namedBindings; } } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } + ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; + function isDefaultImport(node) { + return node.kind === 231 + && node.importClause + && !!node.importClause.name; + } + ts.isDefaultImport = isDefaultImport; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 143: + case 148: + case 147: + case 254: + case 253: + case 146: + case 145: + return node.questionToken !== undefined; } - parseStrings(args); } + return false; } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 269 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 271; } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; + var jsDocTags = getJSDocTags(node, checkParentVariableStatement); + if (!jsDocTags) { + return undefined; } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; + for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { + var tag = jsDocTags_1[_i]; + if (tag.kind === kind) { + return tag; } } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } + } + function append(previous, additional) { + if (additional) { + if (!previous) { + previous = []; + } + for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { + var x = additional_1[_i]; + previous.push(x); } - return undefined; } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_5] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_5] = convertedValue; - } - else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } + return previous; + } + function getJSDocComments(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); + } + ts.getJSDocComments = getJSDocComments; + function getJSDocTags(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { + var result = []; + for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { + var doc = docs_1[_i]; + if (doc.tags) { + result.push.apply(result, doc.tags); } } return result; - } + }, function (tags) { return tags; }); } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; + function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { + var result = undefined; + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && + (node.parent).initializer === node && + node.parent.parent.parent.kind === 201; + var isVariableOfVariableDeclarationStatement = isVariableLike(node) && + node.parent.parent.kind === 201; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : + isVariableOfVariableDeclarationStatement ? node.parent.parent : + undefined; + if (variableStatementNode) { + result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === 226 && + node.parent && node.parent.kind === 226) { + result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); + } + var parent_5 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && + parent_5.kind === 188 && + parent_5.operatorToken.kind === 57 && + parent_5.parent.kind === 203; + if (isSourceOfAssignmentExpressionStatement) { + result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); + } + var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; + if (isPropertyAssignmentExpression) { + result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === 143) { + var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); + if (paramTags) { + result = append(result, getTags(paramTags)); + } } } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - var errors = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typingOptions: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; + if (isVariableLike(node) && node.initializer) { + result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + if (node.jsDocComments) { + if (result) { + result = append(result, getDocs(node.jsDocComments)); } else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; + return getDocs(node.jsDocComments); } - if (files && !json["files"]) { - json["files"] = files; + } + return result; + } + function getJSDocParameterTag(param, checkParentVariableStatement) { + var func = param.parent; + var tags = getJSDocTags(func, checkParentVariableStatement); + if (!param.name) { + var i = func.parameters.indexOf(param); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275; }); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; } - options = ts.assign({}, baseOptions, options); } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typingOptions: typingOptions, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; + else if (param.name.kind === 70) { + var name_5 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_5; }); + if (paramTags) { + return paramTags; } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + else { + return undefined; + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 277, false); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 276, true); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 278, false); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 70) { + var parameterName = parameter.name.text; + var jsDocTags = getJSDocTags(parameter.parent, true); + if (!jsDocTags) { + return undefined; } - else { - excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); + for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { + var tag = jsDocTags_2[_i]; + if (tag.kind === 275) { + var parameterTag = tag; + if (parameterTag.parameterName.text === parameterName) { + return parameterTag; + } } } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; } - return false; + return undefined; } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; + ts.hasRestParameter = hasRestParameter; + function hasDeclaredRestParameter(s) { + return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); } - ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; + ts.hasDeclaredRestParameter = hasDeclaredRestParameter; + function isRestParameter(node) { + if (node && (node.flags & 1048576)) { + if (node.type && node.type.kind === 270) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 270; + } + } + return isDeclaredRestParam(node); } - function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; - convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); - return options; + ts.isRestParameter = isRestParameter; + function isDeclaredRestParam(node) { + return node && node.dotDotDotToken !== undefined; } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; + ts.isDeclaredRestParam = isDeclaredRestParam; + function isAssignmentTarget(node) { + while (node.parent.kind === 179) { + node = node.parent; } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + while (true) { + var parent_6 = node.parent; + if (parent_6.kind === 171 || parent_6.kind === 192) { + node = parent_6; + continue; } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + if (parent_6.kind === 253 || parent_6.kind === 254) { + node = parent_6.parent; + continue; } + return parent_6.kind === 188 && + isAssignmentOperator(parent_6.operatorToken.kind) && + parent_6.left === node || + (parent_6.kind === 208 || parent_6.kind === 209) && + parent_6.initializer === node; } } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); + ts.isAssignmentTarget = isAssignmentTarget; + function isNodeDescendantOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); + return false; + } + ts.isNodeDescendantOf = isNodeDescendantOf; + function isInAmbientContext(node) { + while (node) { + if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { + return true; } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclarationName(name) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 235 || parent.kind === 239) { + if (parent.propertyName) { + return true; } - return value; } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + if (isDeclaration(parent)) { + return parent.name === name; } + return false; } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + ts.isDeclarationName = isDeclarationName; + function isLiteralComputedPropertyDeclarationName(node) { + return (node.kind === 9 || node.kind === 8) && + node.parent.kind === 141 && + isDeclaration(node.parent.parent); + } + ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 146: + case 145: + case 148: + case 147: + case 150: + case 151: + case 255: + case 253: + case 173: + return parent.name === node; + case 140: + if (parent.right === node) { + while (parent.kind === 140) { + parent = parent.parent; + } + return parent.kind === 159; + } + return false; + case 170: + case 235: + return parent.propertyName === node; + case 239: + return true; } + return false; } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 230 || + node.kind === 229 || + node.kind === 232 && !!node.name || + node.kind === 233 || + node.kind === 235 || + node.kind === 239 || + node.kind === 236 && exportAssignmentIsAlias(node); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function exportAssignmentIsAlias(node) { + return isEntityNameExpression(node.expression); } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 107); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; + if (clause.token === kind) { + return clause; } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; + return undefined; } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.test(comment)) { + if (isNoDefaultLibRegEx.test(comment)) { + return { + isNoDefaultLib: true + }; } else { - validSpecs.push(spec); + var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + if (refMatchResult || refLibResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: (refMatchResult || refLibResult)[3] + }, + isNoDefaultLib: false, + isTypeReferenceDirective: !!refLibResult + }; + } + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; } } - return validSpecs; + return undefined; } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - var recursiveKeys = []; - for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { - var file = include_1[_i]; - var name_6 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_6)) { - continue; - } - var match = wildcardDirectoryPattern.exec(name_6); - if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_6) ? 1 : 0; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 71 <= token && token <= 139; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function isStringOrNumericLiteral(kind) { + return kind === 9 || kind === 8; + } + ts.isStringOrNumericLiteral = isStringOrNumericLiteral; + function hasDynamicName(declaration) { + return declaration.name && isDynamicName(declaration.name); + } + ts.hasDynamicName = hasDynamicName; + function isDynamicName(name) { + return name.kind === 141 && + !isStringOrNumericLiteral(name.expression.kind) && + !isWellKnownSymbolSyntactically(name.expression); + } + ts.isDynamicName = isDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { + return name.text; + } + if (name.kind === 141) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } + else if (nameExpression.kind === 9 || nameExpression.kind === 8) { + return nameExpression.text; } } - return wildcardDirectories; + return undefined; } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 70 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; + function isModifierKind(token) { + switch (token) { + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: + case 113: + case 111: + case 112: + case 129: + case 114: return true; - } } return false; } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } + ts.isModifierKind = isModifierKind; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 143; } - function addFileToOutput(output, file) { - output.push(file); - return output; + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 170) { + node = node.parent.parent; + } + return node; } - function caseSensitiveKeyMapper(key) { - return key; + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(node) { + var kind = node.kind; + return kind === 149 + || kind === 180 + || kind === 221 + || kind === 181 + || kind === 148 + || kind === 150 + || kind === 151 + || kind === 226 + || kind === 256; } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function nodeIsSynthesized(node) { + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); } -})(ts || (ts = {})); -var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { - var inferredTypings = ts.createMap(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - 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(typingOptions.include); - exclude = typingOptions.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { - 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); - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; - } - } - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; - delete inferredTypings[excludeTypingName]; + ts.nodeIsSynthesized = nodeIsSynthesized; + function getOriginalNode(node) { + if (node) { + while (node.original !== undefined) { + node = node.original; } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } + } + return node; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + function getOriginalSourceFiles(sourceFiles) { + var originalSourceFiles = []; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); + if (originalSourceFile) { + originalSourceFiles.push(originalSourceFile); } - 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; - } + } + return originalSourceFiles; + } + ts.getOriginalSourceFiles = getOriginalSourceFiles; + function getOriginalNodeId(node) { + node = getOriginalNode(node); + return node ? ts.getNodeId(node) : 0; + } + ts.getOriginalNodeId = getOriginalNodeId; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(ts.Associativity || (ts.Associativity = {})); + var Associativity = ts.Associativity; + function getExpressionAssociativity(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + return getOperatorAssociativity(expression.kind, operator, hasArguments); + } + ts.getExpressionAssociativity = getExpressionAssociativity; + function getOperatorAssociativity(kind, operator, hasArguments) { + switch (kind) { + case 176: + return hasArguments ? 0 : 1; + case 186: + case 183: + case 184: + case 182: + case 185: + case 189: + case 191: + return 1; + case 188: + switch (operator) { + case 39: + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 1; } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - filesToWatch.push(jsonPath); - 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)); - } + } + return 0; + } + ts.getOperatorAssociativity = getOperatorAssociativity; + function getExpressionPrecedence(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + return getOperatorPrecedence(expression.kind, operator, hasArguments); + } + ts.getExpressionPrecedence = getExpressionPrecedence; + function getOperator(expression) { + if (expression.kind === 188) { + return expression.operatorToken.kind; + } + else if (expression.kind === 186 || expression.kind === 187) { + return expression.operator; + } + else { + return expression.kind; + } + } + ts.getOperator = getOperator; + function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { + switch (nodeKind) { + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: + case 8: + case 9: + case 171: + case 172: + case 180: + case 181: + case 193: + case 242: + case 243: + case 11: + case 12: + case 190: + case 179: + case 194: + return 19; + case 177: + case 173: + case 174: + return 18; + case 176: + return hasArguments ? 18 : 17; + case 175: + return 17; + case 187: + return 16; + case 186: + case 183: + case 184: + case 182: + case 185: + return 15; + case 188: + switch (operatorKind) { + case 50: + case 51: + return 15; + case 39: + case 38: + case 40: + case 41: + return 14; + case 36: + case 37: + return 13; + case 44: + case 45: + case 46: + return 12; + case 26: + case 29: + case 28: + case 30: + case 91: + case 92: + return 11; + case 31: + case 33: + case 32: + case 34: + return 10; + case 47: + return 9; + case 49: + return 8; + case 48: + return 7; + case 52: + return 6; + case 53: + return 5; + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 3; + case 25: + return 0; + default: + return -1; } + case 189: + return 4; + case 191: + return 2; + case 192: + return 1; + default: + return -1; + } + } + ts.getOperatorPrecedence = getOperatorPrecedence; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = ts.createMap(); + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; } - 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"]); - } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; } - 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); - } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; } - mergeTypings(typingNames); } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(server.LogLevel || (server.LogLevel = {})); - var 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; + else { + diagnostics = nonFileDiagnostics; } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; } - function createInstallTypingsRequest(project, typingOptions, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(), - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; } - 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."); + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); } - 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, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: 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]; - } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { + function sortAndDeduplicate() { + if (!diagnosticsModified) { return; } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); } } - 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); + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = ts.createMap({ + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\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)); } - 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 throwLanguageServiceIsDisabledError() { - throw new Error("LanguageService is disabled"); - } - server.nullLanguageService = { - cleanupSemanticCache: throwLanguageServiceIsDisabledError, - getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, - getSemanticDiagnostics: throwLanguageServiceIsDisabledError, - getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, - getSyntacticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, - getSemanticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, - getCompletionsAtPosition: throwLanguageServiceIsDisabledError, - findReferences: throwLanguageServiceIsDisabledError, - getCompletionEntryDetails: throwLanguageServiceIsDisabledError, - getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, - findRenameLocations: throwLanguageServiceIsDisabledError, - getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, - getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, - getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, - getSignatureHelpItems: throwLanguageServiceIsDisabledError, - getDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getRenameInfo: throwLanguageServiceIsDisabledError, - getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getReferencesAtPosition: throwLanguageServiceIsDisabledError, - getDocumentHighlights: throwLanguageServiceIsDisabledError, - getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, - getNavigateToItems: throwLanguageServiceIsDisabledError, - getNavigationBarItems: throwLanguageServiceIsDisabledError, - getNavigationTree: throwLanguageServiceIsDisabledError, - getOutliningSpans: throwLanguageServiceIsDisabledError, - getTodoComments: throwLanguageServiceIsDisabledError, - getIndentationAtPosition: throwLanguageServiceIsDisabledError, - getFormattingEditsForRange: throwLanguageServiceIsDisabledError, - getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, - getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, - getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, - isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, - getEmitOutput: throwLanguageServiceIsDisabledError, - getProgram: throwLanguageServiceIsDisabledError, - getNonBoundSourceFile: throwLanguageServiceIsDisabledError, - dispose: throwLanguageServiceIsDisabledError, - getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, - getImplementationAtPosition: throwLanguageServiceIsDisabledError, - getSourceFile: throwLanguageServiceIsDisabledError, - getCodeFixesAtPosition: throwLanguageServiceIsDisabledError - }; - server.nullLanguageServiceHost = { - setCompilationSettings: function () { return undefined; }, - notifyFileRemoved: function () { return undefined; } - }; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - 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, message) { - host.trace(ts.formatMessage.apply(undefined, arguments)); } - ts.trace = trace; - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; } - ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; } - ts.createResolvedModule = createResolvedModule; - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output; + var indent; + var lineStart; + var lineCount; + var linePos; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; } + output += s; } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; + function reset() { + output = ""; + indent = 0; + lineStart = true; + lineCount = 0; + linePos = 0; } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; } - return undefined; - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } } - catch (e) { - return {}; + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(text, node) { + write(getTextOfNodeFromSourceText(text, node)); } + reset(); + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; }, + isAtStartOfLine: function () { return lineStart; }, + reset: reset + }; } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; + ts.createTextWriter = createTextWriter; + function getResolvedExternalModuleName(host, file) { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + } + ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getExternalModuleNameFromDeclaration(host, resolver, declaration) { + var file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || isDeclarationFile(file)) { + return undefined; } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); + return getResolvedExternalModuleName(host, file); + } + ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; + function getExternalModuleNameFromPath(host, fileName) { + var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; + var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); + return ts.removeFileExtension(relativePath); + } + ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + return emitOutputFilePathWithoutExtension + extension; } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getDeclarationEmitOutputFilePath(sourceFile, host) { + var options = host.getCompilerOptions(); + var outputDir = options.declarationDir || options.outDir; + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; + } + ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; + function getSourceFilesToEmit(host, targetSourceFile) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + var moduleKind = ts.getEmitModuleKind(options); + var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + var sourceFiles = host.getSourceFiles(); + return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_1 = ts.getDirectoryPath(currentDirectory); - if (parent_1 === currentDirectory) { - break; - } - currentDirectory = parent_1; + else { + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, isNonDeclarationFile); } - return typeRoots; } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + ts.getSourceFilesToEmit = getSourceFilesToEmit; + function isNonDeclarationFile(sourceFile) { + return !isDeclarationFile(sourceFile); + } + function isBundleEmitNonExternalModule(sourceFile) { + return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + } + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(sourceFiles); + } + else { + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + onSingleFileEmit(host, sourceFile); } } } - var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; } } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + function onBundledEmit(sourceFiles) { + if (sourceFiles.length) { + var jsFilePath = options.outFile || options.out; + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); } } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } - if (initialLocationForSecondaryLookup !== undefined) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } + } + ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + function getSourceMapFilePath(jsFilePath, options) { + return options.sourceMap ? jsFilePath + ".map" : undefined; + } + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(host); } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + onSingleFileEmit(host, sourceFile); + } } } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; } } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: declarationFilePath + }; + action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); + } + function onBundledEmit(host) { + var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && + !host.isSourceFileFromExternalLibrary(sourceFile) && + (!ts.isExternalModule(sourceFile) || + !!ts.getEmitModuleKind(options)); }); + if (bundledSources.length) { + var jsFilePath = options.outFile || options.out; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined + }; + action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); } } - return result; } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - 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; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + ts.forEachExpectedEmitFile = forEachExpectedEmitFile; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + var commonSourceDirectory = host.getCommonSourceDirectory(); + var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; + sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }, sourceFiles); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getLineOfLocalPositionFromLineMap(lineMap, pos) { + return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; + } + ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 149 && nodeIsPresent(member.body)) { + return member; } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + if (accessor && accessor.parameters.length > 0) { + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); + return accessor.parameters[hasThis ? 1 : 0].type; } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; } } - 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) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 70 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 98; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 150) { + getAccessor = accessor; + } + else if (accessor.kind === 151) { + setAccessor = accessor; } else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + ts.Debug.fail("Accessor has wrong kind"); } } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + ts.forEach(declarations, function (member) { + if ((member.kind === 150 || member.kind === 151) + && hasModifier(member, 32) === hasModifier(accessor, 32)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 150 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 151 && !setAccessor) { + setAccessor = member; + } + } + } + }); } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { + emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { + if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { + writer.writeLine(); } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } + } + ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; + function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { + if (pos !== commentPos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { + writer.writeLine(); } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; + function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { + if (comments && comments.length > 0) { + if (leadingSeparator) { + writer.write(" "); } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; + var emitInterveningSeparator = false; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + if (emitInterveningSeparator) { + writer.write(" "); + emitInterveningSeparator = false; } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; + else { + emitInterveningSeparator = true; } } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + if (emitInterveningSeparator && trailingSeparator) { + writer.write(" "); } } - return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + ts.emitComments = emitComments; + function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); } - matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + else { + leadingComments = ts.getLeadingCommentRanges(text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment = void 0; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); + var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); + emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; + function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (text.charCodeAt(commentPos + 1) === 42) { + var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); + var lineCount = lineMap.length; + var firstCommentLineIndent = void 0; + for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? text.length + 1 + : lineMap[currentLine + 1]; + if (pos !== commentPos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } } + writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); + pos = nextLineStart; } - return undefined; } else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + writer.write(text.substring(commentPos, commentEnd)); + } + } + ts.writeCommentRange = writeCommentRange; + function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { + var end = Math.min(commentEnd, nextLineStart - 1); + var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== commentEnd) { + writer.writeLine(); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + else { + writer.writeLiteral(newLine); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); - isExternalLibraryImport = resolvedFileName !== undefined; + function calculateIndent(text, pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { + if (text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); - } - } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + currentLineIndent++; } } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); + return currentLineIndent; } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + function hasModifiers(node) { + return getModifierFlags(node) !== 0; } - function directoryProbablyExists(directoryName, host) { - return !host.directoryExists || host.directoryExists(directoryName); + ts.hasModifiers = hasModifiers; + function hasModifier(node, flags) { + return (getModifierFlags(node) & flags) !== 0; } - ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; + ts.hasModifier = hasModifier; + function getModifierFlags(node) { + if (node.modifierFlagsCache & 536870912) { + return node.modifierFlagsCache & ~536870912; } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + var flags = 0; + if (node.modifiers) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + flags |= modifierToFlag(modifier.kind); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); } + if (node.flags & 4) { + flags |= 1; + } + node.modifierFlagsCache = flags | 536870912; + return flags; } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } + ts.getModifierFlags = getModifierFlags; + function modifierToFlag(token) { + switch (token) { + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 129: return 64; } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + return 0; } - function tryFile(fileName, failedLookupLocation, 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); - } - return fileName; + ts.modifierToFlag = modifierToFlag; + function isLogicalOperator(token) { + return token === 53 + || token === 52 + || token === 50; + } + ts.isLogicalOperator = isLogicalOperator; + function isAssignmentOperator(token) { + return token >= 57 && token <= 69; + } + ts.isAssignmentOperator = isAssignmentOperator; + function tryGetClassExtendingExpressionWithTypeArguments(node) { + if (node.kind === 195 && + node.parent.token === 84 && + isClassLike(node.parent.parent)) { + return node.parent.parent; } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isDestructuringAssignment(node) { + if (isBinaryExpression(node)) { + if (node.operatorToken.kind === 57) { + var kind = node.left.kind; + return kind === 172 + || kind === 171; } - failedLookupLocation.push(fileName); - return undefined; } + return false; } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } + ts.isDestructuringAssignment = isDestructuringAssignment; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 70) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocation.push(packageJsonPath); + return false; } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isEntityNameExpression(node) { + return node.kind === 70 || + node.kind === 173 && isEntityNameExpression(node.expression); + } + ts.isEntityNameExpression = isEntityNameExpression; + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 140 && node.parent.right === node) || + (node.parent.kind === 173 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 172) { + return expression.properties.length === 0; } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; + if (kind === 171) { + return expression.elements.length === 0; } + return false; } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; - function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function tryExtractTypeScriptExtension(fileName) { + return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - } - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; - } + ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); - } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - return referencedSourceFile; + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - return undefined; + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); } - containingDirectory = parentPath; - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.externalHelpersModuleNameText = "tslib"; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { - var declaration = declarations_1[_i]; - if (declaration.kind === kind) { - return declaration; - } + else { + ts.Debug.assert(false, "Unexpected code point"); } } - return undefined; + return output; } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str_1 = ""; - var writeText = function (text) { return str_1 += text; }; - return { - string: function () { return str_1; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str_1 += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str_1 = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); + ts.stringify = typeof JSON !== "undefined" && JSON.stringify + ? JSON.stringify + : stringifyFallback; + function stringifyFallback(value) { + return value === undefined ? undefined : stringifyValue(value); } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); + function stringifyValue(value) { + return typeof value === "string" ? "\"" + escapeString(value) + "\"" + : typeof value === "number" ? isFinite(value) ? String(value) : "null" + : typeof value === "boolean" ? value ? "true" : "false" + : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) + : "null"; } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; + function cycleCheck(cb, value) { + ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); + value.__cycle = true; + var result = cb(value); + delete value.__cycle; + return result; } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; i++) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; + function stringifyArray(value) { + return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + function stringifyElement(memo, value) { + return (memo ? memo + "," : memo) + stringifyValue(value); } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + function stringifyObject(value) { + return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = ts.createMap(); - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + function stringifyProperty(memo, value, key) { + return value === undefined || typeof value === "function" || key === "__cycle" ? memo + : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); } - ts.setResolvedModule = setResolvedModule; - function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { - if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; - } - ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; - } - ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return result; } - ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { - if (names.length !== newResolutions.length) { - return false; + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0) { + return carriageReturnLineFeed; } - for (var i = 0; i < names.length; i++) { - var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; - var changed = oldResolution - ? !newResolution || !comparer(oldResolution, newResolution) - : newResolution; - if (changed) { - return true; - } + else if (options.newLine === 1) { + return lineFeed; } - return false; - } - ts.hasChangesInResolutions = hasChangesInResolutions; - function containsParseError(node) { - aggregateChildData(node); - return (node.flags & 2097152) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.flags & 4194304)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152; - } - node.flags |= 4194304; + else if (ts.sys) { + return ts.sys.newLine; } + return carriageReturnLineFeed; } - function getSourceFileOfNode(node) { - while (node && node.kind !== 256) { - node = node.parent; - } - return node; + ts.getNewLineCharacter = getNewLineCharacter; + function isSimpleExpression(node) { + return isSimpleExpressionWorker(node, 0); } - ts.getSourceFileOfNode = getSourceFileOfNode; - function isStatementWithLocals(node) { - switch (node.kind) { - case 199: - case 227: - case 206: - case 207: - case 208: + ts.isSimpleExpression = isSimpleExpression; + function isSimpleExpressionWorker(node, depth) { + if (depth <= 5) { + var kind = node.kind; + if (kind === 9 + || kind === 8 + || kind === 11 + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { + return true; + } + else if (kind === 173) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 174) { + return isSimpleExpressionWorker(node.expression, depth + 1) + && isSimpleExpressionWorker(node.argumentExpression, depth + 1); + } + else if (kind === 186 + || kind === 187) { + return isSimpleExpressionWorker(node.operand, depth + 1); + } + else if (kind === 188) { + return node.operatorToken.kind !== 39 + && isSimpleExpressionWorker(node.left, depth + 1) + && isSimpleExpressionWorker(node.right, depth + 1); + } + else if (kind === 189) { + return isSimpleExpressionWorker(node.condition, depth + 1) + && isSimpleExpressionWorker(node.whenTrue, depth + 1) + && isSimpleExpressionWorker(node.whenFalse, depth + 1); + } + else if (kind === 184 + || kind === 183 + || kind === 182) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 171) { + return node.elements.length === 0; + } + else if (kind === 172) { + return node.properties.length === 0; + } + else if (kind === 175) { + if (!isSimpleExpressionWorker(node.expression, depth + 1)) { + return false; + } + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + if (!isSimpleExpressionWorker(argument, depth + 1)) { + return false; + } + } return true; + } } return false; } - ts.isStatementWithLocals = isStatementWithLocals; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = ts.getLineStarts(sourceFile); - var lineIndex = line; - var sourceText = sourceFile.text; - if (lineIndex + 1 === lineStarts.length) { - return sourceText.length - 1; + var syntaxKindCache = ts.createMap(); + function formatSyntaxKind(kind) { + var syntaxKindEnum = ts.SyntaxKind; + if (syntaxKindEnum) { + if (syntaxKindCache[kind]) { + return syntaxKindCache[kind]; + } + for (var name_6 in syntaxKindEnum) { + if (syntaxKindEnum[name_6] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_6 + ")"; + } + } } else { - var start = lineStarts[lineIndex]; - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); - while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { - pos--; - } - return pos; + return kind.toString(); } } - ts.getEndLinePosition = getEndLinePosition; - function nodeIsMissing(node) { - if (node === undefined) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + ts.formatSyntaxKind = formatSyntaxKind; + function movePos(pos, value) { + return ts.positionIsSynthesized(pos) ? -1 : pos + value; } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); + ts.movePos = movePos; + function createRange(pos, end) { + return { pos: pos, end: end }; } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { - if (nodeIsMissing(node)) { - return node.pos; - } - if (isJSDocNode(node)) { - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); - } - if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { - return getTokenPosOfNode(node.jsDocComments[0]); - } - if (node.kind === 286 && node._children.length > 0) { - return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + ts.createRange = createRange; + function moveRangeEnd(range, end) { + return createRange(range.pos, end); } - ts.getTokenPosOfNode = getTokenPosOfNode; - function isJSDocNode(node) { - return node.kind >= 257 && node.kind <= 282; + ts.moveRangeEnd = moveRangeEnd; + function moveRangePos(range, pos) { + return createRange(pos, range.end); } - ts.isJSDocNode = isJSDocNode; - function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; + ts.moveRangePos = moveRangePos; + function moveRangePastDecorators(node) { + return node.decorators && node.decorators.length > 0 + ? moveRangePos(node, node.decorators.end) + : node; } - ts.isJSDocTag = isJSDocTag; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + ts.moveRangePastDecorators = moveRangePastDecorators; + function moveRangePastModifiers(node) { + return node.modifiers && node.modifiers.length > 0 + ? moveRangePos(node, node.modifiers.end) + : moveRangePastDecorators(node); } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + ts.moveRangePastModifiers = moveRangePastModifiers; + function isCollapsedRange(range) { + return range.pos === range.end; } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + ts.isCollapsedRange = isCollapsedRange; + function collapseRangeToStart(range) { + return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + ts.collapseRangeToStart = collapseRangeToStart; + function collapseRangeToEnd(range) { + return isCollapsedRange(range) ? range : moveRangePos(range, range.end); } - ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + ts.collapseRangeToEnd = collapseRangeToEnd; + function createTokenRange(pos, token) { + return createRange(pos, pos + ts.tokenToString(token).length); } - ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; + ts.createTokenRange = createTokenRange; + function rangeIsOnSingleLine(range, sourceFile) { + return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + ts.rangeIsOnSingleLine = rangeIsOnSingleLine; + function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); } - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; + function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, range2.end, sourceFile); } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; + function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); } - ts.unescapeIdentifier = unescapeIdentifier; - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; + function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || - isCatchClauseVariableDeclaration(declaration); + ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; + function positionsAreOnSameLine(pos1, pos2, sourceFile) { + return pos1 === pos2 || + getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function isAmbientModule(node) { - return node && node.kind === 225 && - (node.name.kind === 9 || isGlobalScopeAugmentation(node)); - } - ts.isAmbientModule = isAmbientModule; - function isShorthandAmbientModuleSymbol(moduleSymbol) { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); - } - ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; - function isShorthandAmbientModule(node) { - return node.kind === 225 && (!node.body); + ts.positionsAreOnSameLine = positionsAreOnSameLine; + function getStartPositionOfRange(range, sourceFile) { + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } - function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 225 || - isFunctionLike(node); + ts.getStartPositionOfRange = getStartPositionOfRange; + function collectExternalModuleInfo(sourceFile) { + var externalImports = []; + var exportSpecifiers = ts.createMap(); + var exportEquals = undefined; + var hasExportStarsToExportValues = false; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 231: + externalImports.push(node); + break; + case 230: + if (node.moduleReference.kind === 241) { + externalImports.push(node); + } + break; + case 237: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStarsToExportValues = true; + } + else { + externalImports.push(node); + } + } + else { + for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { + var specifier = _c[_b]; + var name_7 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_7] || (exportSpecifiers[name_7] = [])).push(specifier); + } + } + break; + case 236: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; } - ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; - function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); + ts.collectExternalModuleInfo = collectExternalModuleInfo; + function getInitializedVariables(node) { + return ts.filter(node.declarations, isInitializedVariable); } - ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; - function isExternalModuleAugmentation(node) { - if (!node || !isAmbientModule(node)) { - return false; - } - switch (node.parent.kind) { - case 256: - return ts.isExternalModule(node.parent); - case 226: - return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); - } - return false; + ts.getInitializedVariables = getInitializedVariables; + function isInitializedVariable(node) { + return node.initializer !== undefined; } - ts.isExternalModuleAugmentation = isExternalModuleAugmentation; - function isBlockScope(node, parentNode) { - switch (node.kind) { - case 256: - case 227: - case 252: - case 225: - case 206: - case 207: - case 208: - case 148: - case 147: - case 149: - case 150: - case 220: - case 179: - case 180: - return true; - case 199: - return parentNode && !isFunctionLike(parentNode); + function isMergedWithClass(node) { + if (node.symbol) { + for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 222 && declaration !== node) { + return true; + } + } } return false; } - ts.isBlockScope = isBlockScope; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isBlockScope(current, current.parent)) { - return current; - } - current = current.parent; - } + ts.isMergedWithClass = isMergedWithClass; + function isFirstDeclarationOfKind(node, kind) { + return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 218 && - declaration.parent && - declaration.parent.kind === 252; + ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; + function isNodeArray(array) { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + ts.isNodeArray = isNodeArray; + function isNoSubstitutionTemplateLiteral(node) { + return node.kind === 12; } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 12; } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 12; } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + ts.isTextualLiteralKind = isTextualLiteralKind; + function isLiteralExpression(node) { + return isLiteralKind(node.kind); } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForArrowFunction(sourceFile, node) { - var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199) { - var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; - if (startLine < endLine) { - return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); - } - } - return ts.createTextSpanFromBounds(pos, node.end); + ts.isLiteralExpression = isLiteralExpression; + function isTemplateLiteralKind(kind) { + return 12 <= kind && kind <= 15; } - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 256: - 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 218: - case 169: - case 221: - case 192: - case 222: - case 225: - case 224: - case 255: - case 220: - case 179: - case 147: - case 149: - case 150: - case 223: - errorNode = node.name; - break; - case 180: - return getErrorSpanForArrowFunction(sourceFile, node); - } - if (errorNode === undefined) { - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateHead(node) { + return node.kind === 13; } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalOrCommonJsModule(file) { - return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 14 + || kind === 15; } - ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; - function isDeclarationFile(file) { - return file.isDeclarationFile; + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; + function isIdentifier(node) { + return node.kind === 70; } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 224 && isConst(node); + ts.isIdentifier = isIdentifier; + function isGeneratedIdentifier(node) { + return isIdentifier(node) && node.autoGenerateKind > 0; } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); + ts.isGeneratedIdentifier = isGeneratedIdentifier; + function isModifier(node) { + return isModifierKind(node.kind); } - ts.isConst = isConst; - function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1); + ts.isModifier = isModifier; + function isQualifiedName(node) { + return node.kind === 140; } - ts.isLet = isLet; - function isSuperCall(n) { - return n.kind === 174 && n.expression.kind === 95; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 141; } - ts.isSuperCall = isSuperCall; - function isPrologueDirective(node) { - return node.kind === 202 && node.expression.kind === 9; + ts.isComputedPropertyName = isComputedPropertyName; + function isEntityName(node) { + var kind = node.kind; + return kind === 140 + || kind === 70; } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + ts.isEntityName = isEntityName; + function isPropertyName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9 + || kind === 8 + || kind === 141; } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); + ts.isPropertyName = isPropertyName; + function isModuleName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9; } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; - function getJsDocComments(node, sourceFileOfNode) { - return getJsDocCommentsFromText(node, sourceFileOfNode.text); + ts.isModuleName = isModuleName; + function isBindingName(node) { + var kind = node.kind; + return kind === 70 + || kind === 168 + || kind === 169; } - ts.getJsDocComments = getJsDocComments; - function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 || - node.kind === 141 || - node.kind === 179 || - node.kind === 180) ? - ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 42 && - text.charCodeAt(comment.pos + 3) !== 47; - } + ts.isBindingName = isBindingName; + function isTypeParameter(node) { + return node.kind === 142; } - ts.getJsDocCommentsFromText = getJsDocCommentsFromText; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isPartOfTypeNode(node) { - if (154 <= node.kind && node.kind <= 166) { - return true; - } - switch (node.kind) { - case 117: - case 130: - case 132: - case 120: - case 133: - case 135: - case 127: - return true; - case 103: - return node.parent.kind !== 183; - case 194: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 139 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 172 && node.parent.name === node) { - node = node.parent; - } - ts.Debug.assert(node.kind === 69 || node.kind === 139 || node.kind === 172, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139: - case 172: - case 97: - var parent_2 = node.parent; - if (parent_2.kind === 158) { - return false; - } - if (154 <= parent_2.kind && parent_2.kind <= 166) { - return true; - } - switch (parent_2.kind) { - case 194: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 141: - return node === parent_2.constraint; - case 145: - case 144: - case 142: - case 218: - return node === parent_2.type; - case 220: - case 179: - case 180: - case 148: - case 147: - case 146: - case 149: - case 150: - return node === parent_2.type; - case 151: - case 152: - case 153: - return node === parent_2.type; - case 177: - return node === parent_2.type; - case 174: - case 175: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; - case 176: - return false; - } - } - return false; + ts.isTypeParameter = isTypeParameter; + function isParameter(node) { + return node.kind === 143; } - ts.isPartOfTypeNode = isPartOfTypeNode; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 211: - return visitor(node); - case 227: - case 199: - case 203: - case 204: - case 205: - case 206: - case 207: - case 208: - case 212: - case 213: - case 249: - case 250: - case 214: - case 216: - case 252: - return ts.forEachChild(node, traverse); - } - } + ts.isParameter = isParameter; + function isDecorator(node) { + return node.kind === 144; } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 190: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 224: - case 222: - case 225: - case 223: - case 221: - case 192: - return; - default: - if (isFunctionLike(node)) { - var name_8 = node.name; - if (name_8 && name_8.kind === 140) { - traverse(name_8.expression); - return; - } - } - else if (!isPartOfTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } + ts.isDecorator = isDecorator; + function isMethodDeclaration(node) { + return node.kind === 148; } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 169: - case 255: - case 142: - case 253: - case 145: - case 144: - case 254: - case 218: - return true; - } - } - return false; + ts.isMethodDeclaration = isMethodDeclaration; + function isClassElement(node) { + var kind = node.kind; + return kind === 149 + || kind === 146 + || kind === 148 + || kind === 150 + || kind === 151 + || kind === 154 + || kind === 199; } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 149 || node.kind === 150); + ts.isClassElement = isClassElement; + function isObjectLiteralElementLike(node) { + var kind = node.kind; + return kind === 253 + || kind === 254 + || kind === 148 + || kind === 150 + || kind === 151 + || kind === 240; } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 221 || node.kind === 192); + ts.isObjectLiteralElementLike = isObjectLiteralElementLike; + function isTypeNodeKind(kind) { + return (kind >= 155 && kind <= 167) + || kind === 118 + || kind === 131 + || kind === 121 + || kind === 133 + || kind === 134 + || kind === 104 + || kind === 128 + || kind === 195; } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + function isTypeNode(node) { + return isTypeNodeKind(node.kind); } - ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { - switch (kind) { - case 148: - case 179: - case 220: - case 180: - case 147: - case 146: - case 149: - case 150: - case 151: - case 152: - case 153: - case 156: - case 157: - return true; + ts.isTypeNode = isTypeNode; + function isBindingPattern(node) { + if (node) { + var kind = node.kind; + return kind === 169 + || kind === 168; } return false; } - ts.isFunctionLikeKind = isFunctionLikeKind; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 147: - case 146: - case 148: - case 149: - case 150: - case 220: - case 179: - return true; - } - return false; + ts.isBindingPattern = isBindingPattern; + function isBindingElement(node) { + return node.kind === 170; } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 206: - case 207: - case 208: - case 204: - case 205: - return true; - case 214: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; + ts.isBindingElement = isBindingElement; + function isArrayBindingElement(node) { + var kind = node.kind; + return kind === 170 + || kind === 194; } - ts.isIterationStatement = isIterationStatement; - function isFunctionBlock(node) { - return node && node.kind === 199 && isFunctionLike(node.parent); + ts.isArrayBindingElement = isArrayBindingElement; + function isPropertyAccessExpression(node) { + return node.kind === 173; } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 147 && node.parent.kind === 171; + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 174; } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 && - (node.parent.kind === 171 || - node.parent.kind === 192); + ts.isElementAccessExpression = isElementAccessExpression; + function isBinaryExpression(node) { + return node.kind === 188; } - ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; - function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1; + ts.isBinaryExpression = isBinaryExpression; + function isConditionalExpression(node) { + return node.kind === 189; } - ts.isIdentifierTypePredicate = isIdentifierTypePredicate; - function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0; - } - ts.isThisTypePredicate = isThisTypePredicate; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 140: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 180: - if (!includeArrowFunctions) { - continue; - } - case 220: - case 179: - case 225: - case 145: - case 144: - case 147: - case 146: - case 148: - case 149: - case 150: - case 151: - case 152: - case 153: - case 224: - case 256: - return node; - } - } + ts.isConditionalExpression = isConditionalExpression; + function isCallExpression(node) { + return node.kind === 175; } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, stopOnFunctions) { - while (true) { - node = node.parent; - if (!node) { - return node; - } - switch (node.kind) { - case 140: - node = node.parent; - break; - case 220: - case 179: - case 180: - if (!stopOnFunctions) { - continue; - } - case 145: - case 144: - case 147: - case 146: - case 148: - case 149: - case 150: - return node; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - } - } + ts.isCallExpression = isCallExpression; + function isTemplateLiteral(node) { + var kind = node.kind; + return kind === 190 + || kind === 12; } - ts.getSuperContainer = getSuperContainer; - function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 || func.kind === 180) { - var prev = func; - var parent_3 = func.parent; - while (parent_3.kind === 178) { - prev = parent_3; - parent_3 = parent_3.parent; - } - if (parent_3.kind === 174 && parent_3.expression === prev) { - return parent_3; - } - } + ts.isTemplateLiteral = isTemplateLiteral; + function isSpreadElementExpression(node) { + return node.kind === 192; } - ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; - function isSuperProperty(node) { - var kind = node.kind; - return (kind === 172 || kind === 173) - && node.expression.kind === 95; + ts.isSpreadElementExpression = isSpreadElementExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 195; } - ts.isSuperProperty = isSuperProperty; - function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 155: - return node.typeName; - case 194: - ts.Debug.assert(isEntityNameExpression(node.expression)); - return node.expression; - case 69: - case 139: - return node; - } - } - return undefined; + ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; + function isLeftHandSideExpressionKind(kind) { + return kind === 173 + || kind === 174 + || kind === 176 + || kind === 175 + || kind === 242 + || kind === 243 + || kind === 177 + || kind === 171 + || kind === 179 + || kind === 172 + || kind === 193 + || kind === 180 + || kind === 70 + || kind === 11 + || kind === 8 + || kind === 9 + || kind === 12 + || kind === 190 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 197; } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function isCallLikeExpression(node) { - switch (node.kind) { - case 174: - case 175: - case 176: - case 143: - return true; - default: - return false; - } + function isLeftHandSideExpression(node) { + return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } - ts.isCallLikeExpression = isCallLikeExpression; - function getInvokedExpression(node) { - if (node.kind === 176) { - return node.tag; - } - return node.expression; + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isUnaryExpressionKind(kind) { + return kind === 186 + || kind === 187 + || kind === 182 + || kind === 183 + || kind === 184 + || kind === 185 + || kind === 178 + || isLeftHandSideExpressionKind(kind); } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 221: - return true; - case 145: - return node.parent.kind === 221; - case 149: - case 150: - case 147: - return node.body !== undefined - && node.parent.kind === 221; - case 142: - return node.parent.body !== undefined - && (node.parent.kind === 148 - || node.parent.kind === 147 - || node.parent.kind === 150) - && node.parent.parent.kind === 221; - } - return false; + function isUnaryExpression(node) { + return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - return node.decorators !== undefined - && nodeCanBeDecorated(node); + ts.isUnaryExpression = isUnaryExpression; + function isExpressionKind(kind) { + return kind === 189 + || kind === 191 + || kind === 181 + || kind === 188 + || kind === 192 + || kind === 196 + || kind === 194 + || isUnaryExpressionKind(kind); } - ts.nodeIsDecorated = nodeIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); + function isExpression(node) { + return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 221: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147: - case 150: - return ts.forEach(node.parameters, nodeIsDecorated); - } + ts.isExpression = isExpression; + function isAssertionExpression(node) { + var kind = node.kind; + return kind === 178 + || kind === 196; } - ts.childIsDecorated = childIsDecorated; - function isJSXTagName(node) { - var parent = node.parent; - if (parent.kind === 243 || - parent.kind === 242 || - parent.kind === 245) { - return parent.tagName === node; - } - return false; + ts.isAssertionExpression = isAssertionExpression; + function isPartiallyEmittedExpression(node) { + return node.kind === 288; } - ts.isJSXTagName = isJSXTagName; - function isPartOfExpression(node) { - switch (node.kind) { - case 97: - case 95: - case 93: - case 99: - case 84: - case 10: - case 170: - case 171: - case 172: - case 173: - case 174: - case 175: - case 176: - case 195: - case 177: - case 196: - case 178: - case 179: - case 192: - case 180: - case 183: - case 181: - case 182: - case 185: - case 186: - case 187: - case 188: - case 191: - case 189: - case 11: - case 193: - case 241: - case 242: - case 190: - case 184: - return true; - case 139: - while (node.parent.kind === 139) { - node = node.parent; - } - return node.parent.kind === 158 || isJSXTagName(node); - case 69: - if (node.parent.kind === 158 || isJSXTagName(node)) { - return true; - } - case 8: - case 9: - case 97: - var parent_4 = node.parent; - switch (parent_4.kind) { - case 218: - case 142: - case 145: - case 144: - case 255: - case 253: - case 169: - return parent_4.initializer === node; - case 202: - case 203: - case 204: - case 205: - case 211: - case 212: - case 213: - case 249: - case 215: - case 213: - return parent_4.expression === node; - case 206: - var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || - forStatement.condition === node || - forStatement.incrementor === node; - case 207: - case 208: - var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || - forInStatement.expression === node; - case 177: - case 195: - return node === parent_4.expression; - case 197: - return node === parent_4.expression; - case 140: - return node === parent_4.expression; - case 143: - case 248: - case 247: - return true; - case 194: - return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); - default: - if (isPartOfExpression(parent_4)) { - return true; - } - } - } - return false; + ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; + function isNotEmittedStatement(node) { + return node.kind === 287; } - ts.isPartOfExpression = isPartOfExpression; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); + ts.isNotEmittedStatement = isNotEmittedStatement; + function isNotEmittedOrPartiallyEmittedNode(node) { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind === 240; + ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; + function isOmittedExpression(node) { + return node.kind === 194; } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; + ts.isOmittedExpression = isOmittedExpression; + function isTemplateSpan(node) { + return node.kind === 198; } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind !== 240; + ts.isTemplateSpan = isTemplateSpan; + function isBlock(node) { + return node.kind === 200; } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function isSourceFileJavaScript(file) { - return isInJavaScriptFile(file); + ts.isBlock = isBlock; + function isConciseBody(node) { + return isBlock(node) + || isExpression(node); } - ts.isSourceFileJavaScript = isSourceFileJavaScript; - function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576); + ts.isConciseBody = isConciseBody; + function isFunctionBody(node) { + return isBlock(node); } - ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 174 && - expression.expression.kind === 69 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + ts.isFunctionBody = isFunctionBody; + function isForInitializer(node) { + return isVariableDeclarationList(node) + || isExpression(node); } - ts.isRequireCall = isRequireCall; - function isSingleOrDoubleQuote(charCode) { - return charCode === 39 || charCode === 34; + ts.isForInitializer = isForInitializer; + function isVariableDeclaration(node) { + return node.kind === 219; } - ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218) { - var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179; - } - return false; + ts.isVariableDeclaration = isVariableDeclaration; + function isVariableDeclarationList(node) { + return node.kind === 220; } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; - function getSpecialPropertyAssignmentKind(expression) { - if (!isInJavaScriptFile(expression)) { - return 0; - } - if (expression.kind !== 187) { - return 0; - } - var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 172) { - return 0; - } - var lhs = expr.left; - if (lhs.expression.kind === 69) { - var lhsId = lhs.expression; - if (lhsId.text === "exports") { - return 1; - } - else if (lhsId.text === "module" && lhs.name.text === "exports") { - return 2; - } - } - else if (lhs.expression.kind === 97) { - return 4; - } - else if (lhs.expression.kind === 172) { - var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69) { - var innerPropertyAccessIdentifier = innerPropertyAccess.expression; - if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { - return 1; - } - if (innerPropertyAccess.name.text === "prototype") { - return 3; - } - } - } - return 0; + ts.isVariableDeclarationList = isVariableDeclarationList; + function isCaseBlock(node) { + return node.kind === 228; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; - function getExternalModuleName(node) { - if (node.kind === 230) { - return node.moduleSpecifier; - } - if (node.kind === 229) { - var reference = node.moduleReference; - if (reference.kind === 240) { - return reference.expression; - } - } - if (node.kind === 236) { - return node.moduleSpecifier; - } - if (node.kind === 225 && node.name.kind === 9) { - return node.name; - } + ts.isCaseBlock = isCaseBlock; + function isModuleBody(node) { + var kind = node.kind; + return kind === 227 + || kind === 226; } - ts.getExternalModuleName = getExternalModuleName; - function getNamespaceDeclarationNode(node) { - if (node.kind === 229) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232) { - return importClause.namedBindings; - } + ts.isModuleBody = isModuleBody; + function isImportEqualsDeclaration(node) { + return node.kind === 230; } - ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; - function isDefaultImport(node) { - return node.kind === 230 - && node.importClause - && !!node.importClause.name; + ts.isImportEqualsDeclaration = isImportEqualsDeclaration; + function isImportClause(node) { + return node.kind === 232; } - ts.isDefaultImport = isDefaultImport; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 142: - case 147: - case 146: - case 254: - case 253: - case 145: - case 144: - return node.questionToken !== undefined; - } - } - return false; + ts.isImportClause = isImportClause; + function isNamedImportBindings(node) { + var kind = node.kind; + return kind === 234 + || kind === 233; } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 269 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 271; + ts.isNamedImportBindings = isNamedImportBindings; + function isImportSpecifier(node) { + return node.kind === 235; } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind, checkParentVariableStatement) { - if (!node) { - return undefined; - } - var jsDocTags = getJSDocTags(node, checkParentVariableStatement); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { - var tag = jsDocTags_1[_i]; - if (tag.kind === kind) { - return tag; - } - } + ts.isImportSpecifier = isImportSpecifier; + function isNamedExports(node) { + return node.kind === 238; } - function append(previous, additional) { - if (additional) { - if (!previous) { - previous = []; - } - for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { - var x = additional_1[_i]; - previous.push(x); - } - } - return previous; + ts.isNamedExports = isNamedExports; + function isExportSpecifier(node) { + return node.kind === 239; } - function getJSDocComments(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); + ts.isExportSpecifier = isExportSpecifier; + function isModuleOrEnumDeclaration(node) { + return node.kind === 226 || node.kind === 225; } - ts.getJSDocComments = getJSDocComments; - function getJSDocTags(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { - var result = []; - for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { - var doc = docs_1[_i]; - if (doc.tags) { - result.push.apply(result, doc.tags); - } - } - return result; - }, function (tags) { return tags; }); - } - function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { - var result = undefined; - if (checkParentVariableStatement) { - var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && - (node.parent).initializer === node && - node.parent.parent.parent.kind === 200; - var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200; - var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : - isVariableOfVariableDeclarationStatement ? node.parent.parent : - undefined; - if (variableStatementNode) { - result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); - } - if (node.kind === 225 && - node.parent && node.parent.kind === 225) { - result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); - } - var parent_5 = node.parent; - var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && - parent_5.kind === 187 && - parent_5.operatorToken.kind === 56 && - parent_5.parent.kind === 202; - if (isSourceOfAssignmentExpressionStatement) { - result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); - } - var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; - if (isPropertyAssignmentExpression) { - result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); - } - if (node.kind === 142) { - var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); - if (paramTags) { - result = append(result, getTags(paramTags)); - } - } - } - if (isVariableLike(node) && node.initializer) { - result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); - } - if (node.jsDocComments) { - if (result) { - result = append(result, getDocs(node.jsDocComments)); - } - else { - return getDocs(node.jsDocComments); - } - } - return result; + ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; + function isDeclarationKind(kind) { + return kind === 181 + || kind === 170 + || kind === 222 + || kind === 193 + || kind === 149 + || kind === 225 + || kind === 255 + || kind === 239 + || kind === 221 + || kind === 180 + || kind === 150 + || kind === 232 + || kind === 230 + || kind === 235 + || kind === 223 + || kind === 148 + || kind === 147 + || kind === 226 + || kind === 229 + || kind === 233 + || kind === 143 + || kind === 253 + || kind === 146 + || kind === 145 + || kind === 151 + || kind === 254 + || kind === 224 + || kind === 142 + || kind === 219 + || kind === 279; } - function getJSDocParameterTag(param, checkParentVariableStatement) { - var func = param.parent; - var tags = getJSDocTags(func, checkParentVariableStatement); - if (!param.name) { - var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275; }); - if (paramTags && 0 <= i && i < paramTags.length) { - return [paramTags[i]]; - } - } - else if (param.name.kind === 69) { - var name_9 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); - if (paramTags) { - return paramTags; - } - } - else { - return undefined; - } + function isDeclarationStatementKind(kind) { + return kind === 221 + || kind === 240 + || kind === 222 + || kind === 223 + || kind === 224 + || kind === 225 + || kind === 226 + || kind === 231 + || kind === 230 + || kind === 237 + || kind === 236 + || kind === 229; } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); + function isStatementKindButNotDeclarationKind(kind) { + return kind === 211 + || kind === 210 + || kind === 218 + || kind === 205 + || kind === 203 + || kind === 202 + || kind === 208 + || kind === 209 + || kind === 207 + || kind === 204 + || kind === 215 + || kind === 212 + || kind === 214 + || kind === 216 + || kind === 217 + || kind === 201 + || kind === 206 + || kind === 213 + || kind === 287; } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); + function isDeclaration(node) { + return isDeclarationKind(node.kind); } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); + ts.isDeclaration = isDeclaration; + function isDeclarationStatement(node) { + return isDeclarationStatementKind(node.kind); } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { - var parameterName = parameter.name.text; - var jsDocTags = getJSDocTags(parameter.parent, true); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { - var tag = jsDocTags_2[_i]; - if (tag.kind === 275) { - var parameterTag = tag; - if (parameterTag.parameterName.text === parameterName) { - return parameterTag; - } - } - } - } - return undefined; + ts.isDeclarationStatement = isDeclarationStatement; + function isStatementButNotDeclaration(node) { + return isStatementKindButNotDeclarationKind(node.kind); } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); + ts.isStatementButNotDeclaration = isStatementButNotDeclaration; + function isStatement(node) { + var kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === 200; } - ts.hasRestParameter = hasRestParameter; - function hasDeclaredRestParameter(s) { - return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); + ts.isStatement = isStatement; + function isModuleReference(node) { + var kind = node.kind; + return kind === 241 + || kind === 140 + || kind === 70; } - ts.hasDeclaredRestParameter = hasDeclaredRestParameter; - function isRestParameter(node) { - if (node && (node.flags & 1048576)) { - if (node.type && node.type.kind === 270) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; - } - } - return isDeclaredRestParam(node); + ts.isModuleReference = isModuleReference; + function isJsxOpeningElement(node) { + return node.kind === 244; } - ts.isRestParameter = isRestParameter; - function isDeclaredRestParam(node) { - return node && node.dotDotDotToken !== undefined; + ts.isJsxOpeningElement = isJsxOpeningElement; + function isJsxClosingElement(node) { + return node.kind === 245; } - ts.isDeclaredRestParam = isDeclaredRestParam; - function isAssignmentTarget(node) { - while (node.parent.kind === 178) { - node = node.parent; - } - while (true) { - var parent_6 = node.parent; - if (parent_6.kind === 170 || parent_6.kind === 191) { - node = parent_6; - continue; - } - if (parent_6.kind === 253 || parent_6.kind === 254) { - node = parent_6.parent; - continue; - } - return parent_6.kind === 187 && - isAssignmentOperator(parent_6.operatorToken.kind) && - parent_6.left === node || - (parent_6.kind === 207 || parent_6.kind === 208) && - parent_6.initializer === node; - } + ts.isJsxClosingElement = isJsxClosingElement; + function isJsxTagNameExpression(node) { + var kind = node.kind; + return kind === 98 + || kind === 70 + || kind === 173; } - ts.isAssignmentTarget = isAssignmentTarget; - function isNodeDescendantOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; + ts.isJsxTagNameExpression = isJsxTagNameExpression; + function isJsxChild(node) { + var kind = node.kind; + return kind === 242 + || kind === 248 + || kind === 243 + || kind === 10; } - ts.isNodeDescendantOf = isNodeDescendantOf; - function isInAmbientContext(node) { - while (node) { - if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { - return true; - } - node = node.parent; - } - return false; + ts.isJsxChild = isJsxChild; + function isJsxAttributeLike(node) { + var kind = node.kind; + return kind === 246 + || kind === 247; } - ts.isInAmbientContext = isInAmbientContext; - function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 234 || parent.kind === 238) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; + ts.isJsxAttributeLike = isJsxAttributeLike; + function isJsxSpreadAttribute(node) { + return node.kind === 247; } - ts.isDeclarationName = isDeclarationName; - function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 140 && - isDeclaration(node.parent.parent); + ts.isJsxSpreadAttribute = isJsxSpreadAttribute; + function isJsxAttribute(node) { + return node.kind === 246; } - ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 145: - case 144: - case 147: - case 146: - case 149: - case 150: - case 255: - case 253: - case 172: - return parent.name === node; - case 139: - if (parent.right === node) { - while (parent.kind === 139) { - parent = parent.parent; - } - return parent.kind === 158; - } - return false; - case 169: - case 234: - return parent.propertyName === node; - case 238: - return true; - } - return false; + ts.isJsxAttribute = isJsxAttribute; + function isStringLiteralOrJsxExpression(node) { + var kind = node.kind; + return kind === 9 + || kind === 248; } - ts.isIdentifierName = isIdentifierName; - function isAliasSymbolDeclaration(node) { - return node.kind === 229 || - node.kind === 228 || - node.kind === 231 && !!node.name || - node.kind === 232 || - node.kind === 234 || - node.kind === 238 || - node.kind === 235 && exportAssignmentIsAlias(node); + ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isCaseOrDefaultClause(node) { + var kind = node.kind; + return kind === 249 + || kind === 250; } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - return isEntityNameExpression(node.expression); + ts.isCaseOrDefaultClause = isCaseOrDefaultClause; + function isHeritageClause(node) { + return node.kind === 251; } - ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + ts.isHeritageClause = isHeritageClause; + function isCatchClause(node) { + return node.kind === 252; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); - return heritageClause ? heritageClause.types : undefined; + ts.isCatchClause = isCatchClause; + function isPropertyAssignment(node) { + return node.kind === 253; } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause ? heritageClause.types : undefined; + ts.isPropertyAssignment = isPropertyAssignment; + function isShorthandPropertyAssignment(node) { + return node.kind === 254; } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { - var clause = clauses_1[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; + ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; + function isEnumMember(node) { + return node.kind === 255; } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - return host.getSourceFile(referenceFileName); - } + ts.isEnumMember = isEnumMember; + function isSourceFile(node) { + return node.kind === 256; } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; + ts.isSourceFile = isSourceFile; + function isWatchSet(options) { + return options.watch && options.hasOwnProperty("watch"); } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.test(comment)) { - if (isNoDefaultLibRegEx.test(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); - if (refMatchResult || refLibResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: (refMatchResult || refLibResult)[3] - }, - isNoDefaultLib: false, - isTypeReferenceDirective: !!refLibResult - }; - } - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } + ts.isWatchSet = isWatchSet; +})(ts || (ts = {})); +(function (ts) { + function getDefaultLibFileName(options) { + switch (options.target) { + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 70 <= token && token <= 138; } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function isStringOrNumericLiteral(kind) { - return kind === 9 || kind === 8; + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; } - ts.isStringOrNumericLiteral = isStringOrNumericLiteral; - function hasDynamicName(declaration) { - return declaration.name && isDynamicName(declaration.name); + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); } - ts.hasDynamicName = hasDynamicName; - function isDynamicName(name) { - return name.kind === 140 && - !isStringOrNumericLiteral(name.expression.kind) && - !isWellKnownSymbolSyntactically(name.expression); + ts.textSpanContainsPosition = textSpanContainsPosition; + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); } - ts.isDynamicName = isDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) { - return name.text; - } - if (name.kind === 140) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - else if (nameExpression.kind === 9 || nameExpression.kind === 8) { - return nameExpression.text; - } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); } return undefined; } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isModifierKind(token) { - switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 128: - case 113: - return true; - } - return false; + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; } - ts.isModifierKind = isModifierKind; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 142; + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 169) { - node = node.parent.parent; + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); } - return node; + return undefined; } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(node) { - var kind = node.kind; - return kind === 148 - || kind === 179 - || kind === 220 - || kind === 180 - || kind === 147 - || kind === 149 - || kind === 150 - || kind === 225 - || kind === 256; + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); } - ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } - } - return node; + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; } - return undefined; + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); } - ts.getParseTreeNode = getParseTreeNode; - function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 142) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { + return current; + } } } - return originalSourceFiles; - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; - function getOriginalNodeId(node) { - node = getOriginalNode(node); - return node ? ts.getNodeId(node) : 0; } - ts.getOriginalNodeId = getOriginalNodeId; - function getExpressionAssociativity(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; - return getOperatorAssociativity(expression.kind, operator, hasArguments); + ts.getTypeParameterOwner = getTypeParameterOwner; + function isParameterPropertyDeclaration(node) { + return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); } - ts.getExpressionAssociativity = getExpressionAssociativity; - function getOperatorAssociativity(kind, operator, hasArguments) { - switch (kind) { - case 175: - return hasArguments ? 0 : 1; - case 185: - case 182: - case 183: - case 181: - case 184: - case 188: - case 190: - return 1; - case 187: - switch (operator) { - case 38: - case 56: - case 57: - case 58: - case 60: - case 59: - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - case 68: - case 67: - return 1; - } + ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 170 || ts.isBindingPattern(node))) { + node = node.parent; } - return 0; - } - ts.getOperatorAssociativity = getOperatorAssociativity; - function getExpressionPrecedence(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; - return getOperatorPrecedence(expression.kind, operator, hasArguments); + return node; } - ts.getExpressionPrecedence = getExpressionPrecedence; - function getOperator(expression) { - if (expression.kind === 187) { - return expression.operatorToken.kind; + function getCombinedModifierFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = ts.getModifierFlags(node); + if (node.kind === 219) { + node = node.parent; } - else if (expression.kind === 185 || expression.kind === 186) { - return expression.operator; + if (node && node.kind === 220) { + flags |= ts.getModifierFlags(node); + node = node.parent; } - else { - return expression.kind; + if (node && node.kind === 201) { + flags |= ts.getModifierFlags(node); } + return flags; } - ts.getOperator = getOperator; - function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { - switch (nodeKind) { - case 97: - case 95: - case 69: - case 93: - case 99: - case 84: - case 8: - case 9: - case 170: - case 171: - case 179: - case 180: - case 192: - case 241: - case 242: - case 10: - case 11: - case 189: - case 178: - case 193: - return 19; - case 176: - case 172: - case 173: - return 18; - case 175: - return hasArguments ? 18 : 17; - case 174: - return 17; - case 186: - return 16; - case 185: - case 182: - case 183: - case 181: - case 184: - return 15; - case 187: - switch (operatorKind) { - case 49: - case 50: - return 15; - case 38: - case 37: - case 39: - case 40: - return 14; - case 35: - case 36: - return 13; - case 43: - case 44: - case 45: - return 12; - case 25: - case 28: - case 27: - case 29: - case 90: - case 91: - return 11; - case 30: - case 32: - case 31: - case 33: - return 10; - case 46: - return 9; - case 48: - return 8; - case 47: - return 7; - case 51: - return 6; - case 52: - return 5; - case 56: - case 57: - case 58: - case 60: - case 59: - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - case 68: - case 67: - return 3; - case 24: - return 0; - default: - return -1; - } - case 188: - return 4; - case 190: - return 2; - case 191: - return 1; - default: - return -1; + ts.getCombinedModifierFlags = getCombinedModifierFlags; + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 219) { + node = node.parent; } + if (node && node.kind === 220) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 201) { + flags |= node.flags; + } + return flags; } - ts.getOperatorPrecedence = getOperatorPrecedence; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = ts.createMap(); - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; + ts.getCombinedNodeFlags = getCombinedNodeFlags; +})(ts || (ts = {})); +var ts; +(function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 70; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = ts.createMap({ + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, + }); + var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + function lookupInUnicodeMap(code, map) { + if (code < map[0]) { + return false; } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; + var lo = 0; + var hi = map.length; + var mid; + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } + if (code < map[mid]) { + hi = mid; } else { - diagnostics = nonFileDiagnostics; + lo = mid + 2; } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + return false; + } + function isUnicodeIdentifierStart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); + } + ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; + function isUnicodeIdentifierPart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); + } + function makeReverseMap(source) { + var result = []; + for (var name_8 in source) { + result[source[name_8]] = name_8; } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + return result; + } + var tokenStrings = makeReverseMap(textToToken); + function tokenToString(t) { + return tokenStrings[t]; + } + ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; + function computeLineStarts(text) { + var result = new Array(); + var pos = 0; + var lineStart = 0; + while (pos < text.length) { + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 13: + if (text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > 127 && isLineBreak(ch)) { + result.push(lineStart); + lineStart = pos; + } + break; } } + result.push(lineStart); + return result; } - ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\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)); + ts.computeLineStarts = computeLineStarts; + function getPositionOfLineAndCharacter(sourceFile, line, character) { + return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); + } + ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; + function computePositionOfLineAndCharacter(lineStarts, line, character) { + ts.Debug.assert(line >= 0 && line < lineStarts.length); + return lineStarts[line] + character; + } + ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; + function getLineStarts(sourceFile) { + return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); + } + ts.getLineStarts = getLineStarts; + function computeLineAndCharacterOfPosition(lineStarts, position) { + var lineNumber = ts.binarySearch(lineStarts, position); + if (lineNumber < 0) { + lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } + return { + line: lineNumber, + character: position - lineStarts[lineNumber] + }; } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; + ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; + function getLineAndCharacterOfPosition(sourceFile, position) { + return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; + ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function isWhiteSpace(ch) { + return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; + ts.isWhiteSpace = isWhiteSpace; + function isWhiteSpaceSingleLine(ch) { + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; + ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; + function isLineBreak(ch) { + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; + ts.isLineBreak = isLineBreak; + function isDigit(ch) { + return ch >= 48 && ch <= 57; } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output; - var indent; - var lineStart; - var lineCount; - var linePos; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function reset() { - output = ""; - indent = 0; - lineStart = true; - lineCount = 0; - linePos = 0; + function isOctalDigit(ch) { + return ch >= 48 && ch <= 55; + } + ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + case 35: + return pos === 0; + default: + return ch > 127; } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; + } + ts.couldStartTrivia = couldStartTrivia; + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { + if (stopAtComments === void 0) { stopAtComments = false; } + if (ts.positionIsSynthesized(pos)) { + return pos; + } + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + if (stopAtComments) { + break; + } + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; + case 60: + case 61: + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + pos++; + continue; + } + break; } + return pos; } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + ts.skipTrivia = skipTrivia; + var mergeConflictMarkerLength = "<<<<<<<".length; + function isConflictMarkerTrivia(text, pos) { + ts.Debug.assert(pos >= 0); + 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++) { + if (text.charCodeAt(pos + i) !== ch) { + return false; + } } + return ch === 61 || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32; } } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; + return false; + } + function scanConflictMarkerTrivia(text, pos, error) { + if (error) { + error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); + } + var ch = text.charCodeAt(pos); + var len = text.length; + if (ch === 60 || ch === 62) { + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; } } - function writeTextOfNode(text, node) { - write(getTextOfNodeFromSourceText(text, node)); + else { + ts.Debug.assert(ch === 61); + while (pos < len) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { + break; + } + pos++; + } } - reset(); - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; }, - isAtStartOfLine: function () { return lineStart; }, - reset: reset - }; - } - ts.createTextWriter = createTextWriter; - function getResolvedExternalModuleName(host, file) { - return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + return pos; } - ts.getResolvedExternalModuleName = getResolvedExternalModuleName; - function getExternalModuleNameFromDeclaration(host, resolver, declaration) { - var file = resolver.getExternalModuleFileFromDeclaration(declaration); - if (!file || isDeclarationFile(file)) { - return undefined; - } - return getResolvedExternalModuleName(host, file); + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); } - ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; - function getExternalModuleNameFromPath(host, fileName) { - var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); - var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); - return ts.removeFileExtension(relativePath); + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; } - ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { + var pendingPos; + var pendingEnd; + var pendingKind; + var pendingHasTrailingNewLine; + var hasPendingCommentRange = false; + var collecting = trailing || pos === 0; + var accumulator = initial; + scan: while (pos >= 0 && pos < text.length) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (trailing) { + break scan; + } + collecting = true; + if (hasPendingCommentRange) { + pendingHasTrailingNewLine = true; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + var nextChar = text.charCodeAt(pos + 1); + var hasTrailingNewLine = false; + if (nextChar === 47 || nextChar === 42) { + var kind = nextChar === 47 ? 2 : 3; + var startPos = pos; + pos += 2; + if (nextChar === 47) { + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + hasTrailingNewLine = true; + break; + } + pos++; + } + } + else { + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + } + if (collecting) { + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + if (!reduce && accumulator) { + return accumulator; + } + hasPendingCommentRange = false; + } + pendingPos = startPos; + pendingEnd = pos; + pendingKind = kind; + pendingHasTrailingNewLine = hasTrailingNewLine; + hasPendingCommentRange = true; + } + continue; + } + break scan; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + if (hasPendingCommentRange && isLineBreak(ch)) { + pendingHasTrailingNewLine = true; + } + pos++; + continue; + } + break scan; + } } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); } - return emitOutputFilePathWithoutExtension + extension; + return accumulator; } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getDeclarationEmitOutputFilePath(sourceFile, host) { - var options = host.getCompilerOptions(); - var outputDir = options.declarationDir || options.outDir; - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; + function forEachLeadingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, false, cb, state); } - ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getSourceFilesToEmit(host, targetSourceFile) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); - } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, isNonDeclarationFile); + ts.forEachLeadingCommentRange = forEachLeadingCommentRange; + function forEachTrailingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, true, cb, state); + } + ts.forEachTrailingCommentRange = forEachTrailingCommentRange; + function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, false, cb, state, initial); + } + ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; + function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, true, cb, state, initial); + } + ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { + if (!comments) { + comments = []; } + comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + return comments; } - ts.getSourceFilesToEmit = getSourceFilesToEmit; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); + function getLeadingCommentRanges(text, pos) { + return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - function isBundleEmitNonExternalModule(sourceFile) { - return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; + function isIdentifierStart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); + } + ts.isIdentifierStart = isIdentifierStart; + function isIdentifierPart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); + } + ts.isIdentifierPart = isIdentifierPart; + function isIdentifierText(name, languageVersion) { + if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + return false; } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } + for (var i = 1, n = name.length; i < n; i++) { + if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + return false; } } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } + return true; + } + ts.isIdentifierText = isIdentifierText; + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0; } + var pos; + var end; + var startPos; + var tokenPos; + var token; + var tokenValue; + var precedingLineBreak; + var hasExtendedUnicodeEscape; + var tokenIsUnterminated; + setText(text, start, length); + return { + getStartPos: function () { return startPos; }, + getTextPos: function () { return pos; }, + getToken: function () { return token; }, + getTokenPos: function () { return tokenPos; }, + getTokenText: function () { return text.substring(tokenPos, pos); }, + getTokenValue: function () { return tokenValue; }, + hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, + hasPrecedingLineBreak: function () { return precedingLineBreak; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, + isUnterminated: function () { return tokenIsUnterminated; }, + reScanGreaterToken: reScanGreaterToken, + reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + scanJsxAttributeValue: scanJsxAttributeValue, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, + scan: scan, + getText: getText, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead, + scanRange: scanRange, + }; + function error(message, length) { + if (onError) { + onError(message, length || 0); + } + } + function scanNumber() { + var start = pos; + while (isDigit(text.charCodeAt(pos))) + pos++; + if (text.charCodeAt(pos) === 46) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + } + var end = pos; + if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { + pos++; + if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) + pos++; + if (isDigit(text.charCodeAt(pos))) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + end = pos; } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; + else { + error(ts.Diagnostics.Digit_expected); } } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); + return "" + +(text.substring(start, end)); } - function onBundledEmit(host, sourceFiles) { - if (sourceFiles.length) { - var jsFilePath = options.outFile || options.out; - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + function scanOctalDigits() { + var start = pos; + while (isOctalDigit(text.charCodeAt(pos))) { + pos++; } + return +(text.substring(start, pos)); } - } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; - function getSourceMapFilePath(jsFilePath, options) { - return options.sourceMap ? jsFilePath + ".map" : undefined; - } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); + function scanExactNumberOfHexDigits(count) { + return scanHexDigits(count, false); } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } + function scanMinimumNumberOfHexDigits(count) { + return scanHexDigits(count, true); } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } + function scanHexDigits(minCount, scanAsManyAsPossible) { + var digits = 0; + var value = 0; + while (digits < minCount || scanAsManyAsPossible) { + var ch = text.charCodeAt(pos); + if (ch >= 48 && ch <= 57) { + value = value * 16 + ch - 48; } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; + else if (ch >= 65 && ch <= 70) { + value = value * 16 + ch - 65 + 10; } + else if (ch >= 97 && ch <= 102) { + value = value * 16 + ch - 97 + 10; + } + else { + break; + } + pos++; + digits++; } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + if (digits < minCount) { + value = -1; } + return value; } - } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - var commonSourceDirectory = host.getCommonSourceDirectory(); - var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; - sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getLineOfLocalPositionFromLineMap(lineMap, pos) { - return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; - } - ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 148 && nodeIsPresent(member.body)) { - return member; + function scanString(allowEscapes) { + if (allowEscapes === void 0) { allowEscapes = true; } + var quote = text.charCodeAt(pos); + pos++; + var result = ""; + var start = pos; + while (true) { + if (pos >= end) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + var ch = text.charCodeAt(pos); + if (ch === quote) { + result += text.substring(start, pos); + pos++; + break; + } + if (ch === 92 && allowEscapes) { + result += text.substring(start, pos); + result += scanEscapeSequence(); + start = pos; + continue; + } + if (isLineBreak(ch)) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + pos++; } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); - return accessor.parameters[hasThis ? 1 : 0].type; + return result; } - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function getThisParameter(signature) { - if (signature.parameters.length) { - var thisParameter = signature.parameters[0]; - if (parameterIsThisKeyword(thisParameter)) { - return thisParameter; + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96; + pos++; + var start = pos; + var contents = ""; + var resultingToken; + while (true) { + if (pos >= end) { + contents += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_template_literal); + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + var currChar = text.charCodeAt(pos); + if (currChar === 96) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { + contents += text.substring(start, pos); + pos += 2; + resultingToken = startedWithBacktick ? 13 : 14; + break; + } + if (currChar === 92) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + if (currChar === 13) { + contents += text.substring(start, pos); + pos++; + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + contents += "\n"; + start = pos; + continue; + } + pos++; } + ts.Debug.assert(resultingToken !== undefined); + tokenValue = contents; + return resultingToken; } - } - ts.getThisParameter = getThisParameter; - function parameterIsThisKeyword(parameter) { - return isThisIdentifier(parameter.name); - } - ts.parameterIsThisKeyword = parameterIsThisKeyword; - function isThisIdentifier(node) { - return node && node.kind === 69 && identifierIsThisKeyword(node); - } - ts.isThisIdentifier = isThisIdentifier; - function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97; - } - ts.identifierIsThisKeyword = identifierIsThisKeyword; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 149) { - getAccessor = accessor; + function scanEscapeSequence() { + pos++; + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + return ""; } - else if (accessor.kind === 150) { - setAccessor = accessor; + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 48: + return "\0"; + case 98: + return "\b"; + case 116: + return "\t"; + case 110: + return "\n"; + case 118: + return "\v"; + case 102: + return "\f"; + case 114: + return "\r"; + case 39: + return "\'"; + case 34: + return "\""; + case 117: + if (pos < end && text.charCodeAt(pos) === 123) { + hasExtendedUnicodeEscape = true; + pos++; + return scanExtendedUnicodeEscape(); + } + return scanHexadecimalEscape(4); + case 120: + return scanHexadecimalEscape(2); + case 13: + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + case 8232: + case 8233: + return ""; + default: + return String.fromCharCode(ch); + } + } + function scanHexadecimalEscape(numDigits) { + var escapedValue = scanExactNumberOfHexDigits(numDigits); + if (escapedValue >= 0) { + return String.fromCharCode(escapedValue); } else { - ts.Debug.fail("Accessor has wrong kind"); + error(ts.Diagnostics.Hexadecimal_digit_expected); + return ""; } } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 149 || member.kind === 150) - && hasModifier(member, 32) === hasModifier(accessor, 32)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 149 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 150 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { - emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { - if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { - if (pos !== commentPos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; - function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { - if (comments && comments.length > 0) { - if (leadingSeparator) { - writer.write(" "); + function scanExtendedUnicodeEscape() { + var escapedValue = scanMinimumNumberOfHexDigits(1); + var isInvalidExtendedEscape = false; + if (escapedValue < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + isInvalidExtendedEscape = true; } - var emitInterveningSeparator = false; - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - if (emitInterveningSeparator) { - writer.write(" "); - emitInterveningSeparator = false; - } - writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else { - emitInterveningSeparator = true; - } + else if (escapedValue > 0x10FFFF) { + error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); + isInvalidExtendedEscape = true; } - if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + isInvalidExtendedEscape = true; + } + else if (text.charCodeAt(pos) === 125) { + pos++; + } + else { + error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); + isInvalidExtendedEscape = true; + } + if (isInvalidExtendedEscape) { + return ""; } + return utf16EncodeAsString(escapedValue); } - } - ts.emitComments = emitComments; - function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { - var leadingComments; - var currentDetachedCommentInfo; - if (removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + function utf16EncodeAsString(codePoint) { + ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); + if (codePoint <= 65535) { + return String.fromCharCode(codePoint); } + var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; + var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; + return String.fromCharCode(codeUnit1, codeUnit2); } - else { - leadingComments = ts.getLeadingCommentRanges(text, node.pos); + function peekUnicodeEscape() { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { + var start_1 = pos; + pos += 2; + var value = scanExactNumberOfHexDigits(4); + pos = start_1; + return value; + } + return -1; } - if (leadingComments) { - var detachedComments = []; - var lastComment = void 0; - for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { - var comment = leadingComments_1[_i]; - if (lastComment) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); - var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); - if (commentLine >= lastCommentLine + 2) { + function scanIdentifierParts() { + var result = ""; + var start = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (isIdentifierPart(ch, languageVersion)) { + pos++; + } + else if (ch === 92) { + ch = peekUnicodeEscape(); + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + result += text.substring(start, pos); + result += String.fromCharCode(ch); + pos += 6; + start = pos; } - detachedComments.push(comment); - lastComment = comment; - } - if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); - var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); - emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + else { + break; } } + result += text.substring(start, pos); + return result; } - return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; - } - } - ts.emitDetachedComments = emitDetachedComments; - function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42) { - var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); - var lineCount = lineMap.length; - var firstCommentLineIndent = void 0; - for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? text.length + 1 - : lineMap[currentLine + 1]; - if (pos !== commentPos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } + function getIdentifierToken() { + var len = tokenValue.length; + if (len >= 2 && len <= 11) { + var ch = tokenValue.charCodeAt(0); + if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { + return token = textToToken[tokenValue]; } - writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(text.substring(commentPos, commentEnd)); - } - } - ts.writeCommentRange = writeCommentRange; - function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { - var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== commentEnd) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(text, pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; } + return token = 70; } - return currentLineIndent; - } - function hasModifiers(node) { - return getModifierFlags(node) !== 0; - } - ts.hasModifiers = hasModifiers; - function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; - } - ts.hasModifier = hasModifier; - function getModifierFlags(node) { - if (node.modifierFlagsCache & 536870912) { - return node.modifierFlagsCache & ~536870912; - } - var flags = 0; - if (node.modifiers) { - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - flags |= modifierToFlag(modifier.kind); + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; } - } - if (node.flags & 4) { - flags |= 1; - } - node.modifierFlagsCache = flags | 536870912; - return flags; - } - ts.getModifierFlags = getModifierFlags; - function modifierToFlag(token) { - switch (token) { - case 113: return 32; - case 112: return 4; - case 111: return 16; - case 110: return 8; - case 115: return 128; - case 82: return 1; - case 122: return 2; - case 74: return 2048; - case 77: return 512; - case 118: return 256; - case 128: return 64; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLogicalOperator(token) { - return token === 52 - || token === 51 - || token === 49; - } - ts.isLogicalOperator = isLogicalOperator; - function isAssignmentOperator(token) { - return token >= 56 && token <= 68; - } - ts.isAssignmentOperator = isAssignmentOperator; - function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 && - node.parent.token === 83 && - isClassLike(node.parent.parent)) { - return node.parent.parent; - } - } - ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; - function isDestructuringAssignment(node) { - if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56) { - var kind = node.left.kind; - return kind === 171 - || kind === 170; + if (numberOfDigits === 0) { + return -1; } + return value; } - return false; - } - ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { - return true; + function scan() { + startPos = pos; + hasExtendedUnicodeEscape = false; + precedingLineBreak = false; + tokenIsUnterminated = false; + while (true) { + tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } + switch (ch) { + case 10: + case 13: + precedingLineBreak = true; + if (skipTrivia) { + pos++; + continue; + } + else { + if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { + pos += 2; + } + else { + pos++; + } + return token = 4; + } + case 9: + case 11: + case 12: + case 32: + if (skipTrivia) { + pos++; + continue; + } + else { + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; + } + case 33: + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 34; + } + return pos += 2, token = 32; + } + pos++; + return token = 50; + case 34: + case 39: + tokenValue = scanString(); + return token = 9; + case 96: + return token = scanTemplateAndSetTokenValue(); + case 37: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 63; + } + pos++; + return token = 41; + case 38: + if (text.charCodeAt(pos + 1) === 38) { + return pos += 2, token = 52; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 67; + } + pos++; + return token = 47; + case 40: + pos++; + return token = 18; + case 41: + pos++; + return token = 19; + case 42: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 61; + } + return pos += 2, token = 39; + } + pos++; + return token = 38; + case 43: + if (text.charCodeAt(pos + 1) === 43) { + return pos += 2, token = 42; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 58; + } + pos++; + return token = 36; + case 44: + pos++; + return token = 25; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 43; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + pos++; + return token = 37; + case 46: + if (isDigit(text.charCodeAt(pos + 1))) { + tokenValue = scanNumber(); + return token = 8; + } + if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { + return pos += 3, token = 23; + } + pos++; + return token = 22; + case 47: + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < end) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + if (skipTrivia) { + continue; + } + else { + return token = 2; + } + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + var commentClosed = false; + while (pos < end) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + commentClosed = true; + break; + } + if (isLineBreak(ch_2)) { + precedingLineBreak = true; + } + pos++; + } + if (!commentClosed) { + error(ts.Diagnostics.Asterisk_Slash_expected); + } + if (skipTrivia) { + continue; + } + else { + tokenIsUnterminated = !commentClosed; + return token = 3; + } + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 62; + } + pos++; + return token = 40; + case 48: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { + pos += 2; + var value = scanMinimumNumberOfHexDigits(1); + if (value < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { + tokenValue = "" + scanOctalDigits(); + return token = 8; + } + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + tokenValue = scanNumber(); + return token = 8; + case 58: + pos++; + return token = 55; + case 59: + pos++; + return token = 24; + case 60: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 60) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 64; + } + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 29; + } + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { + return pos += 2, token = 27; + } + pos++; + return token = 26; + case 61: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 33; + } + return pos += 2, token = 31; + } + if (text.charCodeAt(pos + 1) === 62) { + return pos += 2, token = 35; + } + pos++; + return token = 57; + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + pos++; + return token = 28; + case 63: + pos++; + return token = 54; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 69; + } + pos++; + return token = 49; + case 123: + pos++; + return token = 16; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 53; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 68; + } + pos++; + return token = 48; + case 125: + pos++; + return token = 17; + case 126: + pos++; + return token = 51; + case 64: + pos++; + return token = 56; + case 92: + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + default: + if (isIdentifierStart(ch, languageVersion)) { + pos++; + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) + pos++; + tokenValue = text.substring(tokenPos, pos); + if (ch === 92) { + tokenValue += scanIdentifierParts(); + } + return token = getIdentifierToken(); + } + else if (isWhiteSpaceSingleLine(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + } + } } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); + function reScanGreaterToken() { + if (token === 28) { + if (text.charCodeAt(pos) === 62) { + if (text.charCodeAt(pos + 1) === 62) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 66; + } + return pos += 2, token = 46; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 65; + } + pos++; + return token = 45; + } + if (text.charCodeAt(pos) === 61) { + pos++; + return token = 30; + } + } + return token; } - else { - return false; + function reScanSlashToken() { + if (token === 40 || token === 62) { + var p = tokenPos + 1; + var inEscape = false; + var inCharacterClass = false; + while (true) { + if (p >= end) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + var ch = text.charCodeAt(p); + if (isLineBreak(ch)) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + if (inEscape) { + inEscape = false; + } + else if (ch === 47 && !inCharacterClass) { + p++; + break; + } + else if (ch === 91) { + inCharacterClass = true; + } + else if (ch === 92) { + inEscape = true; + } + else if (ch === 93) { + inCharacterClass = false; + } + p++; + } + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { + p++; + } + pos = p; + tokenValue = text.substring(tokenPos, pos); + token = 11; + } + return token; } - } - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isEntityNameExpression(node) { - return node.kind === 69 || - node.kind === 172 && isEntityNameExpression(node.expression); - } - ts.isEntityNameExpression = isEntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 && node.parent.right === node) || - (node.parent.kind === 172 && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 171) { - return expression.properties.length === 0; + function reScanTemplateToken() { + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(); } - if (kind === 170) { - return expression.elements.length === 0; + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function tryExtractTypeScriptExtension(fileName) { - return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - if (charCode < 0x80) { - output.push(charCode); + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1; } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); + var char = text.charCodeAt(pos); + if (char === 60) { + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + return token = 27; + } + pos++; + return token = 26; } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); + if (char === 123) { + pos++; + return token = 16; } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123) || (char === 60)) { + break; + } } - else { - ts.Debug.assert(false, "Unexpected code point"); + return token = 10; + } + function scanJsxIdentifier() { + if (tokenIsIdentifierOrKeyword(token)) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); } + return token; } - return output; - } - ts.stringify = typeof JSON !== "undefined" && JSON.stringify - ? JSON.stringify - : stringifyFallback; - function stringifyFallback(value) { - return value === undefined ? undefined : stringifyValue(value); - } - function stringifyValue(value) { - return typeof value === "string" ? "\"" + escapeString(value) + "\"" - : typeof value === "number" ? isFinite(value) ? String(value) : "null" - : typeof value === "boolean" ? value ? "true" : "false" - : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) - : "null"; - } - function cycleCheck(cb, value) { - ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); - value.__cycle = true; - var result = cb(value); - delete value.__cycle; - return result; - } - function stringifyArray(value) { - return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; - } - function stringifyElement(memo, value) { - return (memo ? memo + "," : memo) + stringifyValue(value); - } - function stringifyObject(value) { - return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; - } - function stringifyProperty(memo, value, key) { - return value === undefined || typeof value === "function" || key === "__cycle" ? memo - : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - if (i + 1 >= length) { - byte3 = byte4 = 64; + function scanJsxAttributeValue() { + startPos = pos; + switch (text.charCodeAt(pos)) { + case 34: + case 39: + tokenValue = scanString(false); + return token = 9; + default: + return scan(); } - else if (i + 2 >= length) { - byte4 = 64; + } + function scanJSDocToken() { + if (pos >= end) { + return token = 1; + } + startPos = pos; + tokenPos = pos; + var ch = text.charCodeAt(pos); + switch (ch) { + case 9: + case 11: + case 12: + case 32: + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; + case 64: + pos++; + return token = 56; + case 10: + case 13: + pos++; + return token = 4; + case 42: + pos++; + return token = 38; + case 123: + pos++; + return token = 16; + case 125: + pos++; + return token = 17; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 61: + pos++; + return token = 57; + case 44: + pos++; + return token = 25; + } + if (isIdentifierStart(ch, 4)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + pos++; + } + return token = 70; + } + else { + return pos += 1, token = 0; } - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0) { - return carriageReturnLineFeed; + function speculationHelper(callback, isLookahead) { + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var saveTokenValue = tokenValue; + var savePrecedingLineBreak = precedingLineBreak; + var result = callback(); + if (!result || isLookahead) { + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + tokenValue = saveTokenValue; + precedingLineBreak = savePrecedingLineBreak; + } + return result; } - else if (options.newLine === 1) { - return lineFeed; + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; } - else if (ts.sys) { - return ts.sys.newLine; + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } + function getText() { + return text; + } + function setText(newText, start, length) { + text = newText || ""; + end = length === undefined ? text.length : start + length; + setTextPos(start || 0); + } + function setOnError(errorCallback) { + onError = errorCallback; + } + function setScriptTarget(scriptTarget) { + languageVersion = scriptTarget; + } + function setLanguageVariant(variant) { + languageVariant = variant; + } + function setTextPos(textPos) { + ts.Debug.assert(textPos >= 0); + pos = textPos; + startPos = textPos; + tokenPos = textPos; + token = 0; + precedingLineBreak = false; + tokenValue = undefined; + hasExtendedUnicodeEscape = false; + tokenIsUnterminated = false; } - return carriageReturnLineFeed; } - ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); + ts.createScanner = createScanner; +})(ts || (ts = {})); +var ts; +(function (ts) { + var NodeConstructor; + var SourceFileConstructor; + function createNode(kind, location, flags) { + var ConstructorForKind = kind === 256 + ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) + : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); + var node = location + ? new ConstructorForKind(kind, location.pos, location.end) + : new ConstructorForKind(kind, -1, -1); + node.flags = flags | 8; + return node; } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 10 - || kind === 11 - || kind === 69 - || kind === 97 - || kind === 95 - || kind === 99 - || kind === 84 - || kind === 93) { - return true; - } - else if (kind === 172) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 173) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 185 - || kind === 186) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 187) { - return node.operatorToken.kind !== 38 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 188) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 183 - || kind === 182 - || kind === 181) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 170) { - return node.elements.length === 0; - } - else if (kind === 171) { - return node.properties.length === 0; - } - else if (kind === 174) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; + function updateNode(updated, original) { + if (updated !== original) { + setOriginalNode(updated, original); + if (original.startsOnNewLine) { + updated.startsOnNewLine = true; } + ts.aggregateTransformFlags(updated); } - return false; + return updated; } - var syntaxKindCache = ts.createMap(); - function formatSyntaxKind(kind) { - var syntaxKindEnum = ts.SyntaxKind; - if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; - } - for (var name_10 in syntaxKindEnum) { - if (syntaxKindEnum[name_10] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; - } + ts.updateNode = updateNode; + function createNodeArray(elements, location, hasTrailingComma) { + if (elements) { + if (ts.isNodeArray(elements)) { + return elements; } } else { - return kind.toString(); + elements = []; } + var array = elements; + if (location) { + array.pos = location.pos; + array.end = location.end; + } + else { + array.pos = -1; + array.end = -1; + } + if (hasTrailingComma) { + array.hasTrailingComma = true; + } + return array; } - ts.formatSyntaxKind = formatSyntaxKind; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; - function createRange(pos, end) { - return { pos: pos, end: end }; - } - ts.createRange = createRange; - function moveRangeEnd(range, end) { - return createRange(range.pos, end); + ts.createNodeArray = createNodeArray; + function createSynthesizedNode(kind, startsOnNewLine) { + var node = createNode(kind, undefined); + node.startsOnNewLine = startsOnNewLine; + return node; } - ts.moveRangeEnd = moveRangeEnd; - function moveRangePos(range, pos) { - return createRange(pos, range.end); + ts.createSynthesizedNode = createSynthesizedNode; + function createSynthesizedNodeArray(elements) { + return createNodeArray(elements, undefined); } - ts.moveRangePos = moveRangePos; - function moveRangePastDecorators(node) { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) - : node; + ts.createSynthesizedNodeArray = createSynthesizedNodeArray; + function getSynthesizedClone(node) { + var clone = createNode(node.kind, undefined, node.flags); + setOriginalNode(clone, node); + for (var key in node) { + if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { + continue; + } + clone[key] = node[key]; + } + return clone; } - ts.moveRangePastDecorators = moveRangePastDecorators; - function moveRangePastModifiers(node) { - return node.modifiers && node.modifiers.length > 0 - ? moveRangePos(node, node.modifiers.end) - : moveRangePastDecorators(node); + ts.getSynthesizedClone = getSynthesizedClone; + function getMutableClone(node) { + var clone = getSynthesizedClone(node); + clone.pos = node.pos; + clone.end = node.end; + clone.parent = node.parent; + return clone; } - ts.moveRangePastModifiers = moveRangePastModifiers; - function isCollapsedRange(range) { - return range.pos === range.end; + ts.getMutableClone = getMutableClone; + function createLiteral(value, location) { + if (typeof value === "number") { + var node = createNode(8, location, undefined); + node.text = value.toString(); + return node; + } + else if (typeof value === "boolean") { + return createNode(value ? 100 : 85, location, undefined); + } + else if (typeof value === "string") { + var node = createNode(9, location, undefined); + node.text = value; + return node; + } + else if (value) { + var node = createNode(9, location, undefined); + node.textSourceNode = value; + node.text = value.text; + return node; + } } - ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); + ts.createLiteral = createLiteral; + var nextAutoGenerateId = 0; + function createIdentifier(text, location) { + var node = createNode(70, location); + node.text = ts.escapeIdentifier(text); + node.originalKeywordKind = ts.stringToToken(text); + node.autoGenerateKind = 0; + node.autoGenerateId = 0; + return node; } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); + ts.createIdentifier = createIdentifier; + function createTempVariable(recordTempVariable, location) { + var name = createNode(70, location); + name.text = ""; + name.originalKeywordKind = 0; + name.autoGenerateKind = 1; + name.autoGenerateId = nextAutoGenerateId; + nextAutoGenerateId++; + if (recordTempVariable) { + recordTempVariable(name); + } + return name; } - ts.collapseRangeToEnd = collapseRangeToEnd; - function createTokenRange(pos, token) { - return createRange(pos, pos + ts.tokenToString(token).length); + ts.createTempVariable = createTempVariable; + function createLoopVariable(location) { + var name = createNode(70, location); + name.text = ""; + name.originalKeywordKind = 0; + name.autoGenerateKind = 2; + name.autoGenerateId = nextAutoGenerateId; + nextAutoGenerateId++; + return name; } - ts.createTokenRange = createTokenRange; - function rangeIsOnSingleLine(range, sourceFile) { - return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); + ts.createLoopVariable = createLoopVariable; + function createUniqueName(text, location) { + var name = createNode(70, location); + name.text = text; + name.originalKeywordKind = 0; + name.autoGenerateKind = 3; + name.autoGenerateId = nextAutoGenerateId; + nextAutoGenerateId++; + return name; } - ts.rangeIsOnSingleLine = rangeIsOnSingleLine; - function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); + ts.createUniqueName = createUniqueName; + function getGeneratedNameForNode(node, location) { + var name = createNode(70, location); + name.original = node; + name.text = ""; + name.originalKeywordKind = 0; + name.autoGenerateKind = 4; + name.autoGenerateId = nextAutoGenerateId; + nextAutoGenerateId++; + return name; } - ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; - function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, range2.end, sourceFile); + ts.getGeneratedNameForNode = getGeneratedNameForNode; + function createToken(token) { + return createNode(token); } - ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; - function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); + ts.createToken = createToken; + function createSuper() { + var node = createNode(96); + return node; } - ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; - function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); + ts.createSuper = createSuper; + function createThis(location) { + var node = createNode(98, location); + return node; } - ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; - function positionsAreOnSameLine(pos1, pos2, sourceFile) { - return pos1 === pos2 || - getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); + ts.createThis = createThis; + function createNull() { + var node = createNode(94); + return node; } - ts.positionsAreOnSameLine = positionsAreOnSameLine; - function getStartPositionOfRange(range, sourceFile) { - return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + ts.createNull = createNull; + function createComputedPropertyName(expression, location) { + var node = createNode(141, location); + node.expression = expression; + return node; } - ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { - var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportEquals = undefined; - var hasExportStarsToExportValues = false; - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var node = _a[_i]; - switch (node.kind) { - case 230: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); - } - break; - case 229: - if (node.moduleReference.kind === 240 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 236: - if (node.moduleSpecifier) { - if (!node.exportClause) { - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } - } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); - } - } - else { - for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { - var specifier = _c[_b]; - var name_11 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); - } - } - break; - case 235: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } + ts.createComputedPropertyName = createComputedPropertyName; + function updateComputedPropertyName(node, expression) { + if (node.expression !== expression) { + return updateNode(createComputedPropertyName(expression, node), node); } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; + return node; } - ts.collectExternalModuleInfo = collectExternalModuleInfo; - function getInitializedVariables(node) { - return ts.filter(node.declarations, isInitializedVariable); + ts.updateComputedPropertyName = updateComputedPropertyName; + function createParameter(name, initializer, location) { + return createParameterDeclaration(undefined, undefined, undefined, name, undefined, undefined, initializer, location); } - ts.getInitializedVariables = getInitializedVariables; - function isInitializedVariable(node) { - return node.initializer !== undefined; + ts.createParameter = createParameter; + function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { + var node = createNode(143, location, flags); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.dotDotDotToken = dotDotDotToken; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.questionToken = questionToken; + node.type = type; + node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + return node; } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 221 && declaration !== node) { - return true; - } - } + ts.createParameterDeclaration = createParameterDeclaration; + function updateParameterDeclaration(node, decorators, modifiers, name, type, initializer) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { + return updateNode(createParameterDeclaration(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; + return node; } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; - function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + ts.updateParameterDeclaration = updateParameterDeclaration; + function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { + var node = createNode(146, location); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.questionToken = questionToken; + node.type = type; + node.initializer = initializer; + return node; } - ts.isNodeArray = isNodeArray; - function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11; + ts.createProperty = createProperty; + function updateProperty(node, decorators, modifiers, name, type, initializer) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { + return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); + } + return node; } - ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; + ts.updateProperty = updateProperty; + function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(148, location, flags); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.asteriskToken = asteriskToken; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.parameters = createNodeArray(parameters); + node.type = type; + node.body = body; + return node; } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; + ts.createMethod = createMethod; + function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + } + return node; } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isLiteralExpression(node) { - return isLiteralKind(node.kind); + ts.updateMethod = updateMethod; + function createConstructor(decorators, modifiers, parameters, body, location, flags) { + var node = createNode(149, location, flags); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.typeParameters = undefined; + node.parameters = createNodeArray(parameters); + node.type = undefined; + node.body = body; + return node; } - ts.isLiteralExpression = isLiteralExpression; - function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; + ts.createConstructor = createConstructor; + function updateConstructor(node, decorators, modifiers, parameters, body) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { + return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); + } + return node; } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateHead(node) { - return node.kind === 12; + ts.updateConstructor = updateConstructor; + function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { + var node = createNode(150, location, flags); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.typeParameters = undefined; + node.parameters = createNodeArray(parameters); + node.type = type; + node.body = body; + return node; } - ts.isTemplateHead = isTemplateHead; - function isTemplateMiddleOrTemplateTail(node) { - var kind = node.kind; - return kind === 13 - || kind === 14; + ts.createGetAccessor = createGetAccessor; + function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); + } + return node; } - ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; - function isIdentifier(node) { - return node.kind === 69; + ts.updateGetAccessor = updateGetAccessor; + function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { + var node = createNode(151, location, flags); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.typeParameters = undefined; + node.parameters = createNodeArray(parameters); + node.body = body; + return node; } - ts.isIdentifier = isIdentifier; - function isGeneratedIdentifier(node) { - return isIdentifier(node) && node.autoGenerateKind > 0; + ts.createSetAccessor = createSetAccessor; + function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { + return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); + } + return node; } - ts.isGeneratedIdentifier = isGeneratedIdentifier; - function isModifier(node) { - return isModifierKind(node.kind); + ts.updateSetAccessor = updateSetAccessor; + function createObjectBindingPattern(elements, location) { + var node = createNode(168, location); + node.elements = createNodeArray(elements); + return node; } - ts.isModifier = isModifier; - function isQualifiedName(node) { - return node.kind === 139; + ts.createObjectBindingPattern = createObjectBindingPattern; + function updateObjectBindingPattern(node, elements) { + if (node.elements !== elements) { + return updateNode(createObjectBindingPattern(elements, node), node); + } + return node; } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 140; + ts.updateObjectBindingPattern = updateObjectBindingPattern; + function createArrayBindingPattern(elements, location) { + var node = createNode(169, location); + node.elements = createNodeArray(elements); + return node; } - ts.isComputedPropertyName = isComputedPropertyName; - function isEntityName(node) { - var kind = node.kind; - return kind === 139 - || kind === 69; + ts.createArrayBindingPattern = createArrayBindingPattern; + function updateArrayBindingPattern(node, elements) { + if (node.elements !== elements) { + return updateNode(createArrayBindingPattern(elements, node), node); + } + return node; } - ts.isEntityName = isEntityName; - function isPropertyName(node) { - var kind = node.kind; - return kind === 69 - || kind === 9 - || kind === 8 - || kind === 140; + ts.updateArrayBindingPattern = updateArrayBindingPattern; + function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { + var node = createNode(170, location); + node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + node.dotDotDotToken = dotDotDotToken; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.initializer = initializer; + return node; } - ts.isPropertyName = isPropertyName; - function isModuleName(node) { - var kind = node.kind; - return kind === 69 - || kind === 9; + ts.createBindingElement = createBindingElement; + function updateBindingElement(node, propertyName, name, initializer) { + if (node.propertyName !== propertyName || node.name !== name || node.initializer !== initializer) { + return updateNode(createBindingElement(propertyName, node.dotDotDotToken, name, initializer, node), node); + } + return node; } - ts.isModuleName = isModuleName; - function isBindingName(node) { - var kind = node.kind; - return kind === 69 - || kind === 167 - || kind === 168; + ts.updateBindingElement = updateBindingElement; + function createArrayLiteral(elements, location, multiLine) { + var node = createNode(171, location); + node.elements = parenthesizeListElements(createNodeArray(elements)); + if (multiLine) { + node.multiLine = true; + } + return node; } - ts.isBindingName = isBindingName; - function isTypeParameter(node) { - return node.kind === 141; + ts.createArrayLiteral = createArrayLiteral; + function updateArrayLiteral(node, elements) { + if (node.elements !== elements) { + return updateNode(createArrayLiteral(elements, node, node.multiLine), node); + } + return node; } - ts.isTypeParameter = isTypeParameter; - function isParameter(node) { - return node.kind === 142; + ts.updateArrayLiteral = updateArrayLiteral; + function createObjectLiteral(properties, location, multiLine) { + var node = createNode(172, location); + node.properties = createNodeArray(properties); + if (multiLine) { + node.multiLine = true; + } + return node; } - ts.isParameter = isParameter; - function isDecorator(node) { - return node.kind === 143; + ts.createObjectLiteral = createObjectLiteral; + function updateObjectLiteral(node, properties) { + if (node.properties !== properties) { + return updateNode(createObjectLiteral(properties, node, node.multiLine), node); + } + return node; } - ts.isDecorator = isDecorator; - function isMethodDeclaration(node) { - return node.kind === 147; + ts.updateObjectLiteral = updateObjectLiteral; + function createPropertyAccess(expression, name, location, flags) { + var node = createNode(173, location, flags); + node.expression = parenthesizeForAccess(expression); + (node.emitNode || (node.emitNode = {})).flags |= 1048576; + node.name = typeof name === "string" ? createIdentifier(name) : name; + return node; } - ts.isMethodDeclaration = isMethodDeclaration; - function isClassElement(node) { - var kind = node.kind; - return kind === 148 - || kind === 145 - || kind === 147 - || kind === 149 - || kind === 150 - || kind === 153 - || kind === 198; + ts.createPropertyAccess = createPropertyAccess; + function updatePropertyAccess(node, expression, name) { + if (node.expression !== expression || node.name !== name) { + var propertyAccess = createPropertyAccess(expression, name, node, node.flags); + (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); + return updateNode(propertyAccess, node); + } + return node; } - ts.isClassElement = isClassElement; - function isObjectLiteralElementLike(node) { - var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 147 - || kind === 149 - || kind === 150 - || kind === 239; + ts.updatePropertyAccess = updatePropertyAccess; + function createElementAccess(expression, index, location) { + var node = createNode(174, location); + node.expression = parenthesizeForAccess(expression); + node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + return node; } - ts.isObjectLiteralElementLike = isObjectLiteralElementLike; - function isTypeNodeKind(kind) { - return (kind >= 154 && kind <= 166) - || kind === 117 - || kind === 130 - || kind === 120 - || kind === 132 - || kind === 133 - || kind === 103 - || kind === 127 - || kind === 194; + ts.createElementAccess = createElementAccess; + function updateElementAccess(node, expression, argumentExpression) { + if (node.expression !== expression || node.argumentExpression !== argumentExpression) { + return updateNode(createElementAccess(expression, argumentExpression, node), node); + } + return node; } - function isTypeNode(node) { - return isTypeNodeKind(node.kind); + ts.updateElementAccess = updateElementAccess; + function createCall(expression, typeArguments, argumentsArray, location, flags) { + var node = createNode(175, location, flags); + node.expression = parenthesizeForAccess(expression); + if (typeArguments) { + node.typeArguments = createNodeArray(typeArguments); + } + node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + return node; } - ts.isTypeNode = isTypeNode; - function isBindingPattern(node) { - if (node) { - var kind = node.kind; - return kind === 168 - || kind === 167; + ts.createCall = createCall; + function updateCall(node, expression, typeArguments, argumentsArray) { + if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { + return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); } - return false; + return node; } - ts.isBindingPattern = isBindingPattern; - function isBindingElement(node) { - return node.kind === 169; + ts.updateCall = updateCall; + function createNew(expression, typeArguments, argumentsArray, location, flags) { + var node = createNode(176, location, flags); + node.expression = parenthesizeForNew(expression); + node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; + node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + return node; } - ts.isBindingElement = isBindingElement; - function isArrayBindingElement(node) { - var kind = node.kind; - return kind === 169 - || kind === 193; + ts.createNew = createNew; + function updateNew(node, expression, typeArguments, argumentsArray) { + if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { + return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); + } + return node; } - ts.isArrayBindingElement = isArrayBindingElement; - function isPropertyAccessExpression(node) { - return node.kind === 172; + ts.updateNew = updateNew; + function createTaggedTemplate(tag, template, location) { + var node = createNode(177, location); + node.tag = parenthesizeForAccess(tag); + node.template = template; + return node; } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 173; + ts.createTaggedTemplate = createTaggedTemplate; + function updateTaggedTemplate(node, tag, template) { + if (node.tag !== tag || node.template !== template) { + return updateNode(createTaggedTemplate(tag, template, node), node); + } + return node; } - ts.isElementAccessExpression = isElementAccessExpression; - function isBinaryExpression(node) { - return node.kind === 187; + ts.updateTaggedTemplate = updateTaggedTemplate; + function createParen(expression, location) { + var node = createNode(179, location); + node.expression = expression; + return node; } - ts.isBinaryExpression = isBinaryExpression; - function isConditionalExpression(node) { - return node.kind === 188; + ts.createParen = createParen; + function updateParen(node, expression) { + if (node.expression !== expression) { + return updateNode(createParen(expression, node), node); + } + return node; } - ts.isConditionalExpression = isConditionalExpression; - function isCallExpression(node) { - return node.kind === 174; + ts.updateParen = updateParen; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.asteriskToken = asteriskToken; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.parameters = createNodeArray(parameters); + node.type = type; + node.body = body; + return node; } - ts.isCallExpression = isCallExpression; - function isTemplateLiteral(node) { - var kind = node.kind; - return kind === 189 - || kind === 11; + ts.createFunctionExpression = createFunctionExpression; + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + } + return node; } - ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 191; + ts.updateFunctionExpression = updateFunctionExpression; + function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { + var node = createNode(181, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.parameters = createNodeArray(parameters); + node.type = type; + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); + node.body = parenthesizeConciseBody(body); + return node; } - ts.isSpreadElementExpression = isSpreadElementExpression; - function isExpressionWithTypeArguments(node) { - return node.kind === 194; + ts.createArrowFunction = createArrowFunction; + function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { + if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); + } + return node; } - ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; - function isLeftHandSideExpressionKind(kind) { - return kind === 172 - || kind === 173 - || kind === 175 - || kind === 174 - || kind === 241 - || kind === 242 - || kind === 176 - || kind === 170 - || kind === 178 - || kind === 171 - || kind === 192 - || kind === 179 - || kind === 69 - || kind === 10 - || kind === 8 - || kind === 9 - || kind === 11 - || kind === 189 - || kind === 84 - || kind === 93 - || kind === 97 - || kind === 99 - || kind === 95 - || kind === 196; + ts.updateArrowFunction = updateArrowFunction; + function createDelete(expression, location) { + var node = createNode(182, location); + node.expression = parenthesizePrefixOperand(expression); + return node; } - function isLeftHandSideExpression(node) { - return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + ts.createDelete = createDelete; + function updateDelete(node, expression) { + if (node.expression !== expression) { + return updateNode(createDelete(expression, node), expression); + } + return node; } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 185 - || kind === 186 - || kind === 181 - || kind === 182 - || kind === 183 - || kind === 184 - || kind === 177 - || isLeftHandSideExpressionKind(kind); + ts.updateDelete = updateDelete; + function createTypeOf(expression, location) { + var node = createNode(183, location); + node.expression = parenthesizePrefixOperand(expression); + return node; } - function isUnaryExpression(node) { - return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + ts.createTypeOf = createTypeOf; + function updateTypeOf(node, expression) { + if (node.expression !== expression) { + return updateNode(createTypeOf(expression, node), expression); + } + return node; } - ts.isUnaryExpression = isUnaryExpression; - function isExpressionKind(kind) { - return kind === 188 - || kind === 190 - || kind === 180 - || kind === 187 - || kind === 191 - || kind === 195 - || kind === 193 - || isUnaryExpressionKind(kind); + ts.updateTypeOf = updateTypeOf; + function createVoid(expression, location) { + var node = createNode(184, location); + node.expression = parenthesizePrefixOperand(expression); + return node; } - function isExpression(node) { - return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); + ts.createVoid = createVoid; + function updateVoid(node, expression) { + if (node.expression !== expression) { + return updateNode(createVoid(expression, node), node); + } + return node; } - ts.isExpression = isExpression; - function isAssertionExpression(node) { - var kind = node.kind; - return kind === 177 - || kind === 195; + ts.updateVoid = updateVoid; + function createAwait(expression, location) { + var node = createNode(185, location); + node.expression = parenthesizePrefixOperand(expression); + return node; } - ts.isAssertionExpression = isAssertionExpression; - function isPartiallyEmittedExpression(node) { - return node.kind === 288; + ts.createAwait = createAwait; + function updateAwait(node, expression) { + if (node.expression !== expression) { + return updateNode(createAwait(expression, node), node); + } + return node; } - ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; - function isNotEmittedStatement(node) { - return node.kind === 287; + ts.updateAwait = updateAwait; + function createPrefix(operator, operand, location) { + var node = createNode(186, location); + node.operator = operator; + node.operand = parenthesizePrefixOperand(operand); + return node; } - ts.isNotEmittedStatement = isNotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node) { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); + ts.createPrefix = createPrefix; + function updatePrefix(node, operand) { + if (node.operand !== operand) { + return updateNode(createPrefix(node.operator, operand, node), node); + } + return node; } - ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; - function isOmittedExpression(node) { - return node.kind === 193; + ts.updatePrefix = updatePrefix; + function createPostfix(operand, operator, location) { + var node = createNode(187, location); + node.operand = parenthesizePostfixOperand(operand); + node.operator = operator; + return node; } - ts.isOmittedExpression = isOmittedExpression; - function isTemplateSpan(node) { - return node.kind === 197; + ts.createPostfix = createPostfix; + function updatePostfix(node, operand) { + if (node.operand !== operand) { + return updateNode(createPostfix(operand, node.operator, node), node); + } + return node; } - ts.isTemplateSpan = isTemplateSpan; - function isBlock(node) { - return node.kind === 199; + ts.updatePostfix = updatePostfix; + function createBinary(left, operator, right, location) { + var operatorToken = typeof operator === "number" ? createToken(operator) : operator; + var operatorKind = operatorToken.kind; + var node = createNode(188, location); + node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); + node.operatorToken = operatorToken; + node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); + return node; } - ts.isBlock = isBlock; - function isConciseBody(node) { - return isBlock(node) - || isExpression(node); + ts.createBinary = createBinary; + function updateBinary(node, left, right) { + if (node.left !== left || node.right !== right) { + return updateNode(createBinary(left, node.operatorToken, right, node), node); + } + return node; } - ts.isConciseBody = isConciseBody; - function isFunctionBody(node) { - return isBlock(node); + ts.updateBinary = updateBinary; + function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { + var node = createNode(189, location); + node.condition = condition; + node.questionToken = questionToken; + node.whenTrue = whenTrue; + node.colonToken = colonToken; + node.whenFalse = whenFalse; + return node; } - ts.isFunctionBody = isFunctionBody; - function isForInitializer(node) { - return isVariableDeclarationList(node) - || isExpression(node); + ts.createConditional = createConditional; + function updateConditional(node, condition, whenTrue, whenFalse) { + if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { + return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); + } + return node; } - ts.isForInitializer = isForInitializer; - function isVariableDeclaration(node) { - return node.kind === 218; + ts.updateConditional = updateConditional; + function createTemplateExpression(head, templateSpans, location) { + var node = createNode(190, location); + node.head = head; + node.templateSpans = createNodeArray(templateSpans); + return node; } - ts.isVariableDeclaration = isVariableDeclaration; - function isVariableDeclarationList(node) { - return node.kind === 219; + ts.createTemplateExpression = createTemplateExpression; + function updateTemplateExpression(node, head, templateSpans) { + if (node.head !== head || node.templateSpans !== templateSpans) { + return updateNode(createTemplateExpression(head, templateSpans, node), node); + } + return node; } - ts.isVariableDeclarationList = isVariableDeclarationList; - function isCaseBlock(node) { - return node.kind === 227; + ts.updateTemplateExpression = updateTemplateExpression; + function createYield(asteriskToken, expression, location) { + var node = createNode(191, location); + node.asteriskToken = asteriskToken; + node.expression = expression; + return node; } - ts.isCaseBlock = isCaseBlock; - function isModuleBody(node) { - var kind = node.kind; - return kind === 226 - || kind === 225; + ts.createYield = createYield; + function updateYield(node, expression) { + if (node.expression !== expression) { + return updateNode(createYield(node.asteriskToken, expression, node), node); + } + return node; } - ts.isModuleBody = isModuleBody; - function isImportEqualsDeclaration(node) { - return node.kind === 229; + ts.updateYield = updateYield; + function createSpread(expression, location) { + var node = createNode(192, location); + node.expression = parenthesizeExpressionForList(expression); + return node; } - ts.isImportEqualsDeclaration = isImportEqualsDeclaration; - function isImportClause(node) { - return node.kind === 231; + ts.createSpread = createSpread; + function updateSpread(node, expression) { + if (node.expression !== expression) { + return updateNode(createSpread(expression, node), node); + } + return node; } - ts.isImportClause = isImportClause; - function isNamedImportBindings(node) { - var kind = node.kind; - return kind === 233 - || kind === 232; + ts.updateSpread = updateSpread; + function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { + var node = createNode(193, location); + node.decorators = undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.name = name; + node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.heritageClauses = createNodeArray(heritageClauses); + node.members = createNodeArray(members); + return node; } - ts.isNamedImportBindings = isNamedImportBindings; - function isImportSpecifier(node) { - return node.kind === 234; + ts.createClassExpression = createClassExpression; + function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { + if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { + return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); + } + return node; } - ts.isImportSpecifier = isImportSpecifier; - function isNamedExports(node) { - return node.kind === 237; + ts.updateClassExpression = updateClassExpression; + function createOmittedExpression(location) { + var node = createNode(194, location); + return node; } - ts.isNamedExports = isNamedExports; - function isExportSpecifier(node) { - return node.kind === 238; + ts.createOmittedExpression = createOmittedExpression; + function createExpressionWithTypeArguments(typeArguments, expression, location) { + var node = createNode(195, location); + node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; + node.expression = parenthesizeForAccess(expression); + return node; } - ts.isExportSpecifier = isExportSpecifier; - function isModuleOrEnumDeclaration(node) { - return node.kind === 225 || node.kind === 224; + ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node, typeArguments, expression) { + if (node.typeArguments !== typeArguments || node.expression !== expression) { + return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); + } + return node; } - ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; - function isDeclarationKind(kind) { - return kind === 180 - || kind === 169 - || kind === 221 - || kind === 192 - || kind === 148 - || kind === 224 - || kind === 255 - || kind === 238 - || kind === 220 - || kind === 179 - || kind === 149 - || kind === 231 - || kind === 229 - || kind === 234 - || kind === 222 - || kind === 147 - || kind === 146 - || kind === 225 - || kind === 228 - || kind === 232 - || kind === 142 - || kind === 253 - || kind === 145 - || kind === 144 - || kind === 150 - || kind === 254 - || kind === 223 - || kind === 141 - || kind === 218 - || kind === 279; + ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; + function createTemplateSpan(expression, literal, location) { + var node = createNode(198, location); + node.expression = expression; + node.literal = literal; + return node; } - function isDeclarationStatementKind(kind) { - return kind === 220 - || kind === 239 - || kind === 221 - || kind === 222 - || kind === 223 - || kind === 224 - || kind === 225 - || kind === 230 - || kind === 229 - || kind === 236 - || kind === 235 - || kind === 228; + ts.createTemplateSpan = createTemplateSpan; + function updateTemplateSpan(node, expression, literal) { + if (node.expression !== expression || node.literal !== literal) { + return updateNode(createTemplateSpan(expression, literal, node), node); + } + return node; } - function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 - || kind === 209 - || kind === 217 - || kind === 204 - || kind === 202 - || kind === 201 - || kind === 207 - || kind === 208 - || kind === 206 - || kind === 203 - || kind === 214 - || kind === 211 - || kind === 213 - || kind === 215 - || kind === 216 - || kind === 200 - || kind === 205 - || kind === 212 - || kind === 287; + ts.updateTemplateSpan = updateTemplateSpan; + function createBlock(statements, location, multiLine, flags) { + var block = createNode(200, location, flags); + block.statements = createNodeArray(statements); + if (multiLine) { + block.multiLine = true; + } + return block; } - function isDeclaration(node) { - return isDeclarationKind(node.kind); + ts.createBlock = createBlock; + function updateBlock(node, statements) { + if (statements !== node.statements) { + return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); + } + return node; } - ts.isDeclaration = isDeclaration; - function isDeclarationStatement(node) { - return isDeclarationStatementKind(node.kind); + ts.updateBlock = updateBlock; + function createVariableStatement(modifiers, declarationList, location, flags) { + var node = createNode(201, location, flags); + node.decorators = undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; + return node; } - ts.isDeclarationStatement = isDeclarationStatement; - function isStatementButNotDeclaration(node) { - return isStatementKindButNotDeclarationKind(node.kind); + ts.createVariableStatement = createVariableStatement; + function updateVariableStatement(node, modifiers, declarationList) { + if (node.modifiers !== modifiers || node.declarationList !== declarationList) { + return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); + } + return node; } - ts.isStatementButNotDeclaration = isStatementButNotDeclaration; - function isStatement(node) { - var kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === 199; + ts.updateVariableStatement = updateVariableStatement; + function createVariableDeclarationList(declarations, location, flags) { + var node = createNode(220, location, flags); + node.declarations = createNodeArray(declarations); + return node; } - ts.isStatement = isStatement; - function isModuleReference(node) { - var kind = node.kind; - return kind === 240 - || kind === 139 - || kind === 69; + ts.createVariableDeclarationList = createVariableDeclarationList; + function updateVariableDeclarationList(node, declarations) { + if (node.declarations !== declarations) { + return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); + } + return node; } - ts.isModuleReference = isModuleReference; - function isJsxOpeningElement(node) { - return node.kind === 243; + ts.updateVariableDeclarationList = updateVariableDeclarationList; + function createVariableDeclaration(name, type, initializer, location, flags) { + var node = createNode(219, location, flags); + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.type = type; + node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + return node; } - ts.isJsxOpeningElement = isJsxOpeningElement; - function isJsxClosingElement(node) { - return node.kind === 245; + ts.createVariableDeclaration = createVariableDeclaration; + function updateVariableDeclaration(node, name, type, initializer) { + if (node.name !== name || node.type !== type || node.initializer !== initializer) { + return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); + } + return node; } - ts.isJsxClosingElement = isJsxClosingElement; - function isJsxTagNameExpression(node) { - var kind = node.kind; - return kind === 97 - || kind === 69 - || kind === 172; + ts.updateVariableDeclaration = updateVariableDeclaration; + function createEmptyStatement(location) { + return createNode(202, location); } - ts.isJsxTagNameExpression = isJsxTagNameExpression; - function isJsxChild(node) { - var kind = node.kind; - return kind === 241 - || kind === 248 - || kind === 242 - || kind === 244; + ts.createEmptyStatement = createEmptyStatement; + function createStatement(expression, location, flags) { + var node = createNode(203, location, flags); + node.expression = parenthesizeExpressionForExpressionStatement(expression); + return node; } - ts.isJsxChild = isJsxChild; - function isJsxAttributeLike(node) { - var kind = node.kind; - return kind === 246 - || kind === 247; + ts.createStatement = createStatement; + function updateStatement(node, expression) { + if (node.expression !== expression) { + return updateNode(createStatement(expression, node, node.flags), node); + } + return node; } - ts.isJsxAttributeLike = isJsxAttributeLike; - function isJsxSpreadAttribute(node) { - return node.kind === 247; + ts.updateStatement = updateStatement; + function createIf(expression, thenStatement, elseStatement, location) { + var node = createNode(204, location); + node.expression = expression; + node.thenStatement = thenStatement; + node.elseStatement = elseStatement; + return node; } - ts.isJsxSpreadAttribute = isJsxSpreadAttribute; - function isJsxAttribute(node) { - return node.kind === 246; + ts.createIf = createIf; + function updateIf(node, expression, thenStatement, elseStatement) { + if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { + return updateNode(createIf(expression, thenStatement, elseStatement, node), node); + } + return node; } - ts.isJsxAttribute = isJsxAttribute; - function isStringLiteralOrJsxExpression(node) { - var kind = node.kind; - return kind === 9 - || kind === 248; + ts.updateIf = updateIf; + function createDo(statement, expression, location) { + var node = createNode(205, location); + node.statement = statement; + node.expression = expression; + return node; } - ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; - function isCaseOrDefaultClause(node) { - var kind = node.kind; - return kind === 249 - || kind === 250; + ts.createDo = createDo; + function updateDo(node, statement, expression) { + if (node.statement !== statement || node.expression !== expression) { + return updateNode(createDo(statement, expression, node), node); + } + return node; } - ts.isCaseOrDefaultClause = isCaseOrDefaultClause; - function isHeritageClause(node) { - return node.kind === 251; + ts.updateDo = updateDo; + function createWhile(expression, statement, location) { + var node = createNode(206, location); + node.expression = expression; + node.statement = statement; + return node; } - ts.isHeritageClause = isHeritageClause; - function isCatchClause(node) { - return node.kind === 252; + ts.createWhile = createWhile; + function updateWhile(node, expression, statement) { + if (node.expression !== expression || node.statement !== statement) { + return updateNode(createWhile(expression, statement, node), node); + } + return node; } - ts.isCatchClause = isCatchClause; - function isPropertyAssignment(node) { - return node.kind === 253; + ts.updateWhile = updateWhile; + function createFor(initializer, condition, incrementor, statement, location) { + var node = createNode(207, location, undefined); + node.initializer = initializer; + node.condition = condition; + node.incrementor = incrementor; + node.statement = statement; + return node; } - ts.isPropertyAssignment = isPropertyAssignment; - function isShorthandPropertyAssignment(node) { - return node.kind === 254; + ts.createFor = createFor; + function updateFor(node, initializer, condition, incrementor, statement) { + if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { + return updateNode(createFor(initializer, condition, incrementor, statement, node), node); + } + return node; } - ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; - function isEnumMember(node) { - return node.kind === 255; + ts.updateFor = updateFor; + function createForIn(initializer, expression, statement, location) { + var node = createNode(208, location); + node.initializer = initializer; + node.expression = expression; + node.statement = statement; + return node; } - ts.isEnumMember = isEnumMember; - function isSourceFile(node) { - return node.kind === 256; + ts.createForIn = createForIn; + function updateForIn(node, initializer, expression, statement) { + if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { + return updateNode(createForIn(initializer, expression, statement, node), node); + } + return node; } - ts.isSourceFile = isSourceFile; - function isWatchSet(options) { - return options.watch && options.hasOwnProperty("watch"); + ts.updateForIn = updateForIn; + function createForOf(initializer, expression, statement, location) { + var node = createNode(209, location); + node.initializer = initializer; + node.expression = expression; + node.statement = statement; + return node; } - ts.isWatchSet = isWatchSet; -})(ts || (ts = {})); -(function (ts) { - function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; + ts.createForOf = createForOf; + function updateForOf(node, initializer, expression, statement) { + if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { + return updateNode(createForOf(initializer, expression, statement, node), node); + } + return node; } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; + ts.updateForOf = updateForOf; + function createContinue(label, location) { + var node = createNode(210, location); + if (label) { + node.label = label; + } + return node; } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; + ts.createContinue = createContinue; + function updateContinue(node, label) { + if (node.label !== label) { + return updateNode(createContinue(label, node), node); + } + return node; } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); + ts.updateContinue = updateContinue; + function createBreak(label, location) { + var node = createNode(211, location); + if (label) { + node.label = label; + } + return node; } - ts.textSpanContainsPosition = textSpanContainsPosition; - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); + ts.createBreak = createBreak; + function updateBreak(node, label) { + if (node.label !== label) { + return updateNode(createBreak(label, node), node); + } + return node; } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; + ts.updateBreak = updateBreak; + function createReturn(expression, location) { + var node = createNode(212, location); + node.expression = expression; + return node; } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); + ts.createReturn = createReturn; + function updateReturn(node, expression) { + if (node.expression !== expression) { + return updateNode(createReturn(expression, node), node); } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; + return node; } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; + ts.updateReturn = updateReturn; + function createWith(expression, statement, location) { + var node = createNode(213, location); + node.expression = expression; + node.statement = statement; + return node; } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; + ts.createWith = createWith; + function updateWith(node, expression, statement) { + if (node.expression !== expression || node.statement !== statement) { + return updateNode(createWith(expression, statement, node), node); + } + return node; } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; + ts.updateWith = updateWith; + function createSwitch(expression, caseBlock, location) { + var node = createNode(214, location); + node.expression = parenthesizeExpressionForList(expression); + node.caseBlock = caseBlock; + return node; } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); + ts.createSwitch = createSwitch; + function updateSwitch(node, expression, caseBlock) { + if (node.expression !== expression || node.caseBlock !== caseBlock) { + return updateNode(createSwitch(expression, caseBlock, node), node); } - return undefined; + return node; } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); - } - if (length < 0) { - throw new Error("length < 0"); + ts.updateSwitch = updateSwitch; + function createLabel(label, statement, location) { + var node = createNode(215, location); + node.label = typeof label === "string" ? createIdentifier(label) : label; + node.statement = statement; + return node; + } + ts.createLabel = createLabel; + function updateLabel(node, label, statement) { + if (node.label !== label || node.statement !== statement) { + return updateNode(createLabel(label, statement, node), node); } - return { start: start, length: length }; + return node; } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); + ts.updateLabel = updateLabel; + function createThrow(expression, location) { + var node = createNode(216, location); + node.expression = expression; + return node; } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); + ts.createThrow = createThrow; + function updateThrow(node, expression) { + if (node.expression !== expression) { + return updateNode(createThrow(expression, node), node); } - return { span: span, newLength: newLength }; + return node; } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; - } - if (changes.length === 1) { - return changes[0]; - } - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); + ts.updateThrow = updateThrow; + function createTry(tryBlock, catchClause, finallyBlock, location) { + var node = createNode(217, location); + node.tryBlock = tryBlock; + node.catchClause = catchClause; + node.finallyBlock = finallyBlock; + return node; } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 141) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222) { - return current; - } - } + ts.createTry = createTry; + function updateTry(node, tryBlock, catchClause, finallyBlock) { + if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { + return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); } + return node; } - ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 148 && ts.isClassLike(node.parent.parent); + ts.updateTry = updateTry; + function createCaseBlock(clauses, location) { + var node = createNode(228, location); + node.clauses = createNodeArray(clauses); + return node; } - ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 || ts.isBindingPattern(node))) { - node = node.parent; + ts.createCaseBlock = createCaseBlock; + function updateCaseBlock(node, clauses) { + if (node.clauses !== clauses) { + return updateNode(createCaseBlock(clauses, node), node); } return node; } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 218) { - node = node.parent; - } - if (node && node.kind === 219) { - flags |= ts.getModifierFlags(node); - node = node.parent; - } - if (node && node.kind === 200) { - flags |= ts.getModifierFlags(node); - } - return flags; + ts.updateCaseBlock = updateCaseBlock; + function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(221, location, flags); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.asteriskToken = asteriskToken; + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.parameters = createNodeArray(parameters); + node.type = type; + node.body = body; + return node; } - ts.getCombinedModifierFlags = getCombinedModifierFlags; - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 218) { - node = node.parent; - } - if (node && node.kind === 219) { - flags |= node.flags; - node = node.parent; - } - if (node && node.kind === 200) { - flags |= node.flags; + ts.createFunctionDeclaration = createFunctionDeclaration; + function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); } - return flags; - } - ts.getCombinedNodeFlags = getCombinedNodeFlags; -})(ts || (ts = {})); -var ts; -(function (ts) { - var NodeConstructor; - var SourceFileConstructor; - function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 - ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) - : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); - var node = location - ? new ConstructorForKind(kind, location.pos, location.end) - : new ConstructorForKind(kind, -1, -1); - node.flags = flags | 8; return node; } - function updateNode(updated, original) { - if (updated !== original) { - setOriginalNode(updated, original); - if (original.startsOnNewLine) { - updated.startsOnNewLine = true; - } - ts.aggregateTransformFlags(updated); - } - return updated; + ts.updateFunctionDeclaration = updateFunctionDeclaration; + function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { + var node = createNode(222, location); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.name = name; + node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; + node.heritageClauses = createNodeArray(heritageClauses); + node.members = createNodeArray(members); + return node; } - ts.updateNode = updateNode; - function createNodeArray(elements, location, hasTrailingComma) { - if (elements) { - if (ts.isNodeArray(elements)) { - return elements; - } - } - else { - elements = []; - } - var array = elements; - if (location) { - array.pos = location.pos; - array.end = location.end; - } - else { - array.pos = -1; - array.end = -1; - } - if (hasTrailingComma) { - array.hasTrailingComma = true; + ts.createClassDeclaration = createClassDeclaration; + function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { + return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); } - return array; - } - ts.createNodeArray = createNodeArray; - function createSynthesizedNode(kind, startsOnNewLine) { - var node = createNode(kind, undefined); - node.startsOnNewLine = startsOnNewLine; return node; } - ts.createSynthesizedNode = createSynthesizedNode; - function createSynthesizedNodeArray(elements) { - return createNodeArray(elements, undefined); + ts.updateClassDeclaration = updateClassDeclaration; + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { + var node = createNode(231, location); + node.decorators = decorators ? createNodeArray(decorators) : undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; + node.importClause = importClause; + node.moduleSpecifier = moduleSpecifier; + return node; } - ts.createSynthesizedNodeArray = createSynthesizedNodeArray; - function getSynthesizedClone(node) { - var clone = createNode(node.kind, undefined, node.flags); - setOriginalNode(clone, node); - for (var key in node) { - if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { - continue; - } - clone[key] = node[key]; + ts.createImportDeclaration = createImportDeclaration; + function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { + return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); } - return clone; + return node; } - ts.getSynthesizedClone = getSynthesizedClone; - function getMutableClone(node) { - var clone = getSynthesizedClone(node); - clone.pos = node.pos; - clone.end = node.end; - clone.parent = node.parent; - return clone; + ts.updateImportDeclaration = updateImportDeclaration; + function createImportClause(name, namedBindings, location) { + var node = createNode(232, location); + node.name = name; + node.namedBindings = namedBindings; + return node; } - ts.getMutableClone = getMutableClone; - function createLiteral(value, location) { - if (typeof value === "number") { - var node = createNode(8, location, undefined); - node.text = value.toString(); - return node; - } - else if (typeof value === "boolean") { - return createNode(value ? 99 : 84, location, undefined); - } - else if (typeof value === "string") { - var node = createNode(9, location, undefined); - node.text = value; - return node; - } - else if (value) { - var node = createNode(9, location, undefined); - node.textSourceNode = value; - node.text = value.text; - return node; + ts.createImportClause = createImportClause; + function updateImportClause(node, name, namedBindings) { + if (node.name !== name || node.namedBindings !== namedBindings) { + return updateNode(createImportClause(name, namedBindings, node), node); } + return node; } - ts.createLiteral = createLiteral; - var nextAutoGenerateId = 0; - function createIdentifier(text, location) { - var node = createNode(69, location); - node.text = ts.escapeIdentifier(text); - node.originalKeywordKind = ts.stringToToken(text); - node.autoGenerateKind = 0; - node.autoGenerateId = 0; + ts.updateImportClause = updateImportClause; + function createNamespaceImport(name, location) { + var node = createNode(233, location); + node.name = name; return node; } - ts.createIdentifier = createIdentifier; - function createTempVariable(recordTempVariable, location) { - var name = createNode(69, location); - name.text = ""; - name.originalKeywordKind = 0; - name.autoGenerateKind = 1; - name.autoGenerateId = nextAutoGenerateId; - nextAutoGenerateId++; - if (recordTempVariable) { - recordTempVariable(name); + ts.createNamespaceImport = createNamespaceImport; + function updateNamespaceImport(node, name) { + if (node.name !== name) { + return updateNode(createNamespaceImport(name, node), node); } - return name; - } - ts.createTempVariable = createTempVariable; - function createLoopVariable(location) { - var name = createNode(69, location); - name.text = ""; - name.originalKeywordKind = 0; - name.autoGenerateKind = 2; - name.autoGenerateId = nextAutoGenerateId; - nextAutoGenerateId++; - return name; - } - ts.createLoopVariable = createLoopVariable; - function createUniqueName(text, location) { - var name = createNode(69, location); - name.text = text; - name.originalKeywordKind = 0; - name.autoGenerateKind = 3; - name.autoGenerateId = nextAutoGenerateId; - nextAutoGenerateId++; - return name; - } - ts.createUniqueName = createUniqueName; - function getGeneratedNameForNode(node, location) { - var name = createNode(69, location); - name.original = node; - name.text = ""; - name.originalKeywordKind = 0; - name.autoGenerateKind = 4; - name.autoGenerateId = nextAutoGenerateId; - nextAutoGenerateId++; - return name; - } - ts.getGeneratedNameForNode = getGeneratedNameForNode; - function createToken(token) { - return createNode(token); - } - ts.createToken = createToken; - function createSuper() { - var node = createNode(95); return node; } - ts.createSuper = createSuper; - function createThis(location) { - var node = createNode(97, location); + ts.updateNamespaceImport = updateNamespaceImport; + function createNamedImports(elements, location) { + var node = createNode(234, location); + node.elements = createNodeArray(elements); return node; } - ts.createThis = createThis; - function createNull() { - var node = createNode(93); + ts.createNamedImports = createNamedImports; + function updateNamedImports(node, elements) { + if (node.elements !== elements) { + return updateNode(createNamedImports(elements, node), node); + } return node; } - ts.createNull = createNull; - function createComputedPropertyName(expression, location) { - var node = createNode(140, location); - node.expression = expression; + ts.updateNamedImports = updateNamedImports; + function createImportSpecifier(propertyName, name, location) { + var node = createNode(235, location); + node.propertyName = propertyName; + node.name = name; return node; } - ts.createComputedPropertyName = createComputedPropertyName; - function updateComputedPropertyName(node, expression) { - if (node.expression !== expression) { - return updateNode(createComputedPropertyName(expression, node), node); + ts.createImportSpecifier = createImportSpecifier; + function updateImportSpecifier(node, propertyName, name) { + if (node.propertyName !== propertyName || node.name !== name) { + return updateNode(createImportSpecifier(propertyName, name, node), node); } return node; } - ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(name, initializer, location) { - return createParameterDeclaration(undefined, undefined, undefined, name, undefined, undefined, initializer, location); - } - ts.createParameter = createParameter; - function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142, location, flags); + ts.updateImportSpecifier = updateImportSpecifier; + function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.questionToken = questionToken; - node.type = type; - node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; + node.isExportEquals = isExportEquals; + node.expression = expression; return node; } - ts.createParameterDeclaration = createParameterDeclaration; - function updateParameterDeclaration(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameterDeclaration(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); + ts.createExportAssignment = createExportAssignment; + function updateExportAssignment(node, decorators, modifiers, expression) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { + return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); } return node; } - ts.updateParameterDeclaration = updateParameterDeclaration; - function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145, location); + ts.updateExportAssignment = updateExportAssignment; + function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { + var node = createNode(237, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.questionToken = questionToken; - node.type = type; - node.initializer = initializer; + node.exportClause = exportClause; + node.moduleSpecifier = moduleSpecifier; return node; } - ts.createProperty = createProperty; - function updateProperty(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createProperty(decorators, modifiers, name, node.questionToken, type, initializer, node), node); + ts.createExportDeclaration = createExportDeclaration; + function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { + return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); } return node; } - ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.parameters = createNodeArray(parameters); - node.type = type; - node.body = body; + ts.updateExportDeclaration = updateExportDeclaration; + function createNamedExports(elements, location) { + var node = createNode(238, location); + node.elements = createNodeArray(elements); return node; } - ts.createMethod = createMethod; - function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + ts.createNamedExports = createNamedExports; + function updateNamedExports(node, elements) { + if (node.elements !== elements) { + return updateNode(createNamedExports(elements, node), node); } return node; } - ts.updateMethod = updateMethod; - function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = undefined; - node.parameters = createNodeArray(parameters); - node.type = undefined; - node.body = body; + ts.updateNamedExports = updateNamedExports; + function createExportSpecifier(name, propertyName, location) { + var node = createNode(239, location); + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; } - ts.createConstructor = createConstructor; - function updateConstructor(node, decorators, modifiers, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body) { - return updateNode(createConstructor(decorators, modifiers, parameters, body, node, node.flags), node); + ts.createExportSpecifier = createExportSpecifier; + function updateExportSpecifier(node, name, propertyName) { + if (node.name !== name || node.propertyName !== propertyName) { + return updateNode(createExportSpecifier(name, propertyName, node), node); } return node; } - ts.updateConstructor = updateConstructor; - function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = undefined; - node.parameters = createNodeArray(parameters); - node.type = type; - node.body = body; + ts.updateExportSpecifier = updateExportSpecifier; + function createJsxElement(openingElement, children, closingElement, location) { + var node = createNode(242, location); + node.openingElement = openingElement; + node.children = createNodeArray(children); + node.closingElement = closingElement; return node; } - ts.createGetAccessor = createGetAccessor; - function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body, node, node.flags), node); + ts.createJsxElement = createJsxElement; + function updateJsxElement(node, openingElement, children, closingElement) { + if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { + return updateNode(createJsxElement(openingElement, children, closingElement, node), node); } return node; } - ts.updateGetAccessor = updateGetAccessor; - function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = undefined; - node.parameters = createNodeArray(parameters); - node.body = body; + ts.updateJsxElement = updateJsxElement; + function createJsxSelfClosingElement(tagName, attributes, location) { + var node = createNode(243, location); + node.tagName = tagName; + node.attributes = createNodeArray(attributes); return node; } - ts.createSetAccessor = createSetAccessor; - function updateSetAccessor(node, decorators, modifiers, name, parameters, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body) { - return updateNode(createSetAccessor(decorators, modifiers, name, parameters, body, node, node.flags), node); + ts.createJsxSelfClosingElement = createJsxSelfClosingElement; + function updateJsxSelfClosingElement(node, tagName, attributes) { + if (node.tagName !== tagName || node.attributes !== attributes) { + return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); } return node; } - ts.updateSetAccessor = updateSetAccessor; - function createObjectBindingPattern(elements, location) { - var node = createNode(167, location); - node.elements = createNodeArray(elements); + ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; + function createJsxOpeningElement(tagName, attributes, location) { + var node = createNode(244, location); + node.tagName = tagName; + node.attributes = createNodeArray(attributes); return node; } - ts.createObjectBindingPattern = createObjectBindingPattern; - function updateObjectBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createObjectBindingPattern(elements, node), node); + ts.createJsxOpeningElement = createJsxOpeningElement; + function updateJsxOpeningElement(node, tagName, attributes) { + if (node.tagName !== tagName || node.attributes !== attributes) { + return updateNode(createJsxOpeningElement(tagName, attributes, node), node); } return node; } - ts.updateObjectBindingPattern = updateObjectBindingPattern; - function createArrayBindingPattern(elements, location) { - var node = createNode(168, location); - node.elements = createNodeArray(elements); + ts.updateJsxOpeningElement = updateJsxOpeningElement; + function createJsxClosingElement(tagName, location) { + var node = createNode(245, location); + node.tagName = tagName; return node; } - ts.createArrayBindingPattern = createArrayBindingPattern; - function updateArrayBindingPattern(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayBindingPattern(elements, node), node); + ts.createJsxClosingElement = createJsxClosingElement; + function updateJsxClosingElement(node, tagName) { + if (node.tagName !== tagName) { + return updateNode(createJsxClosingElement(tagName, node), node); } return node; } - ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169, location); - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; - node.dotDotDotToken = dotDotDotToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; + ts.updateJsxClosingElement = updateJsxClosingElement; + function createJsxAttribute(name, initializer, location) { + var node = createNode(246, location); + node.name = name; node.initializer = initializer; return node; } - ts.createBindingElement = createBindingElement; - function updateBindingElement(node, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, node.dotDotDotToken, name, initializer, node), node); + ts.createJsxAttribute = createJsxAttribute; + function updateJsxAttribute(node, name, initializer) { + if (node.name !== name || node.initializer !== initializer) { + return updateNode(createJsxAttribute(name, initializer, node), node); } return node; } - ts.updateBindingElement = updateBindingElement; - function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170, location); - node.elements = parenthesizeListElements(createNodeArray(elements)); - if (multiLine) { - node.multiLine = true; - } - return node; - } - ts.createArrayLiteral = createArrayLiteral; - function updateArrayLiteral(node, elements) { - if (node.elements !== elements) { - return updateNode(createArrayLiteral(elements, node, node.multiLine), node); - } - return node; - } - ts.updateArrayLiteral = updateArrayLiteral; - function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171, location); - node.properties = createNodeArray(properties); - if (multiLine) { - node.multiLine = true; - } + ts.updateJsxAttribute = updateJsxAttribute; + function createJsxSpreadAttribute(expression, location) { + var node = createNode(247, location); + node.expression = expression; return node; } - ts.createObjectLiteral = createObjectLiteral; - function updateObjectLiteral(node, properties) { - if (node.properties !== properties) { - return updateNode(createObjectLiteral(properties, node, node.multiLine), node); + ts.createJsxSpreadAttribute = createJsxSpreadAttribute; + function updateJsxSpreadAttribute(node, expression) { + if (node.expression !== expression) { + return updateNode(createJsxSpreadAttribute(expression, node), node); } return node; } - ts.updateObjectLiteral = updateObjectLiteral; - function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172, location, flags); - node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 1048576; - node.name = typeof name === "string" ? createIdentifier(name) : name; + ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; + function createJsxExpression(expression, location) { + var node = createNode(248, location); + node.expression = expression; return node; } - ts.createPropertyAccess = createPropertyAccess; - function updatePropertyAccess(node, expression, name) { - if (node.expression !== expression || node.name !== name) { - var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); - return updateNode(propertyAccess, node); + ts.createJsxExpression = createJsxExpression; + function updateJsxExpression(node, expression) { + if (node.expression !== expression) { + return updateNode(createJsxExpression(expression, node), node); } return node; } - ts.updatePropertyAccess = updatePropertyAccess; - function createElementAccess(expression, index, location) { - var node = createNode(173, location); - node.expression = parenthesizeForAccess(expression); - node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; + ts.updateJsxExpression = updateJsxExpression; + function createHeritageClause(token, types, location) { + var node = createNode(251, location); + node.token = token; + node.types = createNodeArray(types); return node; } - ts.createElementAccess = createElementAccess; - function updateElementAccess(node, expression, argumentExpression) { - if (node.expression !== expression || node.argumentExpression !== argumentExpression) { - return updateNode(createElementAccess(expression, argumentExpression, node), node); + ts.createHeritageClause = createHeritageClause; + function updateHeritageClause(node, types) { + if (node.types !== types) { + return updateNode(createHeritageClause(node.token, types, node), node); } return node; } - ts.updateElementAccess = updateElementAccess; - function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174, location, flags); - node.expression = parenthesizeForAccess(expression); - if (typeArguments) { - node.typeArguments = createNodeArray(typeArguments); - } - node.arguments = parenthesizeListElements(createNodeArray(argumentsArray)); + ts.updateHeritageClause = updateHeritageClause; + function createCaseClause(expression, statements, location) { + var node = createNode(249, location); + node.expression = parenthesizeExpressionForList(expression); + node.statements = createNodeArray(statements); return node; } - ts.createCall = createCall; - function updateCall(node, expression, typeArguments, argumentsArray) { - if (expression !== node.expression || typeArguments !== node.typeArguments || argumentsArray !== node.arguments) { - return updateNode(createCall(expression, typeArguments, argumentsArray, node, node.flags), node); + ts.createCaseClause = createCaseClause; + function updateCaseClause(node, expression, statements) { + if (node.expression !== expression || node.statements !== statements) { + return updateNode(createCaseClause(expression, statements, node), node); } return node; } - ts.updateCall = updateCall; - function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); - node.expression = parenthesizeForNew(expression); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; + ts.updateCaseClause = updateCaseClause; + function createDefaultClause(statements, location) { + var node = createNode(250, location); + node.statements = createNodeArray(statements); return node; } - ts.createNew = createNew; - function updateNew(node, expression, typeArguments, argumentsArray) { - if (node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray) { - return updateNode(createNew(expression, typeArguments, argumentsArray, node, node.flags), node); + ts.createDefaultClause = createDefaultClause; + function updateDefaultClause(node, statements) { + if (node.statements !== statements) { + return updateNode(createDefaultClause(statements, node), node); } return node; } - ts.updateNew = updateNew; - function createTaggedTemplate(tag, template, location) { - var node = createNode(176, location); - node.tag = parenthesizeForAccess(tag); - node.template = template; + ts.updateDefaultClause = updateDefaultClause; + function createCatchClause(variableDeclaration, block, location) { + var node = createNode(252, location); + node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; + node.block = block; return node; } - ts.createTaggedTemplate = createTaggedTemplate; - function updateTaggedTemplate(node, tag, template) { - if (node.tag !== tag || node.template !== template) { - return updateNode(createTaggedTemplate(tag, template, node), node); + ts.createCatchClause = createCatchClause; + function updateCatchClause(node, variableDeclaration, block) { + if (node.variableDeclaration !== variableDeclaration || node.block !== block) { + return updateNode(createCatchClause(variableDeclaration, block, node), node); } return node; } - ts.updateTaggedTemplate = updateTaggedTemplate; - function createParen(expression, location) { - var node = createNode(178, location); - node.expression = expression; + ts.updateCatchClause = updateCatchClause; + function createPropertyAssignment(name, initializer, location) { + var node = createNode(253, location); + node.name = typeof name === "string" ? createIdentifier(name) : name; + node.questionToken = undefined; + node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; return node; } - ts.createParen = createParen; - function updateParen(node, expression) { - if (node.expression !== expression) { - return updateNode(createParen(expression, node), node); + ts.createPropertyAssignment = createPropertyAssignment; + function updatePropertyAssignment(node, name, initializer) { + if (node.name !== name || node.initializer !== initializer) { + return updateNode(createPropertyAssignment(name, initializer, node), node); } return node; } - ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179, location, flags); - node.modifiers = undefined; - node.asteriskToken = asteriskToken; + ts.updatePropertyAssignment = updatePropertyAssignment; + function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { + var node = createNode(254, location); node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.parameters = createNodeArray(parameters); - node.type = type; - node.body = body; + node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } - ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; + function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { + if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { + return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); } return node; } - ts.updateFunctionExpression = updateFunctionExpression; - function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180, location, flags); - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.parameters = createNodeArray(parameters); - node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); - node.body = parenthesizeConciseBody(body); - return node; - } - ts.createArrowFunction = createArrowFunction; - function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { - if (node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body, node, node.flags), node); + ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function updateSourceFileNode(node, statements) { + if (node.statements !== statements) { + var updated = createNode(256, node, node.flags); + updated.statements = createNodeArray(statements); + updated.endOfFileToken = node.endOfFileToken; + updated.fileName = node.fileName; + updated.path = node.path; + updated.text = node.text; + if (node.amdDependencies !== undefined) + updated.amdDependencies = node.amdDependencies; + if (node.moduleName !== undefined) + updated.moduleName = node.moduleName; + if (node.referencedFiles !== undefined) + updated.referencedFiles = node.referencedFiles; + if (node.typeReferenceDirectives !== undefined) + updated.typeReferenceDirectives = node.typeReferenceDirectives; + if (node.languageVariant !== undefined) + updated.languageVariant = node.languageVariant; + if (node.isDeclarationFile !== undefined) + updated.isDeclarationFile = node.isDeclarationFile; + if (node.renamedDependencies !== undefined) + updated.renamedDependencies = node.renamedDependencies; + if (node.hasNoDefaultLib !== undefined) + updated.hasNoDefaultLib = node.hasNoDefaultLib; + if (node.languageVersion !== undefined) + updated.languageVersion = node.languageVersion; + if (node.scriptKind !== undefined) + updated.scriptKind = node.scriptKind; + if (node.externalModuleIndicator !== undefined) + updated.externalModuleIndicator = node.externalModuleIndicator; + if (node.commonJsModuleIndicator !== undefined) + updated.commonJsModuleIndicator = node.commonJsModuleIndicator; + if (node.identifiers !== undefined) + updated.identifiers = node.identifiers; + if (node.nodeCount !== undefined) + updated.nodeCount = node.nodeCount; + if (node.identifierCount !== undefined) + updated.identifierCount = node.identifierCount; + if (node.symbolCount !== undefined) + updated.symbolCount = node.symbolCount; + if (node.parseDiagnostics !== undefined) + updated.parseDiagnostics = node.parseDiagnostics; + if (node.bindDiagnostics !== undefined) + updated.bindDiagnostics = node.bindDiagnostics; + if (node.lineMap !== undefined) + updated.lineMap = node.lineMap; + if (node.classifiableNames !== undefined) + updated.classifiableNames = node.classifiableNames; + if (node.resolvedModules !== undefined) + updated.resolvedModules = node.resolvedModules; + if (node.resolvedTypeReferenceDirectiveNames !== undefined) + updated.resolvedTypeReferenceDirectiveNames = node.resolvedTypeReferenceDirectiveNames; + if (node.imports !== undefined) + updated.imports = node.imports; + if (node.moduleAugmentations !== undefined) + updated.moduleAugmentations = node.moduleAugmentations; + if (node.externalHelpersModuleName !== undefined) + updated.externalHelpersModuleName = node.externalHelpersModuleName; + return updateNode(updated, node); } return node; } - ts.updateArrowFunction = updateArrowFunction; - function createDelete(expression, location) { - var node = createNode(181, location); - node.expression = parenthesizePrefixOperand(expression); - return node; - } - ts.createDelete = createDelete; - function updateDelete(node, expression) { - if (node.expression !== expression) { - return updateNode(createDelete(expression, node), expression); - } + ts.updateSourceFileNode = updateSourceFileNode; + function createNotEmittedStatement(original) { + var node = createNode(287, original); + node.original = original; return node; } - ts.updateDelete = updateDelete; - function createTypeOf(expression, location) { - var node = createNode(182, location); - node.expression = parenthesizePrefixOperand(expression); + ts.createNotEmittedStatement = createNotEmittedStatement; + function createPartiallyEmittedExpression(expression, original, location) { + var node = createNode(288, location || original); + node.expression = expression; + node.original = original; return node; } - ts.createTypeOf = createTypeOf; - function updateTypeOf(node, expression) { + ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; + function updatePartiallyEmittedExpression(node, expression) { if (node.expression !== expression) { - return updateNode(createTypeOf(expression, node), expression); + return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); } return node; } - ts.updateTypeOf = updateTypeOf; - function createVoid(expression, location) { - var node = createNode(183, location); - node.expression = parenthesizePrefixOperand(expression); - return node; - } - ts.createVoid = createVoid; - function updateVoid(node, expression) { - if (node.expression !== expression) { - return updateNode(createVoid(expression, node), node); - } - return node; + ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; + function createComma(left, right) { + return createBinary(left, 25, right); } - ts.updateVoid = updateVoid; - function createAwait(expression, location) { - var node = createNode(184, location); - node.expression = parenthesizePrefixOperand(expression); - return node; + ts.createComma = createComma; + function createLessThan(left, right, location) { + return createBinary(left, 26, right, location); } - ts.createAwait = createAwait; - function updateAwait(node, expression) { - if (node.expression !== expression) { - return updateNode(createAwait(expression, node), node); - } - return node; + ts.createLessThan = createLessThan; + function createAssignment(left, right, location) { + return createBinary(left, 57, right, location); } - ts.updateAwait = updateAwait; - function createPrefix(operator, operand, location) { - var node = createNode(185, location); - node.operator = operator; - node.operand = parenthesizePrefixOperand(operand); - return node; + ts.createAssignment = createAssignment; + function createStrictEquality(left, right) { + return createBinary(left, 33, right); } - ts.createPrefix = createPrefix; - function updatePrefix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPrefix(node.operator, operand, node), node); - } - return node; + ts.createStrictEquality = createStrictEquality; + function createStrictInequality(left, right) { + return createBinary(left, 34, right); } - ts.updatePrefix = updatePrefix; - function createPostfix(operand, operator, location) { - var node = createNode(186, location); - node.operand = parenthesizePostfixOperand(operand); - node.operator = operator; - return node; + ts.createStrictInequality = createStrictInequality; + function createAdd(left, right) { + return createBinary(left, 36, right); } - ts.createPostfix = createPostfix; - function updatePostfix(node, operand) { - if (node.operand !== operand) { - return updateNode(createPostfix(operand, node.operator, node), node); - } - return node; + ts.createAdd = createAdd; + function createSubtract(left, right) { + return createBinary(left, 37, right); } - ts.updatePostfix = updatePostfix; - function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createToken(operator) : operator; - var operatorKind = operatorToken.kind; - var node = createNode(187, location); - node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); - node.operatorToken = operatorToken; - node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); - return node; + ts.createSubtract = createSubtract; + function createPostfixIncrement(operand, location) { + return createPostfix(operand, 42, location); } - ts.createBinary = createBinary; - function updateBinary(node, left, right) { - if (node.left !== left || node.right !== right) { - return updateNode(createBinary(left, node.operatorToken, right, node), node); - } - return node; + ts.createPostfixIncrement = createPostfixIncrement; + function createLogicalAnd(left, right) { + return createBinary(left, 52, right); } - ts.updateBinary = updateBinary; - function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188, location); - node.condition = condition; - node.questionToken = questionToken; - node.whenTrue = whenTrue; - node.colonToken = colonToken; - node.whenFalse = whenFalse; - return node; + ts.createLogicalAnd = createLogicalAnd; + function createLogicalOr(left, right) { + return createBinary(left, 53, right); } - ts.createConditional = createConditional; - function updateConditional(node, condition, whenTrue, whenFalse) { - if (node.condition !== condition || node.whenTrue !== whenTrue || node.whenFalse !== whenFalse) { - return updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse, node), node); - } - return node; + ts.createLogicalOr = createLogicalOr; + function createLogicalNot(operand) { + return createPrefix(50, operand); } - ts.updateConditional = updateConditional; - function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189, location); - node.head = head; - node.templateSpans = createNodeArray(templateSpans); - return node; + ts.createLogicalNot = createLogicalNot; + function createVoidZero() { + return createVoid(createLiteral(0)); } - ts.createTemplateExpression = createTemplateExpression; - function updateTemplateExpression(node, head, templateSpans) { - if (node.head !== head || node.templateSpans !== templateSpans) { - return updateNode(createTemplateExpression(head, templateSpans, node), node); + ts.createVoidZero = createVoidZero; + function createMemberAccessForPropertyName(target, memberName, location) { + if (ts.isComputedPropertyName(memberName)) { + return createElementAccess(target, memberName.expression, location); } - return node; - } - ts.updateTemplateExpression = updateTemplateExpression; - function createYield(asteriskToken, expression, location) { - var node = createNode(190, location); - node.asteriskToken = asteriskToken; - node.expression = expression; - return node; - } - ts.createYield = createYield; - function updateYield(node, expression) { - if (node.expression !== expression) { - return updateNode(createYield(node.asteriskToken, expression, node), node); + else { + var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); + (expression.emitNode || (expression.emitNode = {})).flags |= 2048; + return expression; } - return node; } - ts.updateYield = updateYield; - function createSpread(expression, location) { - var node = createNode(191, location); - node.expression = parenthesizeExpressionForList(expression); - return node; + ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; + function createRestParameter(name) { + return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); } - ts.createSpread = createSpread; - function updateSpread(node, expression) { - if (node.expression !== expression) { - return updateNode(createSpread(expression, node), node); - } - return node; + ts.createRestParameter = createRestParameter; + function createFunctionCall(func, thisArg, argumentsList, location) { + return createCall(createPropertyAccess(func, "call"), undefined, [ + thisArg + ].concat(argumentsList), location); } - ts.updateSpread = updateSpread; - function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192, location); - node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); - node.members = createNodeArray(members); - return node; + ts.createFunctionCall = createFunctionCall; + function createFunctionApply(func, thisArg, argumentsExpression, location) { + return createCall(createPropertyAccess(func, "apply"), undefined, [ + thisArg, + argumentsExpression + ], location); } - ts.createClassExpression = createClassExpression; - function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) { - if (node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members, node), node); + ts.createFunctionApply = createFunctionApply; + function createArraySlice(array, start) { + var argumentsList = []; + if (start !== undefined) { + argumentsList.push(typeof start === "number" ? createLiteral(start) : start); } - return node; - } - ts.updateClassExpression = updateClassExpression; - function createOmittedExpression(location) { - var node = createNode(193, location); - return node; + return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); } - ts.createOmittedExpression = createOmittedExpression; - function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194, location); - node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; - node.expression = parenthesizeForAccess(expression); - return node; + ts.createArraySlice = createArraySlice; + function createArrayConcat(array, values) { + return createCall(createPropertyAccess(array, "concat"), undefined, values); } - ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node, typeArguments, expression) { - if (node.typeArguments !== typeArguments || node.expression !== expression) { - return updateNode(createExpressionWithTypeArguments(typeArguments, expression, node), node); - } - return node; + ts.createArrayConcat = createArrayConcat; + function createMathPow(left, right, location) { + return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); } - ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; - function createTemplateSpan(expression, literal, location) { - var node = createNode(197, location); - node.expression = expression; - node.literal = literal; - return node; + ts.createMathPow = createMathPow; + function createReactNamespace(reactNamespace, parent) { + var react = createIdentifier(reactNamespace || "React"); + react.flags &= ~8; + react.parent = parent; + return react; } - ts.createTemplateSpan = createTemplateSpan; - function updateTemplateSpan(node, expression, literal) { - if (node.expression !== expression || node.literal !== literal) { - return updateNode(createTemplateSpan(expression, literal, node), node); + function createReactCreateElement(reactNamespace, tagName, props, children, parentElement, location) { + var argumentsList = [tagName]; + if (props) { + argumentsList.push(props); } - return node; - } - ts.updateTemplateSpan = updateTemplateSpan; - function createBlock(statements, location, multiLine, flags) { - var block = createNode(199, location, flags); - block.statements = createNodeArray(statements); - if (multiLine) { - block.multiLine = true; + if (children && children.length > 0) { + if (!props) { + argumentsList.push(createNull()); + } + if (children.length > 1) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + child.startsOnNewLine = true; + argumentsList.push(child); + } + } + else { + argumentsList.push(children[0]); + } } - return block; + return createCall(createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "createElement"), undefined, argumentsList, location); } - ts.createBlock = createBlock; - function updateBlock(node, statements) { - if (statements !== node.statements) { - return updateNode(createBlock(statements, node, node.multiLine, node.flags), node); - } - return node; + ts.createReactCreateElement = createReactCreateElement; + function createLetDeclarationList(declarations, location) { + return createVariableDeclarationList(declarations, location, 1); } - ts.updateBlock = updateBlock; - function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200, location, flags); - node.decorators = undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; - return node; - } - ts.createVariableStatement = createVariableStatement; - function updateVariableStatement(node, modifiers, declarationList) { - if (node.modifiers !== modifiers || node.declarationList !== declarationList) { - return updateNode(createVariableStatement(modifiers, declarationList, node, node.flags), node); - } - return node; - } - ts.updateVariableStatement = updateVariableStatement; - function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219, location, flags); - node.declarations = createNodeArray(declarations); - return node; + ts.createLetDeclarationList = createLetDeclarationList; + function createConstDeclarationList(declarations, location) { + return createVariableDeclarationList(declarations, location, 2); } - ts.createVariableDeclarationList = createVariableDeclarationList; - function updateVariableDeclarationList(node, declarations) { - if (node.declarations !== declarations) { - return updateNode(createVariableDeclarationList(declarations, node, node.flags), node); - } - return node; + ts.createConstDeclarationList = createConstDeclarationList; + function createHelperName(externalHelpersModuleName, name) { + return externalHelpersModuleName + ? createPropertyAccess(externalHelpersModuleName, name) + : createIdentifier(name); } - ts.updateVariableDeclarationList = updateVariableDeclarationList; - function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218, location, flags); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; - return node; + ts.createHelperName = createHelperName; + function createExtendsHelper(externalHelpersModuleName, name) { + return createCall(createHelperName(externalHelpersModuleName, "__extends"), undefined, [ + name, + createIdentifier("_super") + ]); } - ts.createVariableDeclaration = createVariableDeclaration; - function updateVariableDeclaration(node, name, type, initializer) { - if (node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createVariableDeclaration(name, type, initializer, node, node.flags), node); - } - return node; + ts.createExtendsHelper = createExtendsHelper; + function createAssignHelper(externalHelpersModuleName, attributesSegments) { + return createCall(createHelperName(externalHelpersModuleName, "__assign"), undefined, attributesSegments); } - ts.updateVariableDeclaration = updateVariableDeclaration; - function createEmptyStatement(location) { - return createNode(201, location); + ts.createAssignHelper = createAssignHelper; + function createParamHelper(externalHelpersModuleName, expression, parameterOffset, location) { + return createCall(createHelperName(externalHelpersModuleName, "__param"), undefined, [ + createLiteral(parameterOffset), + expression + ], location); } - ts.createEmptyStatement = createEmptyStatement; - function createStatement(expression, location, flags) { - var node = createNode(202, location, flags); - node.expression = parenthesizeExpressionForExpressionStatement(expression); - return node; + ts.createParamHelper = createParamHelper; + function createMetadataHelper(externalHelpersModuleName, metadataKey, metadataValue) { + return createCall(createHelperName(externalHelpersModuleName, "__metadata"), undefined, [ + createLiteral(metadataKey), + metadataValue + ]); } - ts.createStatement = createStatement; - function updateStatement(node, expression) { - if (node.expression !== expression) { - return updateNode(createStatement(expression, node, node.flags), node); + ts.createMetadataHelper = createMetadataHelper; + function createDecorateHelper(externalHelpersModuleName, decoratorExpressions, target, memberName, descriptor, location) { + var argumentsArray = []; + argumentsArray.push(createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(target); + if (memberName) { + argumentsArray.push(memberName); + if (descriptor) { + argumentsArray.push(descriptor); + } } - return node; + return createCall(createHelperName(externalHelpersModuleName, "__decorate"), undefined, argumentsArray, location); } - ts.updateStatement = updateStatement; - function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203, location); - node.expression = expression; - node.thenStatement = thenStatement; - node.elseStatement = elseStatement; - return node; + ts.createDecorateHelper = createDecorateHelper; + function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { + var generatorFunc = createFunctionExpression(undefined, createToken(38), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; + return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ + createThis(), + hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(), + promiseConstructor ? createExpressionFromEntityName(promiseConstructor) : createVoidZero(), + generatorFunc + ]); } - ts.createIf = createIf; - function updateIf(node, expression, thenStatement, elseStatement) { - if (node.expression !== expression || node.thenStatement !== thenStatement || node.elseStatement !== elseStatement) { - return updateNode(createIf(expression, thenStatement, elseStatement, node), node); - } - return node; + ts.createAwaiterHelper = createAwaiterHelper; + function createHasOwnProperty(target, propertyName) { + return createCall(createPropertyAccess(target, "hasOwnProperty"), undefined, [propertyName]); } - ts.updateIf = updateIf; - function createDo(statement, expression, location) { - var node = createNode(204, location); - node.statement = statement; - node.expression = expression; - return node; + ts.createHasOwnProperty = createHasOwnProperty; + function createObjectCreate(prototype) { + return createCall(createPropertyAccess(createIdentifier("Object"), "create"), undefined, [prototype]); } - ts.createDo = createDo; - function updateDo(node, statement, expression) { - if (node.statement !== statement || node.expression !== expression) { - return updateNode(createDo(statement, expression, node), node); - } - return node; + function createGeti(target) { + return createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createElementAccess(target, createIdentifier("name"))); } - ts.updateDo = updateDo; - function createWhile(expression, statement, location) { - var node = createNode(205, location); - node.expression = expression; - node.statement = statement; - return node; + function createSeti(target) { + return createArrowFunction(undefined, undefined, [ + createParameter("name"), + createParameter("value") + ], undefined, undefined, createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); } - ts.createWhile = createWhile; - function updateWhile(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWhile(expression, statement, node), node); - } - return node; + function createAdvancedAsyncSuperHelper() { + var createCache = createVariableStatement(undefined, createConstDeclarationList([ + createVariableDeclaration("cache", undefined, createObjectCreate(createNull())) + ])); + var getter = createGetAccessor(undefined, undefined, "value", [], undefined, createBlock([ + createReturn(createCall(createIdentifier("geti"), undefined, [createIdentifier("name")])) + ])); + var setter = createSetAccessor(undefined, undefined, "value", [createParameter("v")], createBlock([ + createStatement(createCall(createIdentifier("seti"), undefined, [ + createIdentifier("name"), + createIdentifier("v") + ])) + ])); + var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ + getter, + setter + ])))))); + return createVariableStatement(undefined, createConstDeclarationList([ + createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ + createParameter("geti"), + createParameter("seti") + ], undefined, createBlock([ + createCache, + getOrCreateAccessorsForName + ]))), undefined, [ + createGeti(createSuper()), + createSeti(createSuper()) + ])) + ])); } - ts.updateWhile = updateWhile; - function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206, location, undefined); - node.initializer = initializer; - node.condition = condition; - node.incrementor = incrementor; - node.statement = statement; - return node; + ts.createAdvancedAsyncSuperHelper = createAdvancedAsyncSuperHelper; + function createSimpleAsyncSuperHelper() { + return createVariableStatement(undefined, createConstDeclarationList([ + createVariableDeclaration("_super", undefined, createGeti(createSuper())) + ])); } - ts.createFor = createFor; - function updateFor(node, initializer, condition, incrementor, statement) { - if (node.initializer !== initializer || node.condition !== condition || node.incrementor !== incrementor || node.statement !== statement) { - return updateNode(createFor(initializer, condition, incrementor, statement, node), node); + ts.createSimpleAsyncSuperHelper = createSimpleAsyncSuperHelper; + function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { + var target = skipParentheses(node); + switch (target.kind) { + case 70: + return cacheIdentifiers; + case 98: + case 8: + case 9: + return false; + case 171: + var elements = target.elements; + if (elements.length === 0) { + return false; + } + return true; + case 172: + return target.properties.length > 0; + default: + return true; } - return node; - } - ts.updateFor = updateFor; - function createForIn(initializer, expression, statement, location) { - var node = createNode(207, location); - node.initializer = initializer; - node.expression = expression; - node.statement = statement; - return node; } - ts.createForIn = createForIn; - function updateForIn(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForIn(initializer, expression, statement, node), node); + function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + var callee = skipOuterExpressions(expression, 7); + var thisArg; + var target; + if (ts.isSuperProperty(callee)) { + thisArg = createThis(); + target = callee; } - return node; + else if (callee.kind === 96) { + thisArg = createThis(); + target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; + } + else { + switch (callee.kind) { + case 173: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = createTempVariable(recordTempVariable); + target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + case 174: { + if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { + thisArg = createTempVariable(recordTempVariable); + target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); + } + else { + thisArg = callee.expression; + target = callee; + } + break; + } + default: { + thisArg = createVoidZero(); + target = parenthesizeForAccess(expression); + break; + } + } + } + return { target: target, thisArg: thisArg }; } - ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement, location) { - var node = createNode(208, location); - node.initializer = initializer; - node.expression = expression; - node.statement = statement; - return node; + ts.createCallBinding = createCallBinding; + function inlineExpressions(expressions) { + return ts.reduceLeft(expressions, createComma); } - ts.createForOf = createForOf; - function updateForOf(node, initializer, expression, statement) { - if (node.initializer !== initializer || node.expression !== expression || node.statement !== statement) { - return updateNode(createForOf(initializer, expression, statement, node), node); + ts.inlineExpressions = inlineExpressions; + function createExpressionFromEntityName(node) { + if (ts.isQualifiedName(node)) { + var left = createExpressionFromEntityName(node.left); + var right = getMutableClone(node.right); + return createPropertyAccess(left, right, node); } - return node; - } - ts.updateForOf = updateForOf; - function createContinue(label, location) { - var node = createNode(209, location); - if (label) { - node.label = label; + else { + return getMutableClone(node); } - return node; } - ts.createContinue = createContinue; - function updateContinue(node, label) { - if (node.label !== label) { - return updateNode(createContinue(label, node), node); + ts.createExpressionFromEntityName = createExpressionFromEntityName; + function createExpressionForPropertyName(memberName) { + if (ts.isIdentifier(memberName)) { + return createLiteral(memberName, undefined); } - return node; - } - ts.updateContinue = updateContinue; - function createBreak(label, location) { - var node = createNode(210, location); - if (label) { - node.label = label; + else if (ts.isComputedPropertyName(memberName)) { + return getMutableClone(memberName.expression); } - return node; - } - ts.createBreak = createBreak; - function updateBreak(node, label) { - if (node.label !== label) { - return updateNode(createBreak(label, node), node); + else { + return getMutableClone(memberName); } - return node; - } - ts.updateBreak = updateBreak; - function createReturn(expression, location) { - var node = createNode(211, location); - node.expression = expression; - return node; } - ts.createReturn = createReturn; - function updateReturn(node, expression) { - if (node.expression !== expression) { - return updateNode(createReturn(expression, node), node); + ts.createExpressionForPropertyName = createExpressionForPropertyName; + function createExpressionForObjectLiteralElementLike(node, property, receiver) { + switch (property.kind) { + case 150: + case 151: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); + case 253: + return createExpressionForPropertyAssignment(property, receiver); + case 254: + return createExpressionForShorthandPropertyAssignment(property, receiver); + case 148: + return createExpressionForMethodDeclaration(property, receiver); } - return node; - } - ts.updateReturn = updateReturn; - function createWith(expression, statement, location) { - var node = createNode(212, location); - node.expression = expression; - node.statement = statement; - return node; } - ts.createWith = createWith; - function updateWith(node, expression, statement) { - if (node.expression !== expression || node.statement !== statement) { - return updateNode(createWith(expression, statement, node), node); + ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; + function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { + var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + if (property === firstAccessor) { + var properties_1 = []; + if (getAccessor) { + var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); + setOriginalNode(getterFunction, getAccessor); + var getter = createPropertyAssignment("get", getterFunction); + properties_1.push(getter); + } + if (setAccessor) { + var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); + setOriginalNode(setterFunction, setAccessor); + var setter = createPropertyAssignment("set", setterFunction); + properties_1.push(setter); + } + properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); + properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); + var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ + receiver, + createExpressionForPropertyName(property.name), + createObjectLiteral(properties_1, undefined, multiLine) + ], firstAccessor); + return ts.aggregateTransformFlags(expression); } - return node; - } - ts.updateWith = updateWith; - function createSwitch(expression, caseBlock, location) { - var node = createNode(213, location); - node.expression = parenthesizeExpressionForList(expression); - node.caseBlock = caseBlock; - return node; + return undefined; } - ts.createSwitch = createSwitch; - function updateSwitch(node, expression, caseBlock) { - if (node.expression !== expression || node.caseBlock !== caseBlock) { - return updateNode(createSwitch(expression, caseBlock, node), node); - } - return node; + function createExpressionForPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); } - ts.updateSwitch = updateSwitch; - function createLabel(label, statement, location) { - var node = createNode(214, location); - node.label = typeof label === "string" ? createIdentifier(label) : label; - node.statement = statement; - return node; + function createExpressionForShorthandPropertyAssignment(property, receiver) { + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); } - ts.createLabel = createLabel; - function updateLabel(node, label, statement) { - if (node.label !== label || node.statement !== statement) { - return updateNode(createLabel(label, statement, node), node); - } - return node; + function createExpressionForMethodDeclaration(method, receiver) { + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } - ts.updateLabel = updateLabel; - function createThrow(expression, location) { - var node = createNode(215, location); - node.expression = expression; - return node; + function isUseStrictPrologue(node) { + return node.expression.text === "use strict"; } - ts.createThrow = createThrow; - function updateThrow(node, expression) { - if (node.expression !== expression) { - return updateNode(createThrow(expression, node), node); + function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); + var foundUseStrict = false; + var statementOffset = 0; + var numStatements = source.length; + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + } + target.push(statement); + } + else { + break; + } + statementOffset++; } - return node; - } - ts.updateThrow = updateThrow; - function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216, location); - node.tryBlock = tryBlock; - node.catchClause = catchClause; - node.finallyBlock = finallyBlock; - return node; - } - ts.createTry = createTry; - function updateTry(node, tryBlock, catchClause, finallyBlock) { - if (node.tryBlock !== tryBlock || node.catchClause !== catchClause || node.finallyBlock !== finallyBlock) { - return updateNode(createTry(tryBlock, catchClause, finallyBlock, node), node); + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); } - return node; - } - ts.updateTry = updateTry; - function createCaseBlock(clauses, location) { - var node = createNode(227, location); - node.clauses = createNodeArray(clauses); - return node; - } - ts.createCaseBlock = createCaseBlock; - function updateCaseBlock(node, clauses) { - if (node.clauses !== clauses) { - return updateNode(createCaseBlock(clauses, node), node); + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; + } + statementOffset++; } - return node; + return statementOffset; } - ts.updateCaseBlock = updateCaseBlock; - function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220, location, flags); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.asteriskToken = asteriskToken; - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.parameters = createNodeArray(parameters); - node.type = type; - node.body = body; + ts.addPrologueDirectives = addPrologueDirectives; + function ensureUseStrict(node) { + var foundUseStrict = false; + for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + var statements = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + return updateSourceFileNode(node, statements.concat(node.statements)); + } return node; } - ts.createFunctionDeclaration = createFunctionDeclaration; - function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + ts.ensureUseStrict = ensureUseStrict; + function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var skipped = skipPartiallyEmittedExpressions(operand); + if (skipped.kind === 179) { + return operand; } - return node; + return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) + ? createParen(operand) + : operand; } - ts.updateFunctionDeclaration = updateFunctionDeclaration; - function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.name = name; - node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; - node.heritageClauses = createNodeArray(heritageClauses); - node.members = createNodeArray(members); - return node; - } - ts.createClassDeclaration = createClassDeclaration; - function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members) { - return updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, node), node); + ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; + function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); + var emittedOperand = skipPartiallyEmittedExpressions(operand); + var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); + switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { + case -1: + if (!isLeftSideOfBinary + && binaryOperatorAssociativity === 1 + && operand.kind === 191) { + return false; + } + return true; + case 1: + return false; + case 0: + if (isLeftSideOfBinary) { + return binaryOperatorAssociativity === 1; + } + else { + if (ts.isBinaryExpression(emittedOperand) + && emittedOperand.operatorToken.kind === binaryOperator) { + if (operatorHasAssociativeProperty(binaryOperator)) { + return false; + } + if (binaryOperator === 36) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; + if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { + return false; + } + } + } + var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); + return operandAssociativity === 0; + } } - return node; } - ts.updateClassDeclaration = updateClassDeclaration; - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.importClause = importClause; - node.moduleSpecifier = moduleSpecifier; - return node; + function operatorHasAssociativeProperty(binaryOperator) { + return binaryOperator === 38 + || binaryOperator === 48 + || binaryOperator === 47 + || binaryOperator === 49; } - ts.createImportDeclaration = createImportDeclaration; - function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, node), node); + function getLiteralKindOfBinaryPlusOperand(node) { + node = skipPartiallyEmittedExpressions(node); + if (ts.isLiteralKind(node.kind)) { + return node.kind; } - return node; - } - ts.updateImportDeclaration = updateImportDeclaration; - function createImportClause(name, namedBindings, location) { - var node = createNode(231, location); - node.name = name; - node.namedBindings = namedBindings; - return node; - } - ts.createImportClause = createImportClause; - function updateImportClause(node, name, namedBindings) { - if (node.name !== name || node.namedBindings !== namedBindings) { - return updateNode(createImportClause(name, namedBindings, node), node); + if (node.kind === 188 && node.operatorToken.kind === 36) { + if (node.cachedLiteralKind !== undefined) { + return node.cachedLiteralKind; + } + var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); + var literalKind = ts.isLiteralKind(leftKind) + && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) + ? leftKind + : 0; + node.cachedLiteralKind = literalKind; + return literalKind; } - return node; - } - ts.updateImportClause = updateImportClause; - function createNamespaceImport(name, location) { - var node = createNode(232, location); - node.name = name; - return node; + return 0; } - ts.createNamespaceImport = createNamespaceImport; - function updateNamespaceImport(node, name) { - if (node.name !== name) { - return updateNode(createNamespaceImport(name, node), node); + function parenthesizeForNew(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + switch (emittedExpression.kind) { + case 175: + return createParen(expression); + case 176: + return emittedExpression.arguments + ? expression + : createParen(expression); } - return node; - } - ts.updateNamespaceImport = updateNamespaceImport; - function createNamedImports(elements, location) { - var node = createNode(233, location); - node.elements = createNodeArray(elements); - return node; + return parenthesizeForAccess(expression); } - ts.createNamedImports = createNamedImports; - function updateNamedImports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedImports(elements, node), node); + ts.parenthesizeForNew = parenthesizeForNew; + function parenthesizeForAccess(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isLeftHandSideExpression(emittedExpression) + && (emittedExpression.kind !== 176 || emittedExpression.arguments) + && emittedExpression.kind !== 8) { + return expression; } - return node; + return createParen(expression, expression); } - ts.updateNamedImports = updateNamedImports; - function createImportSpecifier(propertyName, name, location) { - var node = createNode(234, location); - node.propertyName = propertyName; - node.name = name; - return node; + ts.parenthesizeForAccess = parenthesizeForAccess; + function parenthesizePostfixOperand(operand) { + return ts.isLeftHandSideExpression(operand) + ? operand + : createParen(operand, operand); } - ts.createImportSpecifier = createImportSpecifier; - function updateImportSpecifier(node, propertyName, name) { - if (node.propertyName !== propertyName || node.name !== name) { - return updateNode(createImportSpecifier(propertyName, name, node), node); + ts.parenthesizePostfixOperand = parenthesizePostfixOperand; + function parenthesizePrefixOperand(operand) { + return ts.isUnaryExpression(operand) + ? operand + : createParen(operand, operand); + } + ts.parenthesizePrefixOperand = parenthesizePrefixOperand; + function parenthesizeListElements(elements) { + var result; + for (var i = 0; i < elements.length; i++) { + var element = parenthesizeExpressionForList(elements[i]); + if (result !== undefined || element !== elements[i]) { + if (result === undefined) { + result = elements.slice(0, i); + } + result.push(element); + } } - return node; + if (result !== undefined) { + return createNodeArray(result, elements, elements.hasTrailingComma); + } + return elements; } - ts.updateImportSpecifier = updateImportSpecifier; - function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.isExportEquals = isExportEquals; - node.expression = expression; - return node; + function parenthesizeExpressionForList(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); + var commaPrecedence = ts.getOperatorPrecedence(188, 25); + return expressionPrecedence > commaPrecedence + ? expression + : createParen(expression, expression); } - ts.createExportAssignment = createExportAssignment; - function updateExportAssignment(node, decorators, modifiers, expression) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.expression !== expression) { - return updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression, node), node); + ts.parenthesizeExpressionForList = parenthesizeExpressionForList; + function parenthesizeExpressionForExpressionStatement(expression) { + var emittedExpression = skipPartiallyEmittedExpressions(expression); + if (ts.isCallExpression(emittedExpression)) { + var callee = emittedExpression.expression; + var kind = skipPartiallyEmittedExpressions(callee).kind; + if (kind === 180 || kind === 181) { + var mutableCall = getMutableClone(emittedExpression); + mutableCall.expression = createParen(callee, callee); + return recreatePartiallyEmittedExpressions(expression, mutableCall); + } } - return node; - } - ts.updateExportAssignment = updateExportAssignment; - function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236, location); - node.decorators = decorators ? createNodeArray(decorators) : undefined; - node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; - node.exportClause = exportClause; - node.moduleSpecifier = moduleSpecifier; - return node; + else { + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { + return createParen(expression, expression); + } + } + return expression; } - ts.createExportDeclaration = createExportDeclaration; - function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier) { - return updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, node), node); + ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; + function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { + if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { + var clone_1 = getMutableClone(originalOuterExpression); + clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); + return clone_1; } - return node; + return newInnerExpression; } - ts.updateExportDeclaration = updateExportDeclaration; - function createNamedExports(elements, location) { - var node = createNode(237, location); - node.elements = createNodeArray(elements); - return node; + function getLeftmostExpression(node) { + while (true) { + switch (node.kind) { + case 187: + node = node.operand; + continue; + case 188: + node = node.left; + continue; + case 189: + node = node.condition; + continue; + case 175: + case 174: + case 173: + node = node.expression; + continue; + case 288: + node = node.expression; + continue; + } + return node; + } } - ts.createNamedExports = createNamedExports; - function updateNamedExports(node, elements) { - if (node.elements !== elements) { - return updateNode(createNamedExports(elements, node), node); + function parenthesizeConciseBody(body) { + var emittedBody = skipPartiallyEmittedExpressions(body); + if (emittedBody.kind === 172) { + return createParen(body, body); } - return node; + return body; } - ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName, location) { - var node = createNode(238, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; + ts.parenthesizeConciseBody = parenthesizeConciseBody; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + var OuterExpressionKinds = ts.OuterExpressionKinds; + function skipOuterExpressions(node, kinds) { + if (kinds === void 0) { kinds = 7; } + var previousNode; + do { + previousNode = node; + if (kinds & 1) { + node = skipParentheses(node); + } + if (kinds & 2) { + node = skipAssertions(node); + } + if (kinds & 4) { + node = skipPartiallyEmittedExpressions(node); + } + } while (previousNode !== node); return node; } - ts.createExportSpecifier = createExportSpecifier; - function updateExportSpecifier(node, name, propertyName) { - if (node.name !== name || node.propertyName !== propertyName) { - return updateNode(createExportSpecifier(name, propertyName, node), node); + ts.skipOuterExpressions = skipOuterExpressions; + function skipParentheses(node) { + while (node.kind === 179) { + node = node.expression; } return node; } - ts.updateExportSpecifier = updateExportSpecifier; - function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241, location); - node.openingElement = openingElement; - node.children = createNodeArray(children); - node.closingElement = closingElement; + ts.skipParentheses = skipParentheses; + function skipAssertions(node) { + while (ts.isAssertionExpression(node)) { + node = node.expression; + } return node; } - ts.createJsxElement = createJsxElement; - function updateJsxElement(node, openingElement, children, closingElement) { - if (node.openingElement !== openingElement || node.children !== children || node.closingElement !== closingElement) { - return updateNode(createJsxElement(openingElement, children, closingElement, node), node); + ts.skipAssertions = skipAssertions; + function skipPartiallyEmittedExpressions(node) { + while (node.kind === 288) { + node = node.expression; } return node; } - ts.updateJsxElement = updateJsxElement; - function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242, location); - node.tagName = tagName; - node.attributes = createNodeArray(attributes); + ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; + function startOnNewLine(node) { + node.startsOnNewLine = true; return node; } - ts.createJsxSelfClosingElement = createJsxSelfClosingElement; - function updateJsxSelfClosingElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxSelfClosingElement(tagName, attributes, node), node); + ts.startOnNewLine = startOnNewLine; + function setOriginalNode(node, original) { + node.original = original; + if (original) { + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } - ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; - function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243, location); - node.tagName = tagName; - node.attributes = createNodeArray(attributes); - return node; + ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; + if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + return destEmitNode; } - ts.createJsxOpeningElement = createJsxOpeningElement; - function updateJsxOpeningElement(node, tagName, attributes) { - if (node.tagName !== tagName || node.attributes !== attributes) { - return updateNode(createJsxOpeningElement(tagName, attributes, node), node); - } - return node; + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = ts.createMap(); + ts.copyProperties(sourceRanges, destRanges); + return destRanges; } - ts.updateJsxOpeningElement = updateJsxOpeningElement; - function createJsxClosingElement(tagName, location) { - var node = createNode(245, location); - node.tagName = tagName; - return node; + function disposeEmitNodes(sourceFile) { + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } } - ts.createJsxClosingElement = createJsxClosingElement; - function updateJsxClosingElement(node, tagName) { - if (node.tagName !== tagName) { - return updateNode(createJsxClosingElement(tagName, node), node); + ts.disposeEmitNodes = disposeEmitNodes; + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + if (node.kind === 256) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; } - return node; + return node.emitNode; } - ts.updateJsxClosingElement = updateJsxClosingElement; - function createJsxAttribute(name, initializer, location) { - var node = createNode(246, location); - node.name = name; - node.initializer = initializer; - return node; + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; } - ts.createJsxAttribute = createJsxAttribute; - function updateJsxAttribute(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createJsxAttribute(name, initializer, node), node); - } + ts.getEmitFlags = getEmitFlags; + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; return node; } - ts.updateJsxAttribute = updateJsxAttribute; - function createJsxSpreadAttribute(expression, location) { - var node = createNode(247, location); - node.expression = expression; + ts.setEmitFlags = setEmitFlags; + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; return node; } - ts.createJsxSpreadAttribute = createJsxSpreadAttribute; - function updateJsxSpreadAttribute(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxSpreadAttribute(expression, node), node); - } + ts.setSourceMapRange = setSourceMapRange; + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + tokenSourceMapRanges[token] = range; return node; } - ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, location) { - var node = createNode(248, location); - node.expression = expression; + ts.setTokenSourceMapRange = setTokenSourceMapRange; + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; return node; } - ts.createJsxExpression = createJsxExpression; - function updateJsxExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createJsxExpression(expression, node), node); - } - return node; + ts.setCommentRange = setCommentRange; + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; } - ts.updateJsxExpression = updateJsxExpression; - function createHeritageClause(token, types, location) { - var node = createNode(251, location); - node.token = token; - node.types = createNodeArray(types); - return node; + ts.getCommentRange = getCommentRange; + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; } - ts.createHeritageClause = createHeritageClause; - function updateHeritageClause(node, types) { - if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types, node), node); - } - return node; + ts.getSourceMapRange = getSourceMapRange; + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; } - ts.updateHeritageClause = updateHeritageClause; - function createCaseClause(expression, statements, location) { - var node = createNode(249, location); - node.expression = parenthesizeExpressionForList(expression); - node.statements = createNodeArray(statements); + ts.getTokenSourceMapRange = getTokenSourceMapRange; + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; return node; } - ts.createCaseClause = createCaseClause; - function updateCaseClause(node, expression, statements) { - if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements, node), node); + ts.setConstantValue = setConstantValue; + function setTextRange(node, location) { + if (location) { + node.pos = location.pos; + node.end = location.end; } return node; } - ts.updateCaseClause = updateCaseClause; - function createDefaultClause(statements, location) { - var node = createNode(250, location); - node.statements = createNodeArray(statements); + ts.setTextRange = setTextRange; + function setNodeFlags(node, flags) { + node.flags = flags; return node; } - ts.createDefaultClause = createDefaultClause; - function updateDefaultClause(node, statements) { - if (node.statements !== statements) { - return updateNode(createDefaultClause(statements, node), node); - } + ts.setNodeFlags = setNodeFlags; + function setMultiLine(node, multiLine) { + node.multiLine = multiLine; return node; } - ts.updateDefaultClause = updateDefaultClause; - function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252, location); - node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; - node.block = block; - return node; + ts.setMultiLine = setMultiLine; + function setHasTrailingComma(nodes, hasTrailingComma) { + nodes.hasTrailingComma = hasTrailingComma; + return nodes; } - ts.createCatchClause = createCatchClause; - function updateCatchClause(node, variableDeclaration, block) { - if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block, node), node); + ts.setHasTrailingComma = setHasTrailingComma; + function getLocalNameForExternalImport(node, sourceFile) { + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + var name_9 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - return node; - } - ts.updateCatchClause = updateCatchClause; - function createPropertyAssignment(name, initializer, location) { - var node = createNode(253, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.questionToken = undefined; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; - return node; - } - ts.createPropertyAssignment = createPropertyAssignment; - function updatePropertyAssignment(node, name, initializer) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer, node), node); + if (node.kind === 231 && node.importClause) { + return getGeneratedNameForNode(node); } - return node; - } - ts.updatePropertyAssignment = updatePropertyAssignment; - function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254, location); - node.name = typeof name === "string" ? createIdentifier(name) : name; - node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; - return node; - } - ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { - if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); + if (node.kind === 237 && node.moduleSpecifier) { + return getGeneratedNameForNode(node); } - return node; + return undefined; } - ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; - function updateSourceFileNode(node, statements) { - if (node.statements !== statements) { - var updated = createNode(256, node, node.flags); - updated.statements = createNodeArray(statements); - updated.endOfFileToken = node.endOfFileToken; - updated.fileName = node.fileName; - updated.path = node.path; - updated.text = node.text; - if (node.amdDependencies !== undefined) - updated.amdDependencies = node.amdDependencies; - if (node.moduleName !== undefined) - updated.moduleName = node.moduleName; - if (node.referencedFiles !== undefined) - updated.referencedFiles = node.referencedFiles; - if (node.typeReferenceDirectives !== undefined) - updated.typeReferenceDirectives = node.typeReferenceDirectives; - if (node.languageVariant !== undefined) - updated.languageVariant = node.languageVariant; - if (node.isDeclarationFile !== undefined) - updated.isDeclarationFile = node.isDeclarationFile; - if (node.renamedDependencies !== undefined) - updated.renamedDependencies = node.renamedDependencies; - if (node.hasNoDefaultLib !== undefined) - updated.hasNoDefaultLib = node.hasNoDefaultLib; - if (node.languageVersion !== undefined) - updated.languageVersion = node.languageVersion; - if (node.scriptKind !== undefined) - updated.scriptKind = node.scriptKind; - if (node.externalModuleIndicator !== undefined) - updated.externalModuleIndicator = node.externalModuleIndicator; - if (node.commonJsModuleIndicator !== undefined) - updated.commonJsModuleIndicator = node.commonJsModuleIndicator; - if (node.identifiers !== undefined) - updated.identifiers = node.identifiers; - if (node.nodeCount !== undefined) - updated.nodeCount = node.nodeCount; - if (node.identifierCount !== undefined) - updated.identifierCount = node.identifierCount; - if (node.symbolCount !== undefined) - updated.symbolCount = node.symbolCount; - if (node.parseDiagnostics !== undefined) - updated.parseDiagnostics = node.parseDiagnostics; - if (node.bindDiagnostics !== undefined) - updated.bindDiagnostics = node.bindDiagnostics; - if (node.lineMap !== undefined) - updated.lineMap = node.lineMap; - if (node.classifiableNames !== undefined) - updated.classifiableNames = node.classifiableNames; - if (node.resolvedModules !== undefined) - updated.resolvedModules = node.resolvedModules; - if (node.resolvedTypeReferenceDirectiveNames !== undefined) - updated.resolvedTypeReferenceDirectiveNames = node.resolvedTypeReferenceDirectiveNames; - if (node.imports !== undefined) - updated.imports = node.imports; - if (node.moduleAugmentations !== undefined) - updated.moduleAugmentations = node.moduleAugmentations; - if (node.externalHelpersModuleName !== undefined) - updated.externalHelpersModuleName = node.externalHelpersModuleName; - return updateNode(updated, node); + ts.getLocalNameForExternalImport = getLocalNameForExternalImport; + function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { + var moduleName = ts.getExternalModuleName(importNode); + if (moduleName.kind === 9) { + return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) + || tryRenameExternalModule(moduleName, sourceFile) + || getSynthesizedClone(moduleName); } - return node; - } - ts.updateSourceFileNode = updateSourceFileNode; - function createNotEmittedStatement(original) { - var node = createNode(287, original); - node.original = original; - return node; - } - ts.createNotEmittedStatement = createNotEmittedStatement; - function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288, location || original); - node.expression = expression; - node.original = original; - return node; + return undefined; } - ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression; - function updatePartiallyEmittedExpression(node, expression) { - if (node.expression !== expression) { - return updateNode(createPartiallyEmittedExpression(expression, node.original, node), node); + ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; + function tryRenameExternalModule(moduleName, sourceFile) { + if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { + return createLiteral(sourceFile.renamedDependencies[moduleName.text]); } - return node; - } - ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; - function createComma(left, right) { - return createBinary(left, 24, right); - } - ts.createComma = createComma; - function createLessThan(left, right, location) { - return createBinary(left, 25, right, location); - } - ts.createLessThan = createLessThan; - function createAssignment(left, right, location) { - return createBinary(left, 56, right, location); - } - ts.createAssignment = createAssignment; - function createStrictEquality(left, right) { - return createBinary(left, 32, right); - } - ts.createStrictEquality = createStrictEquality; - function createStrictInequality(left, right) { - return createBinary(left, 33, right); - } - ts.createStrictInequality = createStrictInequality; - function createAdd(left, right) { - return createBinary(left, 35, right); - } - ts.createAdd = createAdd; - function createSubtract(left, right) { - return createBinary(left, 36, right); - } - ts.createSubtract = createSubtract; - function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41, location); - } - ts.createPostfixIncrement = createPostfixIncrement; - function createLogicalAnd(left, right) { - return createBinary(left, 51, right); - } - ts.createLogicalAnd = createLogicalAnd; - function createLogicalOr(left, right) { - return createBinary(left, 52, right); - } - ts.createLogicalOr = createLogicalOr; - function createLogicalNot(operand) { - return createPrefix(49, operand); - } - ts.createLogicalNot = createLogicalNot; - function createVoidZero() { - return createVoid(createLiteral(0)); + return undefined; } - ts.createVoidZero = createVoidZero; - function createMemberAccessForPropertyName(target, memberName, location) { - if (ts.isComputedPropertyName(memberName)) { - return createElementAccess(target, memberName.expression, location); + function tryGetModuleNameFromFile(file, host, options) { + if (!file) { + return undefined; } - else { - var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 2048; - return expression; + if (file.moduleName) { + return createLiteral(file.moduleName); } - } - ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); - } - ts.createRestParameter = createRestParameter; - function createFunctionCall(func, thisArg, argumentsList, location) { - return createCall(createPropertyAccess(func, "call"), undefined, [ - thisArg - ].concat(argumentsList), location); - } - ts.createFunctionCall = createFunctionCall; - function createFunctionApply(func, thisArg, argumentsExpression, location) { - return createCall(createPropertyAccess(func, "apply"), undefined, [ - thisArg, - argumentsExpression - ], location); - } - ts.createFunctionApply = createFunctionApply; - function createArraySlice(array, start) { - var argumentsList = []; - if (start !== undefined) { - argumentsList.push(typeof start === "number" ? createLiteral(start) : start); + if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { + return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); } - return createCall(createPropertyAccess(array, "slice"), undefined, argumentsList); - } - ts.createArraySlice = createArraySlice; - function createArrayConcat(array, values) { - return createCall(createPropertyAccess(array, "concat"), undefined, values); - } - ts.createArrayConcat = createArrayConcat; - function createMathPow(left, right, location) { - return createCall(createPropertyAccess(createIdentifier("Math"), "pow"), undefined, [left, right], location); + return undefined; } - ts.createMathPow = createMathPow; - function createReactNamespace(reactNamespace, parent) { - var react = createIdentifier(reactNamespace || "React"); - react.flags &= ~8; - react.parent = parent; - return react; + ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile; + function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { + return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } - function createReactCreateElement(reactNamespace, tagName, props, children, parentElement, location) { - var argumentsList = [tagName]; - if (props) { - argumentsList.push(props); +})(ts || (ts = {})); +var ts; +(function (ts) { + var NodeConstructor; + var TokenConstructor; + var IdentifierConstructor; + var SourceFileConstructor; + function createNode(kind, pos, end) { + if (kind === 256) { + return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - if (children && children.length > 0) { - if (!props) { - argumentsList.push(createNull()); - } - if (children.length > 1) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - child.startsOnNewLine = true; - argumentsList.push(child); - } - } - else { - argumentsList.push(children[0]); - } + else if (kind === 70) { + return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - return createCall(createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "createElement"), undefined, argumentsList, location); - } - ts.createReactCreateElement = createReactCreateElement; - function createLetDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 1); - } - ts.createLetDeclarationList = createLetDeclarationList; - function createConstDeclarationList(declarations, location) { - return createVariableDeclarationList(declarations, location, 2); - } - ts.createConstDeclarationList = createConstDeclarationList; - function createHelperName(externalHelpersModuleName, name) { - return externalHelpersModuleName - ? createPropertyAccess(externalHelpersModuleName, name) - : createIdentifier(name); - } - ts.createHelperName = createHelperName; - function createExtendsHelper(externalHelpersModuleName, name) { - return createCall(createHelperName(externalHelpersModuleName, "__extends"), undefined, [ - name, - createIdentifier("_super") - ]); - } - ts.createExtendsHelper = createExtendsHelper; - function createAssignHelper(externalHelpersModuleName, attributesSegments) { - return createCall(createHelperName(externalHelpersModuleName, "__assign"), undefined, attributesSegments); - } - ts.createAssignHelper = createAssignHelper; - function createParamHelper(externalHelpersModuleName, expression, parameterOffset, location) { - return createCall(createHelperName(externalHelpersModuleName, "__param"), undefined, [ - createLiteral(parameterOffset), - expression - ], location); - } - ts.createParamHelper = createParamHelper; - function createMetadataHelper(externalHelpersModuleName, metadataKey, metadataValue) { - return createCall(createHelperName(externalHelpersModuleName, "__metadata"), undefined, [ - createLiteral(metadataKey), - metadataValue - ]); - } - ts.createMetadataHelper = createMetadataHelper; - function createDecorateHelper(externalHelpersModuleName, decoratorExpressions, target, memberName, descriptor, location) { - var argumentsArray = []; - argumentsArray.push(createArrayLiteral(decoratorExpressions, undefined, true)); - argumentsArray.push(target); - if (memberName) { - argumentsArray.push(memberName); - if (descriptor) { - argumentsArray.push(descriptor); - } + else if (kind < 140) { + return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } - return createCall(createHelperName(externalHelpersModuleName, "__decorate"), undefined, argumentsArray, location); - } - ts.createDecorateHelper = createDecorateHelper; - function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; - return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ - createThis(), - hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(), - promiseConstructor ? createExpressionFromEntityName(promiseConstructor) : createVoidZero(), - generatorFunc - ]); - } - ts.createAwaiterHelper = createAwaiterHelper; - function createHasOwnProperty(target, propertyName) { - return createCall(createPropertyAccess(target, "hasOwnProperty"), undefined, [propertyName]); - } - ts.createHasOwnProperty = createHasOwnProperty; - function createObjectCreate(prototype) { - return createCall(createPropertyAccess(createIdentifier("Object"), "create"), undefined, [prototype]); - } - function createGeti(target) { - return createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createElementAccess(target, createIdentifier("name"))); - } - function createSeti(target) { - return createArrowFunction(undefined, undefined, [ - createParameter("name"), - createParameter("value") - ], undefined, undefined, createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); - } - function createAdvancedAsyncSuperHelper() { - var createCache = createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("cache", undefined, createObjectCreate(createNull())) - ])); - var getter = createGetAccessor(undefined, undefined, "value", [], undefined, createBlock([ - createReturn(createCall(createIdentifier("geti"), undefined, [createIdentifier("name")])) - ])); - var setter = createSetAccessor(undefined, undefined, "value", [createParameter("v")], createBlock([ - createStatement(createCall(createIdentifier("seti"), undefined, [ - createIdentifier("name"), - createIdentifier("v") - ])) - ])); - var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ - getter, - setter - ])))))); - return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, [ - createParameter("geti"), - createParameter("seti") - ], undefined, createBlock([ - createCache, - getOrCreateAccessorsForName - ]))), undefined, [ - createGeti(createSuper()), - createSeti(createSuper()) - ])) - ])); - } - ts.createAdvancedAsyncSuperHelper = createAdvancedAsyncSuperHelper; - function createSimpleAsyncSuperHelper() { - return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createGeti(createSuper())) - ])); - } - ts.createSimpleAsyncSuperHelper = createSimpleAsyncSuperHelper; - function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { - var target = skipParentheses(node); - switch (target.kind) { - case 69: - return cacheIdentifiers; - case 97: - case 8: - case 9: - return false; - case 170: - var elements = target.elements; - if (elements.length === 0) { - return false; - } - return true; - case 171: - return target.properties.length > 0; - default: - return true; + else { + return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end); } } - function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { - var callee = skipOuterExpressions(expression, 7); - var thisArg; - var target; - if (ts.isSuperProperty(callee)) { - thisArg = createThis(); - target = callee; + ts.createNode = createNode; + function visitNode(cbNode, node) { + if (node) { + return cbNode(node); } - else if (callee.kind === 95) { - thisArg = createThis(); - target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; + } + function visitNodeArray(cbNodes, nodes) { + if (nodes) { + return cbNodes(nodes); } - else { - switch (callee.kind) { - case 172: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - case 173: { - if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { - thisArg = createTempVariable(recordTempVariable); - target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); - } - else { - thisArg = callee.expression; - target = callee; - } - break; - } - default: { - thisArg = createVoidZero(); - target = parenthesizeForAccess(expression); - break; + } + function visitEachNode(cbNode, nodes) { + if (nodes) { + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + var result = cbNode(node); + if (result) { + return result; } } } - return { target: target, thisArg: thisArg }; - } - ts.createCallBinding = createCallBinding; - function inlineExpressions(expressions) { - return ts.reduceLeft(expressions, createComma); - } - ts.inlineExpressions = inlineExpressions; - function createExpressionFromEntityName(node) { - if (ts.isQualifiedName(node)) { - var left = createExpressionFromEntityName(node.left); - var right = getMutableClone(node.right); - return createPropertyAccess(left, right, node); - } - else { - return getMutableClone(node); - } } - ts.createExpressionFromEntityName = createExpressionFromEntityName; - function createExpressionForPropertyName(memberName) { - if (ts.isIdentifier(memberName)) { - return createLiteral(memberName, undefined); - } - else if (ts.isComputedPropertyName(memberName)) { - return getMutableClone(memberName.expression); - } - else { - return getMutableClone(memberName); + function forEachChild(node, cbNode, cbNodeArray) { + if (!node) { + return; } - } - ts.createExpressionForPropertyName = createExpressionForPropertyName; - function createExpressionForObjectLiteralElementLike(node, property, receiver) { - switch (property.kind) { + var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; + var cbNodes = cbNodeArray || cbNode; + switch (node.kind) { + case 140: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 142: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.constraint) || + visitNode(cbNode, node.expression); + case 254: + 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 143: + case 146: + case 145: + case 253: + case 219: + case 170: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.dotDotDotToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); + case 157: + case 158: + case 152: + case 153: + case 154: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 148: + case 147: case 149: case 150: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 253: - return createExpressionForPropertyAssignment(property, receiver); - case 254: - return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147: - return createExpressionForMethodDeclaration(property, receiver); + case 151: + case 180: + case 221: + case 181: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.equalsGreaterThanToken) || + visitNode(cbNode, node.body); + case 156: + return visitNode(cbNode, node.typeName) || + visitNodes(cbNodes, node.typeArguments); + case 155: + return visitNode(cbNode, node.parameterName) || + visitNode(cbNode, node.type); + case 159: + return visitNode(cbNode, node.exprName); + case 160: + return visitNodes(cbNodes, node.members); + case 161: + return visitNode(cbNode, node.elementType); + case 162: + return visitNodes(cbNodes, node.elementTypes); + case 163: + case 164: + return visitNodes(cbNodes, node.types); + case 165: + return visitNode(cbNode, node.type); + case 167: + return visitNode(cbNode, node.literal); + case 168: + case 169: + return visitNodes(cbNodes, node.elements); + case 171: + return visitNodes(cbNodes, node.elements); + case 172: + return visitNodes(cbNodes, node.properties); + case 173: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.name); + case 174: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); + case 175: + case 176: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments) || + visitNodes(cbNodes, node.arguments); + case 177: + return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.template); + case 178: + return visitNode(cbNode, node.type) || + visitNode(cbNode, node.expression); + case 179: + return visitNode(cbNode, node.expression); + case 182: + return visitNode(cbNode, node.expression); + case 183: + return visitNode(cbNode, node.expression); + case 184: + return visitNode(cbNode, node.expression); + case 186: + return visitNode(cbNode, node.operand); + case 191: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 185: + return visitNode(cbNode, node.expression); + case 187: + return visitNode(cbNode, node.operand); + case 188: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.operatorToken) || + visitNode(cbNode, node.right); + case 196: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 197: + return visitNode(cbNode, node.expression); + case 189: + return visitNode(cbNode, node.condition) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.whenTrue) || + visitNode(cbNode, node.colonToken) || + visitNode(cbNode, node.whenFalse); + case 192: + return visitNode(cbNode, node.expression); + case 200: + case 227: + return visitNodes(cbNodes, node.statements); + case 256: + return visitNodes(cbNodes, node.statements) || + visitNode(cbNode, node.endOfFileToken); + case 201: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.declarationList); + case 220: + return visitNodes(cbNodes, node.declarations); + case 203: + return visitNode(cbNode, node.expression); + case 204: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.thenStatement) || + visitNode(cbNode, node.elseStatement); + case 205: + return visitNode(cbNode, node.statement) || + visitNode(cbNode, node.expression); + case 206: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 207: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || + visitNode(cbNode, node.statement); + case 208: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 209: + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 210: + case 211: + return visitNode(cbNode, node.label); + case 212: + return visitNode(cbNode, node.expression); + case 213: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 214: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 228: + return visitNodes(cbNodes, node.clauses); + case 249: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 250: + return visitNodes(cbNodes, node.statements); + case 215: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 216: + return visitNode(cbNode, node.expression); + case 217: + return visitNode(cbNode, node.tryBlock) || + visitNode(cbNode, node.catchClause) || + visitNode(cbNode, node.finallyBlock); + case 252: + return visitNode(cbNode, node.variableDeclaration) || + visitNode(cbNode, node.block); + case 144: + return visitNode(cbNode, node.expression); + case 222: + case 193: + 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 223: + 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 224: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 225: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 255: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 226: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.body); + case 230: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.moduleReference); + case 231: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.importClause) || + visitNode(cbNode, node.moduleSpecifier); + case 232: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.namedBindings); + case 229: + return visitNode(cbNode, node.name); + case 233: + return visitNode(cbNode, node.name); + case 234: + case 238: + return visitNodes(cbNodes, node.elements); + case 237: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.exportClause) || + visitNode(cbNode, node.moduleSpecifier); + case 235: + case 239: + return visitNode(cbNode, node.propertyName) || + visitNode(cbNode, node.name); + case 236: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); + case 198: + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); + case 141: + return visitNode(cbNode, node.expression); + case 251: + return visitNodes(cbNodes, node.types); + case 195: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.typeArguments); + case 241: + return visitNode(cbNode, node.expression); + case 240: + return visitNodes(cbNodes, node.decorators); + case 242: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); + case 243: + case 244: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); + case 246: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 247: + return visitNode(cbNode, node.expression); + case 248: + return visitNode(cbNode, node.expression); + case 245: + return visitNode(cbNode, node.tagName); + case 257: + return visitNode(cbNode, node.type); + case 261: + return visitNodes(cbNodes, node.types); + case 262: + return visitNodes(cbNodes, node.types); + case 260: + return visitNode(cbNode, node.elementType); + case 264: + return visitNode(cbNode, node.type); + case 263: + return visitNode(cbNode, node.type); + case 265: + return visitNode(cbNode, node.literal); + case 267: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 268: + return visitNode(cbNode, node.type); + case 269: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 270: + return visitNode(cbNode, node.type); + case 271: + return visitNode(cbNode, node.type); + case 272: + return visitNode(cbNode, node.type); + case 266: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.type); + case 273: + return visitNodes(cbNodes, node.tags); + case 275: + return visitNode(cbNode, node.preParameterName) || + visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.postParameterName); + case 276: + return visitNode(cbNode, node.typeExpression); + case 277: + return visitNode(cbNode, node.typeExpression); + case 278: + return visitNodes(cbNodes, node.typeParameters); + case 279: + return visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.jsDocTypeLiteral); + case 281: + return visitNodes(cbNodes, node.jsDocPropertyTags); + case 280: + return visitNode(cbNode, node.typeExpression) || + visitNode(cbNode, node.name); + case 288: + return visitNode(cbNode, node.expression); + case 282: + return visitNode(cbNode, node.literal); } } - ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike; - function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { - var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - if (property === firstAccessor) { - var properties_1 = []; - if (getAccessor) { - var getterFunction = createFunctionExpression(undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); - setOriginalNode(getterFunction, getAccessor); - var getter = createPropertyAssignment("get", getterFunction); - properties_1.push(getter); - } - if (setAccessor) { - var setterFunction = createFunctionExpression(undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); - setOriginalNode(setterFunction, setAccessor); - var setter = createPropertyAssignment("set", setterFunction); - properties_1.push(setter); - } - properties_1.push(createPropertyAssignment("enumerable", createLiteral(true))); - properties_1.push(createPropertyAssignment("configurable", createLiteral(true))); - var expression = createCall(createPropertyAccess(createIdentifier("Object"), "defineProperty"), undefined, [ - receiver, - createExpressionForPropertyName(property.name), - createObjectLiteral(properties_1, undefined, multiLine) - ], firstAccessor); - return ts.aggregateTransformFlags(expression); - } - return undefined; + ts.forEachChild = forEachChild; + function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { + if (setParentNodes === void 0) { setParentNodes = false; } + ts.performance.mark("beforeParse"); + var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind); + ts.performance.mark("afterParse"); + ts.performance.measure("Parse", "beforeParse", "afterParse"); + return result; } - function createExpressionForPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer, property), property)); + ts.createSourceFile = createSourceFile; + function isExternalModule(file) { + return file.externalModuleIndicator !== undefined; } - function createExpressionForShorthandPropertyAssignment(property, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); + ts.isExternalModule = isExternalModule; + function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); } - function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); + ts.updateSourceFile = updateSourceFile; + function parseIsolatedJSDocComment(content, start, length) { + var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); + if (result && result.jsDoc) { + Parser.fixupParentReferences(result.jsDoc); + } + return result; } - function isUseStrictPrologue(node) { - return node.expression.text === "use strict"; + ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; + function parseJSDocTypeExpressionForTests(content, start, length) { + return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); - var foundUseStrict = false; - var statementOffset = 0; - var numStatements = source.length; - while (statementOffset < numStatements) { - var statement = source[statementOffset]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - } - target.push(statement); - } - else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; + var Parser; + (function (Parser) { + var scanner = ts.createScanner(4, true); + var disallowInAndDecoratorContext = 32768 | 131072; + var NodeConstructor; + var TokenConstructor; + var IdentifierConstructor; + var SourceFileConstructor; + var sourceFile; + var parseDiagnostics; + var syntaxCursor; + var currentToken; + var sourceText; + var nodeCount; + var identifiers; + var identifierCount; + var parsingContext; + var contextFlags; + var parseErrorBeforeNextFinishedNode = false; + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + scriptKind = ts.ensureScriptKind(fileName, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); + var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); + clearState(); + return result; + } + Parser.parseSourceFile = parseSourceFile; + function getLanguageVariant(scriptKind) { + return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; + } + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { + NodeConstructor = ts.objectAllocator.getNodeConstructor(); + TokenConstructor = ts.objectAllocator.getTokenConstructor(); + IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); + SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor(); + sourceText = _sourceText; + syntaxCursor = _syntaxCursor; + parseDiagnostics = []; + parsingContext = 0; + identifiers = ts.createMap(); + identifierCount = 0; + nodeCount = 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 1048576 : 0; + parseErrorBeforeNextFinishedNode = false; + scanner.setText(sourceText); + scanner.setOnError(scanError); + scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(getLanguageVariant(scriptKind)); + } + function clearState() { + scanner.setText(""); + scanner.setOnError(undefined); + parseDiagnostics = undefined; + sourceFile = undefined; + identifiers = undefined; + syntaxCursor = undefined; + sourceText = undefined; + } + function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { + sourceFile = createSourceFile(fileName, languageVersion, scriptKind); + sourceFile.flags = contextFlags; + nextToken(); + processReferenceComments(sourceFile); + sourceFile.statements = parseList(0, parseStatement); + ts.Debug.assert(token() === 1); + sourceFile.endOfFileToken = parseTokenNode(); + setExternalModuleIndicator(sourceFile); + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; + sourceFile.parseDiagnostics = parseDiagnostics; + if (setParentNodes) { + fixupParentReferences(sourceFile); } - statementOffset++; + return sourceFile; } - return statementOffset; - } - ts.addPrologueDirectives = addPrologueDirectives; - function ensureUseStrict(node) { - var foundUseStrict = false; - for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.isPrologueDirective(statement)) { - if (isUseStrictPrologue(statement)) { - foundUseStrict = true; - break; + function addJSDocComment(node) { + var comments = ts.getJsDocCommentsFromText(node, sourceFile.text); + if (comments) { + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var comment = comments_2[_i]; + var jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (!jsDoc) { + continue; + } + if (!node.jsDocComments) { + node.jsDocComments = []; + } + node.jsDocComments.push(jsDoc); } } - else { - break; - } - } - if (!foundUseStrict) { - var statements = []; - statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); - return updateSourceFileNode(node, statements.concat(node.statements)); - } - return node; - } - ts.ensureUseStrict = ensureUseStrict; - function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 178) { - return operand; + return node; } - return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) - ? createParen(operand) - : operand; - } - ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; - function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187, binaryOperator); - var emittedOperand = skipPartiallyEmittedExpressions(operand); - var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); - switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1: - if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 - && operand.kind === 190) { - return false; - } - return true; - case 1: - return false; - case 0: - if (isLeftSideOfBinary) { - return binaryOperatorAssociativity === 1; - } - else { - if (ts.isBinaryExpression(emittedOperand) - && emittedOperand.operatorToken.kind === binaryOperator) { - if (operatorHasAssociativeProperty(binaryOperator)) { - return false; - } - if (binaryOperator === 35) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; - if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { - return false; - } + function fixupParentReferences(rootNode) { + var parent = rootNode; + forEachChild(rootNode, visitNode); + return; + function visitNode(n) { + if (n.parent !== parent) { + n.parent = parent; + var saveParent = parent; + parent = n; + forEachChild(n, visitNode); + if (n.jsDocComments) { + for (var _i = 0, _a = n.jsDocComments; _i < _a.length; _i++) { + var jsDocComment = _a[_i]; + jsDocComment.parent = n; + parent = jsDocComment; + forEachChild(jsDocComment, visitNode); } } - var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0; + parent = saveParent; } + } } - } - function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 37 - || binaryOperator === 47 - || binaryOperator === 46 - || binaryOperator === 48; - } - function getLiteralKindOfBinaryPlusOperand(node) { - node = skipPartiallyEmittedExpressions(node); - if (ts.isLiteralKind(node.kind)) { - return node.kind; + Parser.fixupParentReferences = fixupParentReferences; + function createSourceFile(fileName, languageVersion, scriptKind) { + var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); + nodeCount++; + sourceFile.text = sourceText; + sourceFile.bindDiagnostics = []; + sourceFile.languageVersion = languageVersion; + sourceFile.fileName = ts.normalizePath(fileName); + sourceFile.languageVariant = getLanguageVariant(scriptKind); + sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); + sourceFile.scriptKind = scriptKind; + return sourceFile; } - if (node.kind === 187 && node.operatorToken.kind === 35) { - if (node.cachedLiteralKind !== undefined) { - return node.cachedLiteralKind; + function setContextFlag(val, flag) { + if (val) { + contextFlags |= flag; + } + else { + contextFlags &= ~flag; } - var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; - node.cachedLiteralKind = literalKind; - return literalKind; } - return 0; - } - function parenthesizeForNew(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - switch (emittedExpression.kind) { - case 174: - return createParen(expression); - case 175: - return emittedExpression.arguments - ? expression - : createParen(expression); + function setDisallowInContext(val) { + setContextFlag(val, 32768); } - return parenthesizeForAccess(expression); - } - ts.parenthesizeForNew = parenthesizeForNew; - function parenthesizeForAccess(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { - return expression; + function setYieldContext(val) { + setContextFlag(val, 65536); } - return createParen(expression, expression); - } - ts.parenthesizeForAccess = parenthesizeForAccess; - function parenthesizePostfixOperand(operand) { - return ts.isLeftHandSideExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePostfixOperand = parenthesizePostfixOperand; - function parenthesizePrefixOperand(operand) { - return ts.isUnaryExpression(operand) - ? operand - : createParen(operand, operand); - } - ts.parenthesizePrefixOperand = parenthesizePrefixOperand; - function parenthesizeListElements(elements) { - var result; - for (var i = 0; i < elements.length; i++) { - var element = parenthesizeExpressionForList(elements[i]); - if (result !== undefined || element !== elements[i]) { - if (result === undefined) { - result = elements.slice(0, i); - } - result.push(element); - } + function setDecoratorContext(val) { + setContextFlag(val, 131072); } - if (result !== undefined) { - return createNodeArray(result, elements, elements.hasTrailingComma); + function setAwaitContext(val) { + setContextFlag(val, 262144); } - return elements; - } - function parenthesizeExpressionForList(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187, 24); - return expressionPrecedence > commaPrecedence - ? expression - : createParen(expression, expression); - } - ts.parenthesizeExpressionForList = parenthesizeExpressionForList; - function parenthesizeExpressionForExpressionStatement(expression) { - var emittedExpression = skipPartiallyEmittedExpressions(expression); - if (ts.isCallExpression(emittedExpression)) { - var callee = emittedExpression.expression; - var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 || kind === 180) { - var mutableCall = getMutableClone(emittedExpression); - mutableCall.expression = createParen(callee, callee); - return recreatePartiallyEmittedExpressions(expression, mutableCall); + function doOutsideOfContext(context, func) { + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + setContextFlag(false, contextFlagsToClear); + var result = func(); + setContextFlag(true, contextFlagsToClear); + return result; } + return func(); } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 || leftmostExpressionKind === 179) { - return createParen(expression, expression); + function doInsideOfContext(context, func) { + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + setContextFlag(true, contextFlagsToSet); + var result = func(); + setContextFlag(false, contextFlagsToSet); + return result; } + return func(); } - return expression; - } - ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; - function recreatePartiallyEmittedExpressions(originalOuterExpression, newInnerExpression) { - if (ts.isPartiallyEmittedExpression(originalOuterExpression)) { - var clone_1 = getMutableClone(originalOuterExpression); - clone_1.expression = recreatePartiallyEmittedExpressions(clone_1.expression, newInnerExpression); - return clone_1; - } - return newInnerExpression; - } - function getLeftmostExpression(node) { - while (true) { - switch (node.kind) { - case 186: - node = node.operand; - continue; - case 187: - node = node.left; - continue; - case 188: - node = node.condition; - continue; - case 174: - case 173: - case 172: - node = node.expression; - continue; - case 288: - node = node.expression; - continue; - } - return node; + function allowInAnd(func) { + return doOutsideOfContext(32768, func); } - } - function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171) { - return createParen(body, body); + function disallowInAnd(func) { + return doInsideOfContext(32768, func); } - return body; - } - ts.parenthesizeConciseBody = parenthesizeConciseBody; - function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7; } - var previousNode; - do { - previousNode = node; - if (kinds & 1) { - node = skipParentheses(node); - } - if (kinds & 2) { - node = skipAssertions(node); - } - if (kinds & 4) { - node = skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); - return node; - } - ts.skipOuterExpressions = skipOuterExpressions; - function skipParentheses(node) { - while (node.kind === 178) { - node = node.expression; + function doInYieldContext(func) { + return doInsideOfContext(65536, func); } - return node; - } - ts.skipParentheses = skipParentheses; - function skipAssertions(node) { - while (ts.isAssertionExpression(node)) { - node = node.expression; + function doInDecoratorContext(func) { + return doInsideOfContext(131072, func); } - return node; - } - ts.skipAssertions = skipAssertions; - function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288) { - node = node.expression; + function doInAwaitContext(func) { + return doInsideOfContext(262144, func); } - return node; - } - ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; - function startOnNewLine(node) { - node.startsOnNewLine = true; - return node; - } - ts.startOnNewLine = startOnNewLine; - function setOriginalNode(node, original) { - node.original = original; - if (original) { - var emitNode = original.emitNode; - if (emitNode) - node.emitNode = mergeEmitNode(emitNode, node.emitNode); + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(262144, func); } - return node; - } - ts.setOriginalNode = setOriginalNode; - function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; - if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) - destEmitNode = {}; - if (flags) - destEmitNode.flags = flags; - if (commentRange) - destEmitNode.commentRange = commentRange; - if (sourceMapRange) - destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) - destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); - return destEmitNode; - } - function mergeTokenSourceMapRanges(sourceRanges, destRanges) { - if (!destRanges) - destRanges = ts.createMap(); - ts.copyProperties(sourceRanges, destRanges); - return destRanges; - } - function disposeEmitNodes(sourceFile) { - sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); - var emitNode = sourceFile && sourceFile.emitNode; - var annotatedNodes = emitNode && emitNode.annotatedNodes; - if (annotatedNodes) { - for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { - var node = annotatedNodes_1[_i]; - node.emitNode = undefined; - } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(65536 | 262144, func); } - } - ts.disposeEmitNodes = disposeEmitNodes; - function getOrCreateEmitNode(node) { - if (!node.emitNode) { - if (ts.isParseTreeNode(node)) { - if (node.kind === 256) { - return node.emitNode = { annotatedNodes: [node] }; - } - var sourceFile = ts.getSourceFileOfNode(node); - getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); - } - node.emitNode = {}; + function inContext(flags) { + return (contextFlags & flags) !== 0; } - return node.emitNode; - } - function getEmitFlags(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.flags; - } - ts.getEmitFlags = getEmitFlags; - function setEmitFlags(node, emitFlags) { - getOrCreateEmitNode(node).flags = emitFlags; - return node; - } - ts.setEmitFlags = setEmitFlags; - function setSourceMapRange(node, range) { - getOrCreateEmitNode(node).sourceMapRange = range; - return node; - } - ts.setSourceMapRange = setSourceMapRange; - function setTokenSourceMapRange(node, token, range) { - var emitNode = getOrCreateEmitNode(node); - var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); - tokenSourceMapRanges[token] = range; - return node; - } - ts.setTokenSourceMapRange = setTokenSourceMapRange; - function setCommentRange(node, range) { - getOrCreateEmitNode(node).commentRange = range; - return node; - } - ts.setCommentRange = setCommentRange; - function getCommentRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.commentRange) || node; - } - ts.getCommentRange = getCommentRange; - function getSourceMapRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.sourceMapRange) || node; - } - ts.getSourceMapRange = getSourceMapRange; - function getTokenSourceMapRange(node, token) { - var emitNode = node.emitNode; - var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; - } - ts.getTokenSourceMapRange = getTokenSourceMapRange; - function getConstantValue(node) { - var emitNode = node.emitNode; - return emitNode && emitNode.constantValue; - } - ts.getConstantValue = getConstantValue; - function setConstantValue(node, value) { - var emitNode = getOrCreateEmitNode(node); - emitNode.constantValue = value; - return node; - } - ts.setConstantValue = setConstantValue; - function setTextRange(node, location) { - if (location) { - node.pos = location.pos; - node.end = location.end; + function inYieldContext() { + return inContext(65536); } - return node; - } - ts.setTextRange = setTextRange; - function setNodeFlags(node, flags) { - node.flags = flags; - return node; - } - ts.setNodeFlags = setNodeFlags; - function setMultiLine(node, multiLine) { - node.multiLine = multiLine; - return node; - } - ts.setMultiLine = setMultiLine; - function setHasTrailingComma(nodes, hasTrailingComma) { - nodes.hasTrailingComma = hasTrailingComma; - return nodes; - } - ts.setHasTrailingComma = setHasTrailingComma; - function getLocalNameForExternalImport(node, sourceFile) { - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_12 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + function inDisallowInContext() { + return inContext(32768); } - if (node.kind === 230 && node.importClause) { - return getGeneratedNameForNode(node); + function inDecoratorContext() { + return inContext(131072); } - if (node.kind === 236 && node.moduleSpecifier) { - return getGeneratedNameForNode(node); + function inAwaitContext() { + return inContext(262144); } - return undefined; - } - ts.getLocalNameForExternalImport = getLocalNameForExternalImport; - function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { - var moduleName = ts.getExternalModuleName(importNode); - if (moduleName.kind === 9) { - return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) - || tryRenameExternalModule(moduleName, sourceFile) - || getSynthesizedClone(moduleName); + function parseErrorAtCurrentToken(message, arg0) { + var start = scanner.getTokenPos(); + var length = scanner.getTextPos() - start; + parseErrorAtPosition(start, length, message, arg0); } - return undefined; - } - ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral; - function tryRenameExternalModule(moduleName, sourceFile) { - if (sourceFile.renamedDependencies && ts.hasProperty(sourceFile.renamedDependencies, moduleName.text)) { - return createLiteral(sourceFile.renamedDependencies[moduleName.text]); + function parseErrorAtPosition(start, length, message, arg0) { + var lastError = ts.lastOrUndefined(parseDiagnostics); + if (!lastError || start !== lastError.start) { + parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); + } + parseErrorBeforeNextFinishedNode = true; } - return undefined; - } - function tryGetModuleNameFromFile(file, host, options) { - if (!file) { - return undefined; + function scanError(message, length) { + var pos = scanner.getTextPos(); + parseErrorAtPosition(pos, length || 0, message); } - if (file.moduleName) { - return createLiteral(file.moduleName); + function getNodePos() { + return scanner.getStartPos(); } - if (!ts.isDeclarationFile(file) && (options.out || options.outFile)) { - return createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName)); + function getNodeEnd() { + return scanner.getStartPos(); } - return undefined; - } - ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile; - function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { - return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var NodeConstructor; - var TokenConstructor; - var IdentifierConstructor; - var SourceFileConstructor; - function createNode(kind, pos, end) { - if (kind === 256) { - return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); + function token() { + return currentToken; } - else if (kind === 69) { - return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); + function nextToken() { + return currentToken = scanner.scan(); } - else if (kind < 139) { - return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); + function reScanGreaterToken() { + return currentToken = scanner.reScanGreaterToken(); } - else { - return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end); + function reScanSlashToken() { + return currentToken = scanner.reScanSlashToken(); } - } - ts.createNode = createNode; - function visitNode(cbNode, node) { - if (node) { - return cbNode(node); + function reScanTemplateToken() { + return currentToken = scanner.reScanTemplateToken(); } - } - function visitNodeArray(cbNodes, nodes) { - if (nodes) { - return cbNodes(nodes); + function scanJsxIdentifier() { + return currentToken = scanner.scanJsxIdentifier(); } - } - function visitEachNode(cbNode, nodes) { - if (nodes) { - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var node = nodes_1[_i]; - var result = cbNode(node); - if (result) { - return result; - } - } + function scanJsxText() { + return currentToken = scanner.scanJsxToken(); } - } - function forEachChild(node, cbNode, cbNodeArray) { - if (!node) { - return; + function scanJsxAttributeValue() { + return currentToken = scanner.scanJsxAttributeValue(); } - var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; - var cbNodes = cbNodeArray || cbNode; - switch (node.kind) { - case 139: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.right); - case 141: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.constraint) || - visitNode(cbNode, node.expression); - case 254: - 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 142: - case 145: - case 144: - case 253: - case 218: - case 169: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.dotDotDotToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.initializer); - case 156: - case 157: - case 151: - case 152: - case 153: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 147: - case 146: - case 148: - case 149: - case 150: - case 179: - case 220: - case 180: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.questionToken) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type) || - visitNode(cbNode, node.equalsGreaterThanToken) || - visitNode(cbNode, node.body); - case 155: - return visitNode(cbNode, node.typeName) || - visitNodes(cbNodes, node.typeArguments); - case 154: - return visitNode(cbNode, node.parameterName) || - visitNode(cbNode, node.type); - case 158: - return visitNode(cbNode, node.exprName); - case 159: - return visitNodes(cbNodes, node.members); - case 160: - return visitNode(cbNode, node.elementType); - case 161: - return visitNodes(cbNodes, node.elementTypes); - case 162: - case 163: - return visitNodes(cbNodes, node.types); - case 164: - return visitNode(cbNode, node.type); - case 166: - return visitNode(cbNode, node.literal); - case 167: - case 168: - return visitNodes(cbNodes, node.elements); - case 170: - return visitNodes(cbNodes, node.elements); - case 171: - return visitNodes(cbNodes, node.properties); - case 172: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); - case 173: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); - case 174: - case 175: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments) || - visitNodes(cbNodes, node.arguments); - case 176: - return visitNode(cbNode, node.tag) || - visitNode(cbNode, node.template); - case 177: - return visitNode(cbNode, node.type) || - visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 181: - return visitNode(cbNode, node.expression); - case 182: - return visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.operand); - case 190: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); - case 184: - return visitNode(cbNode, node.expression); - case 186: - return visitNode(cbNode, node.operand); - case 187: - return visitNode(cbNode, node.left) || - visitNode(cbNode, node.operatorToken) || - visitNode(cbNode, node.right); - case 195: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.type); - case 196: - return visitNode(cbNode, node.expression); - case 188: - return visitNode(cbNode, node.condition) || - visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.whenTrue) || - visitNode(cbNode, node.colonToken) || - visitNode(cbNode, node.whenFalse); - case 191: - return visitNode(cbNode, node.expression); - case 199: - case 226: - return visitNodes(cbNodes, node.statements); - case 256: - return visitNodes(cbNodes, node.statements) || - visitNode(cbNode, node.endOfFileToken); - case 200: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.declarationList); - case 219: - return visitNodes(cbNodes, node.declarations); - case 202: - return visitNode(cbNode, node.expression); - case 203: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.thenStatement) || - visitNode(cbNode, node.elseStatement); - case 204: - return visitNode(cbNode, node.statement) || - visitNode(cbNode, node.expression); - case 205: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 206: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || - visitNode(cbNode, node.statement); - case 207: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 208: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 209: - case 210: - return visitNode(cbNode, node.label); - case 211: - return visitNode(cbNode, node.expression); - case 212: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 213: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 227: - return visitNodes(cbNodes, node.clauses); - case 249: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 250: - return visitNodes(cbNodes, node.statements); - case 214: - return visitNode(cbNode, node.label) || - visitNode(cbNode, node.statement); - case 215: - return visitNode(cbNode, node.expression); - case 216: - return visitNode(cbNode, node.tryBlock) || - visitNode(cbNode, node.catchClause) || - visitNode(cbNode, node.finallyBlock); - case 252: - return visitNode(cbNode, node.variableDeclaration) || - visitNode(cbNode, node.block); - case 143: - return visitNode(cbNode, node.expression); - case 221: - case 192: - 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 222: - 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 223: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); - case 224: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 255: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 225: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.body); - case 229: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.moduleReference); - case 230: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.importClause) || - visitNode(cbNode, node.moduleSpecifier); - case 231: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.namedBindings); - case 228: - return visitNode(cbNode, node.name); - case 232: - return visitNode(cbNode, node.name); - case 233: - case 237: - return visitNodes(cbNodes, node.elements); - case 236: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.exportClause) || - visitNode(cbNode, node.moduleSpecifier); - case 234: - case 238: - return visitNode(cbNode, node.propertyName) || - visitNode(cbNode, node.name); - case 235: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.expression); - case 189: - return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197: - return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140: - return visitNode(cbNode, node.expression); - case 251: - return visitNodes(cbNodes, node.types); - case 194: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.expression); - case 239: - return visitNodes(cbNodes, node.decorators); - case 241: - return visitNode(cbNode, node.openingElement) || - visitNodes(cbNodes, node.children) || - visitNode(cbNode, node.closingElement); - case 242: - case 243: - return visitNode(cbNode, node.tagName) || - visitNodes(cbNodes, node.attributes); - case 246: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); - case 247: - return visitNode(cbNode, node.expression); - case 248: - return visitNode(cbNode, node.expression); - case 245: - return visitNode(cbNode, node.tagName); - case 257: - return visitNode(cbNode, node.type); - case 261: - return visitNodes(cbNodes, node.types); - case 262: - return visitNodes(cbNodes, node.types); - case 260: - return visitNode(cbNode, node.elementType); - case 264: - return visitNode(cbNode, node.type); - case 263: - return visitNode(cbNode, node.type); - case 265: - return visitNode(cbNode, node.literal); - case 267: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); - case 268: - return visitNode(cbNode, node.type); - case 269: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 270: - return visitNode(cbNode, node.type); - case 271: - return visitNode(cbNode, node.type); - case 272: - return visitNode(cbNode, node.type); - case 266: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.type); - case 273: - return visitNodes(cbNodes, node.tags); - case 275: - return visitNode(cbNode, node.preParameterName) || - visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.postParameterName); - case 276: - return visitNode(cbNode, node.typeExpression); - case 277: - return visitNode(cbNode, node.typeExpression); - case 278: - return visitNodes(cbNodes, node.typeParameters); - case 279: - return visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name) || - visitNode(cbNode, node.jsDocTypeLiteral); - case 281: - return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280: - return visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name); - case 288: - return visitNode(cbNode, node.expression); - case 282: - return visitNode(cbNode, node.literal); - } - } - ts.forEachChild = forEachChild; - function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { - if (setParentNodes === void 0) { setParentNodes = false; } - ts.performance.mark("beforeParse"); - var result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind); - ts.performance.mark("afterParse"); - ts.performance.measure("Parse", "beforeParse", "afterParse"); - return result; - } - ts.createSourceFile = createSourceFile; - function isExternalModule(file) { - return file.externalModuleIndicator !== undefined; - } - ts.isExternalModule = isExternalModule; - function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - } - ts.updateSourceFile = updateSourceFile; - function parseIsolatedJSDocComment(content, start, length) { - var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); - if (result && result.jsDoc) { - Parser.fixupParentReferences(result.jsDoc); - } - return result; - } - ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment; - function parseJSDocTypeExpressionForTests(content, start, length) { - return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length); - } - ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - var Parser; - (function (Parser) { - var scanner = ts.createScanner(2, true); - var disallowInAndDecoratorContext = 32768 | 131072; - var NodeConstructor; - var TokenConstructor; - var IdentifierConstructor; - var SourceFileConstructor; - var sourceFile; - var parseDiagnostics; - var syntaxCursor; - var currentToken; - var sourceText; - var nodeCount; - var identifiers; - var identifierCount; - var parsingContext; - var contextFlags; - var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { - scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); - var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); - clearState(); + function speculationHelper(callback, isLookAhead) { + var saveToken = currentToken; + var saveParseDiagnosticsLength = parseDiagnostics.length; + var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; + var saveContextFlags = contextFlags; + var result = isLookAhead + ? scanner.lookAhead(callback) + : scanner.tryScan(callback); + ts.Debug.assert(saveContextFlags === contextFlags); + if (!result || isLookAhead) { + currentToken = saveToken; + parseDiagnostics.length = saveParseDiagnosticsLength; + parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; + } return result; } - Parser.parseSourceFile = parseSourceFile; - function getLanguageVariant(scriptKind) { - return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; - } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { - NodeConstructor = ts.objectAllocator.getNodeConstructor(); - TokenConstructor = ts.objectAllocator.getTokenConstructor(); - IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); - SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor(); - sourceText = _sourceText; - syntaxCursor = _syntaxCursor; - parseDiagnostics = []; - parsingContext = 0; - identifiers = ts.createMap(); - identifierCount = 0; - nodeCount = 0; - contextFlags = scriptKind === 1 || scriptKind === 2 ? 1048576 : 0; - parseErrorBeforeNextFinishedNode = false; - scanner.setText(sourceText); - scanner.setOnError(scanError); - scanner.setScriptTarget(languageVersion); - scanner.setLanguageVariant(getLanguageVariant(scriptKind)); + function lookAhead(callback) { + return speculationHelper(callback, true); } - function clearState() { - scanner.setText(""); - scanner.setOnError(undefined); - parseDiagnostics = undefined; - sourceFile = undefined; - identifiers = undefined; - syntaxCursor = undefined; - sourceText = undefined; + function tryParse(callback) { + return speculationHelper(callback, false); } - function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { - sourceFile = createSourceFile(fileName, languageVersion, scriptKind); - sourceFile.flags = contextFlags; - nextToken(); - processReferenceComments(sourceFile); - sourceFile.statements = parseList(0, parseStatement); - ts.Debug.assert(token() === 1); - sourceFile.endOfFileToken = parseTokenNode(); - setExternalModuleIndicator(sourceFile); - sourceFile.nodeCount = nodeCount; - sourceFile.identifierCount = identifierCount; - sourceFile.identifiers = identifiers; - sourceFile.parseDiagnostics = parseDiagnostics; - if (setParentNodes) { - fixupParentReferences(sourceFile); + function isIdentifier() { + if (token() === 70) { + return true; } - return sourceFile; + if (token() === 115 && inYieldContext()) { + return false; + } + if (token() === 120 && inAwaitContext()) { + return false; + } + return token() > 106; } - function addJSDocComment(node) { - var comments = ts.getJsDocCommentsFromText(node, sourceFile.text); - if (comments) { - for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { - var comment = comments_2[_i]; - var jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (!jsDoc) { - continue; - } - if (!node.jsDocComments) { - node.jsDocComments = []; - } - node.jsDocComments.push(jsDoc); + function parseExpected(kind, diagnosticMessage, shouldAdvance) { + if (shouldAdvance === void 0) { shouldAdvance = true; } + if (token() === kind) { + if (shouldAdvance) { + nextToken(); } + return true; } - return node; - } - function fixupParentReferences(rootNode) { - var parent = rootNode; - forEachChild(rootNode, visitNode); - return; - function visitNode(n) { - if (n.parent !== parent) { - n.parent = parent; - var saveParent = parent; - parent = n; - forEachChild(n, visitNode); - if (n.jsDocComments) { - for (var _i = 0, _a = n.jsDocComments; _i < _a.length; _i++) { - var jsDocComment = _a[_i]; - jsDocComment.parent = n; - parent = jsDocComment; - forEachChild(jsDocComment, visitNode); - } - } - parent = saveParent; - } - } - } - Parser.fixupParentReferences = fixupParentReferences; - function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); - nodeCount++; - sourceFile.text = sourceText; - sourceFile.bindDiagnostics = []; - sourceFile.languageVersion = languageVersion; - sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.languageVariant = getLanguageVariant(scriptKind); - sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); - sourceFile.scriptKind = scriptKind; - return sourceFile; - } - function setContextFlag(val, flag) { - if (val) { - contextFlags |= flag; - } - else { - contextFlags &= ~flag; - } - } - function setDisallowInContext(val) { - setContextFlag(val, 32768); - } - function setYieldContext(val) { - setContextFlag(val, 65536); - } - function setDecoratorContext(val) { - setContextFlag(val, 131072); - } - function setAwaitContext(val) { - setContextFlag(val, 262144); - } - function doOutsideOfContext(context, func) { - var contextFlagsToClear = context & contextFlags; - if (contextFlagsToClear) { - setContextFlag(false, contextFlagsToClear); - var result = func(); - setContextFlag(true, contextFlagsToClear); - return result; - } - return func(); - } - function doInsideOfContext(context, func) { - var contextFlagsToSet = context & ~contextFlags; - if (contextFlagsToSet) { - setContextFlag(true, contextFlagsToSet); - var result = func(); - setContextFlag(false, contextFlagsToSet); - return result; - } - return func(); - } - function allowInAnd(func) { - return doOutsideOfContext(32768, func); - } - function disallowInAnd(func) { - return doInsideOfContext(32768, func); - } - function doInYieldContext(func) { - return doInsideOfContext(65536, func); - } - function doInDecoratorContext(func) { - return doInsideOfContext(131072, func); - } - function doInAwaitContext(func) { - return doInsideOfContext(262144, func); - } - function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(262144, func); - } - function doInYieldAndAwaitContext(func) { - return doInsideOfContext(65536 | 262144, func); - } - function inContext(flags) { - return (contextFlags & flags) !== 0; - } - function inYieldContext() { - return inContext(65536); - } - function inDisallowInContext() { - return inContext(32768); - } - function inDecoratorContext() { - return inContext(131072); - } - function inAwaitContext() { - return inContext(262144); - } - function parseErrorAtCurrentToken(message, arg0) { - var start = scanner.getTokenPos(); - var length = scanner.getTextPos() - start; - parseErrorAtPosition(start, length, message, arg0); - } - function parseErrorAtPosition(start, length, message, arg0) { - var lastError = ts.lastOrUndefined(parseDiagnostics); - if (!lastError || start !== lastError.start) { - parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); - } - parseErrorBeforeNextFinishedNode = true; - } - function scanError(message, length) { - var pos = scanner.getTextPos(); - parseErrorAtPosition(pos, length || 0, message); - } - function getNodePos() { - return scanner.getStartPos(); - } - function getNodeEnd() { - return scanner.getStartPos(); - } - function token() { - return currentToken; - } - function nextToken() { - return currentToken = scanner.scan(); - } - function reScanGreaterToken() { - return currentToken = scanner.reScanGreaterToken(); - } - function reScanSlashToken() { - return currentToken = scanner.reScanSlashToken(); - } - function reScanTemplateToken() { - return currentToken = scanner.reScanTemplateToken(); - } - function scanJsxIdentifier() { - return currentToken = scanner.scanJsxIdentifier(); - } - function scanJsxText() { - return currentToken = scanner.scanJsxToken(); - } - function scanJsxAttributeValue() { - return currentToken = scanner.scanJsxAttributeValue(); - } - function speculationHelper(callback, isLookAhead) { - var saveToken = currentToken; - var saveParseDiagnosticsLength = parseDiagnostics.length; - var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var saveContextFlags = contextFlags; - var result = isLookAhead - ? scanner.lookAhead(callback) - : scanner.tryScan(callback); - ts.Debug.assert(saveContextFlags === contextFlags); - if (!result || isLookAhead) { - currentToken = saveToken; - parseDiagnostics.length = saveParseDiagnosticsLength; - parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; - } - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryParse(callback) { - return speculationHelper(callback, false); - } - function isIdentifier() { - if (token() === 69) { - return true; - } - if (token() === 114 && inYieldContext()) { - return false; - } - if (token() === 119 && inAwaitContext()) { - return false; - } - return token() > 105; - } - function parseExpected(kind, diagnosticMessage, shouldAdvance) { - if (shouldAdvance === void 0) { shouldAdvance = true; } - if (token() === kind) { - if (shouldAdvance) { - nextToken(); - } - return true; - } - if (diagnosticMessage) { - parseErrorAtCurrentToken(diagnosticMessage); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); - } - return false; + if (diagnosticMessage) { + parseErrorAtCurrentToken(diagnosticMessage); + } + else { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); + } + return false; } function parseOptional(t) { if (token() === t) { @@ -13176,20 +12663,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 23) { + if (token() === 24) { return true; } - return token() === 16 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23) { + if (token() === 24) { nextToken(); } return true; } else { - return parseExpected(23); + return parseExpected(24); } } function createNode(kind, pos) { @@ -13197,8 +12684,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 ? new NodeConstructor(kind, pos, pos) : - kind === 69 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13239,15 +12726,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69); - if (token() !== 69) { + var node = createNode(70); + if (token() !== 70) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13264,7 +12751,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 19) { + if (allowComputedPropertyNames && token() === 20) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13279,10 +12766,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(140); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(141); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); return finishNode(node); } function parseContextualModifier(t) { @@ -13296,20 +12783,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74) { - return nextToken() === 81; + if (token() === 75) { + return nextToken() === 82; } - if (token() === 82) { + if (token() === 83) { nextToken(); - if (token() === 77) { + if (token() === 78) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 && token() !== 116 && token() !== 15 && canFollowModifier(); + return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); } - if (token() === 77) { + if (token() === 78) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113) { + if (token() === 114) { nextToken(); return canFollowModifier(); } @@ -13319,16 +12806,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 - || token() === 15 - || token() === 37 - || token() === 22 + return token() === 20 + || token() === 16 + || token() === 38 + || token() === 23 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 || token() === 87 || - (token() === 118 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 || token() === 88 || + (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -13339,21 +12826,21 @@ var ts; case 0: case 1: case 3: - return !(token() === 23 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 71 || token() === 77; + return token() === 72 || token() === 78; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 23 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); case 6: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 19 || token() === 37 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || isLiteralPropertyName(); case 9: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 7: - if (token() === 15) { + if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13365,23 +12852,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 24 || token() === 22 || isIdentifierOrPattern(); + return token() === 25 || token() === 23 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token() === 24 || token() === 22 || isStartOfExpression(); + return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token() === 24 || isStartOfType(); + return token() === 25 || isStartOfType(); case 20: return isHeritageClause(); case 21: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; case 22: @@ -13394,10 +12881,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15); - if (nextToken() === 16) { + ts.Debug.assert(token() === 16); + if (nextToken() === 17) { var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; + return next === 25 || next === 16 || next === 84 || next === 107; } return true; } @@ -13410,8 +12897,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 || - token() === 83) { + if (token() === 107 || + token() === 84) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -13433,39 +12920,39 @@ var ts; case 12: case 9: case 21: - return token() === 16; + return token() === 17; case 3: - return token() === 16 || token() === 71 || token() === 77; + return token() === 17 || token() === 72 || token() === 78; case 7: - return token() === 15 || token() === 83 || token() === 106; + return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token() === 27 || token() === 17 || token() === 15 || token() === 83 || token() === 106; + return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: - return token() === 18 || token() === 23; + return token() === 19 || token() === 24; case 15: case 19: case 10: - return token() === 20; + return token() === 21; case 16: - return token() === 18 || token() === 20; + return token() === 19 || token() === 21; case 18: - return token() !== 24; + return token() !== 25; case 20: - return token() === 15 || token() === 16; + return token() === 16 || token() === 17; case 13: - return token() === 27 || token() === 39; + return token() === 28 || token() === 40; case 14: - return token() === 25 && lookAhead(nextTokenIsSlash); + return token() === 26 && lookAhead(nextTokenIsSlash); case 22: - return token() === 18 || token() === 54 || token() === 16; + return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 27 || token() === 16; + return token() === 28 || token() === 17; case 25: - return token() === 20 || token() === 16; + return token() === 21 || token() === 17; case 24: - return token() === 16; + return token() === 17; } } function isVariableDeclaratorListTerminator() { @@ -13475,7 +12962,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 34) { + if (token() === 35) { return true; } return false; @@ -13579,17 +13066,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148: - case 153: case 149: + case 154: case 150: - case 145: - case 198: + case 151: + case 146: + case 199: return true; - case 147: + case 148: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; + var nameIsConstructor = methodDeclaration.name.kind === 70 && + methodDeclaration.name.originalKeywordKind === 122; return !nameIsConstructor; } } @@ -13608,35 +13095,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220: + case 221: + case 201: case 200: - case 199: + case 204: case 203: - case 202: - case 215: + case 216: + case 212: + case 214: case 211: - case 213: case 210: + case 208: case 209: case 207: - case 208: case 206: - case 205: - case 212: - case 201: - case 216: - case 214: - case 204: + case 213: + case 202: case 217: + case 215: + case 205: + case 218: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 225: - case 221: + case 226: case 222: - case 224: case 223: + case 225: + case 224: return true; } } @@ -13648,25 +13135,25 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152: - case 146: case 153: - case 144: - case 151: + case 147: + case 154: + case 145: + case 152: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218) { + if (node.kind !== 219) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var parameter = node; @@ -13720,15 +13207,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { + if (parseOptional(25)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(24); - if (considerSemicolonAsDelimiter && token() === 23 && !scanner.hasPrecedingLineBreak()) { + parseExpected(25); + if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -13760,8 +13247,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(139, entity.pos); + while (parseOptional(22)) { + var node = createNode(140, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -13772,33 +13259,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189); + var template = createNode(190); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197); + var span = createNode(198); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16) { + if (token() === 17) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); } span.literal = literal; return finishNode(span); @@ -13808,12 +13295,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -13838,35 +13325,35 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(155, typeName.pos); + var node = createNode(156, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (!scanner.hasPrecedingLineBreak() && token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154, lhs.pos); + var node = createNode(155, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165); + var node = createNode(166); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158); - parseExpected(101); + var node = createNode(159); + parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141); + var node = createNode(142); node.name = parseIdentifier(); - if (parseOptional(83)) { + if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -13877,34 +13364,34 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); + if (token() === 26) { + return parseBracketedList(17, parseTypeParameter, 26, 28); } } function parseParameterType() { - if (parseOptional(54)) { + if (parseOptional(55)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 || token() === 97; + return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(142); - if (token() === 97) { + var node = createNode(143); + if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(53); + node.questionToken = parseOptionalToken(54); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -13916,7 +13403,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; + var returnTokenRequired = returnToken === 35; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -13928,7 +13415,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { + if (parseExpected(18)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -13936,7 +13423,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { + if (!parseExpected(19) && requireCompleteParameterList) { return undefined; } return result; @@ -13944,29 +13431,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(24)) { + if (parseOptional(25)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152) { - parseExpected(92); + if (kind === 153) { + parseExpected(93); } - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19) { + if (token() !== 20) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 22 || token() === 20) { + if (token() === 23 || token() === 21) { return true; } if (ts.isModifierKind(token())) { @@ -13981,43 +13468,43 @@ var ts; else { nextToken(); } - if (token() === 54 || token() === 24) { + if (token() === 55 || token() === 25) { return true; } - if (token() !== 53) { + if (token() !== 54) { return false; } nextToken(); - return token() === 54 || token() === 24 || token() === 20; + return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153, fullStart); + var node = createNode(154, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.parameters = parseBracketedList(16, parseParameter, 20, 21); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token() === 17 || token() === 25) { - var method = createNode(146, fullStart); + var questionToken = parseOptionalToken(54); + if (token() === 18 || token() === 26) { + var method = createNode(147, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(54, false, false, false, method); + fillSignature(55, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144, fullStart); + var property = createNode(145, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56) { + if (token() === 57) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -14026,14 +13513,14 @@ var ts; } function isTypeMemberStart() { var idToken; - if (token() === 17 || token() === 25) { + if (token() === 18 || token() === 26) { return true; } while (ts.isModifierKind(token())) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (isLiteralPropertyName()) { @@ -14041,22 +13528,22 @@ var ts; nextToken(); } if (idToken) { - return token() === 17 || - token() === 25 || - token() === 53 || + return token() === 18 || + token() === 26 || token() === 54 || - token() === 24 || + token() === 55 || + token() === 25 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 || token() === 25) { - return parseSignatureMember(151); - } - if (token() === 92 && lookAhead(isStartOfConstructSignature)) { + if (token() === 18 || token() === 26) { return parseSignatureMember(152); } + if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -14066,18 +13553,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 || token() === 25; + return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(159); + var node = createNode(160); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15)) { + if (parseExpected(16)) { members = parseList(4, parseTypeMember); - parseExpected(16); + parseExpected(17); } else { members = createMissingList(); @@ -14085,31 +13572,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); + var node = createNode(162); + node.elementTypes = parseBracketedList(19, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164); - parseExpected(17); - node.type = parseType(); + var node = createNode(165); parseExpected(18); + node.type = parseType(); + parseExpected(19); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157) { - parseExpected(92); + if (kind === 158) { + parseExpected(93); } - fillSignature(34, false, false, false, node); + fillSignature(35, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 ? undefined : node; + return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166); + var node = createNode(167); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14119,41 +13606,41 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 135: - case 127: + case 131: + case 121: + case 134: + case 136: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseLiteralTypeNode(); - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103: - case 93: + case 104: + case 94: return parseTokenNode(); - case 97: { + case 98: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101: + case 102: return parseTypeQuery(); - case 15: + case 16: return parseTypeLiteral(); - case 19: + case 20: return parseTupleType(); - case 17: + case 18: return parseParenthesizedType(); default: return parseTypeReference(); @@ -14161,29 +13648,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 98: + case 102: + case 128: + case 16: + case 20: + case 26: case 93: - case 97: - case 101: - case 127: - case 15: - case 19: - case 25: - case 92: case 9: case 8: - case 99: - case 84: + case 100: + case 85: return true; - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral); - case 17: + case 18: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -14191,13 +13678,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 || isStartOfParameter() || isStartOfType(); + return token() === 19 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(160, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + parseExpected(21); + var node = createNode(161, type.pos); node.elementType = type; type = finishNode(node); } @@ -14218,26 +13705,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { - if (token() === 25) { + if (token() === 26) { return true; } - return token() === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 97) { + if (isIdentifier() || token() === 98) { nextToken(); return true; } - if (token() === 19 || token() === 15) { + if (token() === 20 || token() === 16) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -14246,17 +13733,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 || token() === 22) { + if (token() === 19 || token() === 23) { return true; } if (skipParameterStart()) { - if (token() === 54 || token() === 24 || - token() === 53 || token() === 56) { + if (token() === 55 || token() === 25 || + token() === 54 || token() === 57) { return true; } - if (token() === 18) { + if (token() === 19) { nextToken(); - if (token() === 34) { + if (token() === 35) { return true; } } @@ -14267,7 +13754,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154, typePredicateVariable.pos); + var node = createNode(155, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14278,7 +13765,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -14288,36 +13775,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156); - } - if (token() === 92) { return parseFunctionOrConstructorType(157); } + if (token() === 93) { + return parseFunctionOrConstructorType(158); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; + return parseOptional(55) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: case 8: case 9: - case 11: case 12: - case 17: - case 19: - case 15: - case 87: - case 73: - case 92: - case 39: - case 61: - case 69: + case 13: + case 18: + case 20: + case 16: + case 88: + case 74: + case 93: + case 40: + case 62: + case 70: return true; default: return isIdentifier(); @@ -14328,18 +13815,18 @@ var ts; return true; } switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 41: + case 79: + case 102: + case 104: case 42: - case 25: - case 119: - case 114: + case 43: + case 26: + case 120: + case 115: return true; default: if (isBinaryOperator()) { @@ -14349,10 +13836,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 15 && - token() !== 87 && - token() !== 73 && - token() !== 55 && + return token() !== 16 && + token() !== 88 && + token() !== 74 && + token() !== 56 && isStartOfExpression(); } function parseExpression() { @@ -14362,7 +13849,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { + while ((operatorToken = parseOptionalToken(25))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -14371,12 +13858,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15) || !isStartOfExpression()) { + if (token() !== 57) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { return undefined; } } - parseExpected(56); + parseExpected(57); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -14388,7 +13875,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token() === 34) { + if (expr.kind === 70 && token() === 35) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -14397,7 +13884,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114) { + if (token() === 115) { if (inYieldContext()) { return true; } @@ -14410,11 +13897,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); + (token() === 38 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14423,21 +13910,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180, asyncModifier.pos); + node = createNode(181, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180, identifier.pos); + node = createNode(181, identifier.pos); } - var parameter = createNode(142, identifier.pos); + var parameter = createNode(143, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -14454,78 +13941,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 || lastToken === 16) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 17 || token() === 25 || token() === 118) { + if (token() === 18 || token() === 26 || token() === 119) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34) { + if (token() === 35) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 17 && token() !== 25) { + if (token() !== 18 && token() !== 26) { return 0; } } var first = token(); var second = nextToken(); - if (first === 17) { - if (second === 18) { + if (first === 18) { + if (second === 19) { var third = nextToken(); switch (third) { - case 34: - case 54: - case 15: + case 35: + case 55: + case 16: return 1; default: return 0; } } - if (second === 19 || second === 15) { + if (second === 20 || second === 16) { return 2; } - if (second === 22) { + if (second === 23) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 54) { + if (nextToken() === 55) { return 1; } return 2; } else { - ts.Debug.assert(first === 25); + ts.Debug.assert(first === 26); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83) { + if (third === 84) { var fourth = nextToken(); switch (fourth) { - case 56: - case 27: + case 57: + case 28: return false; default: return true; } } - else if (third === 24) { + else if (third === 25) { return true; } return false; @@ -14542,7 +14029,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 118) { + if (token() === 119) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -14553,38 +14040,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 34) { + if (scanner.hasPrecedingLineBreak() || token() === 35) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 && token() === 34) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180); + var node = createNode(181); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(54, false, isAsync, !allowAmbiguity, node); + fillSignature(55, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 34 && token() !== 15) { + if (!allowAmbiguity && token() !== 35 && token() !== 16) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15) { + if (token() === 16) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 23 && - token() !== 87 && - token() !== 73 && + if (token() !== 24 && + token() !== 88 && + token() !== 74 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -14594,15 +14081,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); + var questionToken = parseOptionalToken(54); if (!questionToken) { return leftOperand; } - var node = createNode(188, leftOperand.pos); + var node = createNode(189, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); + node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14611,22 +14098,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 138; + return t === 91 || t === 139; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 38 ? + var consumeCurrentOperator = token() === 39 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 && inDisallowInContext()) { + if (token() === 91 && inDisallowInContext()) { break; } - if (token() === 116) { + if (token() === 117) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -14642,92 +14129,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90) { + if (inDisallowInContext() && token() === 91) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52: + case 53: return 1; - case 51: + case 52: return 2; - case 47: - return 3; case 48: + return 3; + case 49: return 4; - case 46: + case 47: return 5; - case 30: case 31: case 32: case 33: + case 34: return 6; - case 25: - case 27: + case 26: case 28: case 29: + case 30: + case 92: case 91: - case 90: - case 116: + case 117: return 7; - case 43: case 44: case 45: + case 46: return 8; - case 35: case 36: - return 9; case 37: - case 39: + return 9; + case 38: case 40: + case 41: return 10; - case 38: + case 39: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187, left.pos); + var node = createNode(188, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195, left.pos); + var node = createNode(196, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185); + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(182); + var node = createNode(183); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(183); + var node = createNode(184); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 119) { + if (token() === 120) { if (inAwaitContext()) { return true; } @@ -14736,7 +14223,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14744,15 +14231,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 ? + return token() === 39 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38) { + if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177) { + if (simpleUnaryExpression.kind === 178) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -14763,20 +14250,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: return parsePrefixUnaryExpression(); - case 78: + case 79: return parseDeleteExpression(); - case 101: + case 102: return parseTypeOfExpression(); - case 103: + case 104: return parseVoidExpression(); - case 25: + case 26: return parseTypeAssertion(); - case 119: + case 120: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -14786,16 +14273,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 119: + case 79: + case 102: + case 104: + case 120: return false; - case 25: + case 26: if (sourceFile.languageVariant !== 1) { return false; } @@ -14804,20 +14291,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 41 || token() === 42) { - var node = createNode(185); + if (token() === 42 || token() === 43) { + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 || token() === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186, expression.pos); + if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14826,7 +14313,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 95 + var expression = token() === 96 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -14837,12 +14324,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 || token() === 21 || token() === 19) { + if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(172, expression.pos); + var node = createNode(173, expression.pos); node.expression = expression; - parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -14850,10 +14337,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69) { + if (lhs.kind === 70) { return lhs.text === rhs.text; } - if (lhs.kind === 97) { + if (lhs.kind === 98) { return true; } return lhs.name.text === rhs.name.text && @@ -14862,8 +14349,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243) { - var node = createNode(241, opening.pos); + if (opening.kind === 244) { + var node = createNode(242, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14873,18 +14360,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242); + ts.Debug.assert(opening.kind === 243); result = opening; } - if (inExpressionContext && token() === 25) { + if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187, result.pos); + var badNode = createNode(188, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken = createMissingNode(25, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -14892,17 +14379,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(10, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244: + case 10: return parseJsxText(); - case 15: + case 16: return parseJsxExpression(false); - case 25: + case 26: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -14913,7 +14400,7 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26) { + if (token() === 27) { break; } else if (token() === 1) { @@ -14928,24 +14415,24 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25); + parseExpected(26); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (token() === 27) { - node = createNode(243, fullStart); + if (token() === 28) { + node = createNode(244, fullStart); scanJsxText(); } else { - parseExpected(39); + parseExpected(40); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(242, fullStart); + node = createNode(243, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -14953,10 +14440,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 97 ? + var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21)) { - var propertyAccess = createNode(172, expression.pos); + while (parseOptional(22)) { + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14965,27 +14452,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); - parseExpected(15); - if (token() !== 16) { + parseExpected(16); + if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16); + parseExpected(17); } else { - parseExpected(16, undefined, false); + parseExpected(17, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15) { + if (token() === 16) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246); node.name = parseIdentifierName(); - if (token() === 56) { + if (token() === 57) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -14999,68 +14486,68 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); parseExpected(16); + parseExpected(23); + node.expression = parseExpression(); + parseExpected(17); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245); - parseExpected(26); + parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177); - parseExpected(25); + var node = createNode(178); + parseExpected(26); node.type = parseType(); - parseExpected(27); + parseExpected(28); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21); + var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(172, expression.pos); + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196, expression.pos); + var nonNullExpression = createNode(197, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(173, expression.pos); + if (!inDecoratorContext() && parseOptional(20)) { + var indexedAccess = createNode(174, expression.pos); indexedAccess.expression = expression; - if (token() !== 20) { + if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20); + parseExpected(21); expression = finishNode(indexedAccess); continue; } - if (token() === 11 || token() === 12) { - var tagExpression = createNode(176, expression.pos); + if (token() === 12 || token() === 13) { + var tagExpression = createNode(177, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 + tagExpression.template = token() === 12 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -15072,20 +14559,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25) { + if (token() === 26) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(174, expression.pos); + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17) { - var callExpr = createNode(174, expression.pos); + else if (token() === 18) { + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15095,17 +14582,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(18); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(19); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { + if (!parseOptional(26)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { + if (!parseExpected(28)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -15114,27 +14601,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17: - case 21: case 18: - case 20: + case 22: + case 19: + case 21: + case 55: + case 24: case 54: - case 23: - case 53: - case 30: - case 32: case 31: case 33: - case 51: + case 32: + case 34: case 52: - case 48: - case 46: + case 53: + case 49: case 47: - case 16: + case 48: + case 17: case 1: return true; - case 24: - case 15: + case 25: + case 16: default: return false; } @@ -15143,80 +14630,80 @@ var ts; switch (token()) { case 8: case 9: - case 11: + case 12: return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: return parseTokenNode(); - case 17: + case 18: return parseParenthesizedExpression(); - case 19: + case 20: return parseArrayLiteralExpression(); - case 15: + case 16: return parseObjectLiteralExpression(); - case 118: + case 119: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 73: + case 74: return parseClassExpression(); - case 87: + case 88: return parseFunctionExpression(); - case 92: + case 93: return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { + case 40: + case 62: + if (reScanSlashToken() === 11) { return parseLiteralNode(); } break; - case 12: + case 13: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(179); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 ? parseSpreadElement() : - token() === 24 ? createNode(193) : + return token() === 23 ? parseSpreadElement() : + token() === 25 ? createNode(194) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170); - parseExpected(19); + var node = createNode(171); + parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); + parseExpected(21); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(149, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(131)) { + if (parseContextualModifier(124)) { return parseAccessorDeclaration(150, fullStart, decorators, modifiers); } + else if (parseContextualModifier(132)) { + return parseAccessorDeclaration(151, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -15227,19 +14714,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 || token() === 16 || token() === 56); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); + var equalsToken = parseOptionalToken(57); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15251,19 +14738,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54); + parseExpected(55); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171); - parseExpected(15); + var node = createNode(172); + parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); + parseExpected(17); return finishNode(node); } function parseFunctionExpression() { @@ -15271,10 +14758,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(179); + var node = createNode(180); node.modifiers = parseModifiers(); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -15282,7 +14769,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -15293,23 +14780,23 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175); - parseExpected(92); + var node = createNode(176); + parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17) { + if (node.typeArguments || token() === 18) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200); + if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -15334,47 +14821,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201); - parseExpected(23); + var node = createNode(202); + parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(203); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(89); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204); - parseExpected(79); + var node = createNode(205); + parseExpected(80); node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + parseExpected(105); parseExpected(18); - parseOptional(23); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + parseOptional(24); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(206); + parseExpected(105); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86); - parseExpected(17); + parseExpected(87); + parseExpected(18); var initializer = undefined; - if (token() !== 23) { - if (token() === 102 || token() === 108 || token() === 74) { + if (token() !== 24) { + if (token() === 103 || token() === 109 || token() === 75) { initializer = parseVariableDeclarationList(true); } else { @@ -15382,32 +14869,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(207, pos); + if (parseOptional(91)) { + var forInStatement = createNode(208, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138)) { - var forOfStatement = createNode(208, pos); + else if (parseOptional(139)) { + var forOfStatement = createNode(209, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206, pos); + var forStatement = createNode(207, pos); forStatement.initializer = initializer; - parseExpected(23); - if (token() !== 23 && token() !== 18) { + parseExpected(24); + if (token() !== 24 && token() !== 19) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23); - if (token() !== 18) { + parseExpected(24); + if (token() !== 19) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -15415,7 +14902,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 ? 70 : 75); + parseExpected(kind === 211 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15423,8 +14910,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211); - parseExpected(94); + var node = createNode(212); + parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -15432,90 +14919,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249); - parseExpected(71); + parseExpected(72); node.expression = allowInAnd(parseExpression); - parseExpected(54); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250); - parseExpected(77); - parseExpected(54); + parseExpected(78); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 ? parseCaseClause() : parseDefaultClause(); + return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(214); + parseExpected(97); parseExpected(18); - var caseBlock = createNode(227, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + var caseBlock = createNode(228, scanner.getStartPos()); parseExpected(16); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(17); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(215); - parseExpected(98); + var node = createNode(216); + parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(216); - parseExpected(100); + var node = createNode(217); + parseExpected(101); node.tryBlock = parseBlock(false); - node.catchClause = token() === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 85) { - parseExpected(85); + node.catchClause = token() === 73 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 86) { + parseExpected(86); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252); - parseExpected(72); - if (parseExpected(17)) { + parseExpected(73); + if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18); + parseExpected(19); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217); - parseExpected(76); + var node = createNode(218); + parseExpected(77); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(214, fullStart); + if (expression.kind === 70 && parseOptional(55)) { + var labeledStatement = createNode(215, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202, fullStart); + var expressionStatement = createNode(203, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15527,7 +15014,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 && !scanner.hasPrecedingLineBreak(); + return token() === 88 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -15536,47 +15023,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102: - case 108: + case 103: + case 109: + case 75: + case 88: case 74: - case 87: - case 73: - case 81: + case 82: return true; - case 107: - case 134: + case 108: + case 135: return nextTokenIsIdentifierOnSameLine(); - case 125: case 126: + case 127: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: + case 116: + case 119: + case 123: case 111: case 112: - case 128: + case 113: + case 129: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137: + case 138: nextToken(); - return token() === 15 || token() === 69 || token() === 82; - case 89: + return token() === 16 || token() === 70 || token() === 83; + case 90: nextToken(); - return token() === 9 || token() === 37 || - token() === 15 || ts.tokenIsIdentifierOrKeyword(token()); - case 82: + return token() === 9 || token() === 38 || + token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); + case 83: nextToken(); - if (token() === 56 || token() === 37 || - token() === 15 || token() === 77 || - token() === 116) { + if (token() === 57 || token() === 38 || + token() === 16 || token() === 78 || + token() === 117) { return true; } continue; - case 113: + case 114: nextToken(); continue; default: @@ -15589,46 +15076,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: + case 56: + case 24: + case 16: + case 103: + case 109: case 88: - case 79: - case 104: - case 86: - case 75: - case 70: - case 94: - case 105: - case 96: - case 98: - case 100: - case 76: - case 72: - case 85: - return true; case 74: case 82: case 89: + case 80: + case 105: + case 87: + case 76: + case 71: + case 95: + case 106: + case 97: + case 99: + case 101: + case 77: + case 73: + case 86: + return true; + case 75: + case 83: + case 90: return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: + case 119: + case 123: + case 108: case 126: - case 134: - case 137: + case 127: + case 135: + case 138: return true; - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -15636,73 +15123,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 || token() === 19; + return isIdentifier() || token() === 16 || token() === 20; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 23: + case 24: return parseEmptyStatement(); - case 15: + case 16: return parseBlock(false); - case 102: + case 103: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: + case 109: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 87: + case 88: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 73: + case 74: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 88: + case 89: return parseIfStatement(); - case 79: + case 80: return parseDoStatement(); - case 104: + case 105: return parseWhileStatement(); - case 86: + case 87: return parseForOrForInOrForOfStatement(); - case 75: - return parseBreakOrContinueStatement(209); - case 70: + case 76: return parseBreakOrContinueStatement(210); - case 94: + case 71: + return parseBreakOrContinueStatement(211); + case 95: return parseReturnStatement(); - case 105: + case 106: return parseWithStatement(); - case 96: + case 97: return parseSwitchStatement(); - case 98: + case 99: return parseThrowStatement(); - case 100: - case 72: - case 85: + case 101: + case 73: + case 86: return parseTryStatement(); - case 76: + case 77: return parseDebuggerStatement(); - case 55: + case 56: return parseDeclaration(); - case 118: - case 107: - case 134: - case 125: + case 119: + case 108: + case 135: case 126: - case 122: - case 74: - case 81: + case 127: + case 123: + case 75: case 82: - case 89: - case 110: + case 83: + case 90: case 111: case 112: - case 115: case 113: - case 128: - case 137: + case 116: + case 114: + case 129: + case 138: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15715,40 +15202,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: return parseVariableStatement(fullStart, decorators, modifiers); - case 87: + case 88: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: + case 74: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: + case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: + case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137: - case 125: + case 138: case 126: + case 127: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: + case 90: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82: + case 83: nextToken(); switch (token()) { - case 77: - case 56: + case 78: + case 57: return parseExportAssignment(fullStart, decorators, modifiers); - case 116: + case 117: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(239, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15761,31 +15248,31 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 && canParseSemicolon()) { + if (token() !== 16 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 24) { - return createNode(193); + if (token() === 25) { + return createNode(194); } - var node = createNode(169); - node.dotDotDotToken = parseOptionalToken(22); + var node = createNode(170); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169); + var node = createNode(170); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54) { + if (tokenIsIdentifier && token() !== 55) { node.name = propertyName; } else { - parseExpected(54); + parseExpected(55); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -15793,33 +15280,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(168); parseExpected(16); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(169); parseExpected(20); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(21); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 || token() === 19 || isIdentifier(); + return token() === 16 || token() === 20 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19) { + if (token() === 20) { return parseArrayBindingPattern(); } - if (token() === 15) { + if (token() === 16) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218); + var node = createNode(219); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15828,21 +15315,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219); + var node = createNode(220); switch (token()) { - case 102: + case 103: break; - case 108: + case 109: node.flags |= 1; break; - case 74: + case 75: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 138 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15854,10 +15341,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; + return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -15865,29 +15352,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148, pos); + var node = createNode(149, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121); - fillSignature(54, false, false, false, node); + parseExpected(122); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -15895,12 +15382,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(54, isGenerator, isAsync, false, method); + fillSignature(55, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -15913,10 +15400,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -15931,17 +15418,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return true; default: return false; @@ -15949,7 +15436,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55) { + if (token() === 56) { return true; } while (ts.isModifierKind(token())) { @@ -15959,26 +15446,26 @@ var ts; } nextToken(); } - if (token() === 37) { + if (token() === 38) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 131 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { return true; } switch (token()) { - case 17: - case 25: + case 18: + case 26: + case 55: + case 57: case 54: - case 56: - case 53: return true; default: return canParseSemicolon(); @@ -15990,10 +15477,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55)) { + if (!parseOptional(56)) { break; } - var decorator = createNode(143, decoratorStart); + var decorator = createNode(144, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16013,7 +15500,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 && permitInvalidConstAsModifier) { + if (token() === 75 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -16038,7 +15525,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118) { + if (token() === 119) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -16049,8 +15536,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23) { - var result = createNode(198); + if (token() === 24) { + var result = createNode(199); nextToken(); return finishNode(result); } @@ -16061,7 +15548,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121) { + if (token() === 122) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -16070,33 +15557,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 37 || - token() === 19) { + token() === 38 || + token() === 20) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name_10 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 192); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73); + parseExpected(74); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16)) { node.members = parseClassMembers(); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16109,16 +15596,16 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { if (isHeritageClause()) { return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClause() { - if (token() === 83 || token() === 106) { + if (token() === 84 || token() === 107) { var node = createNode(251); node.token = token(); nextToken(); @@ -16128,38 +15615,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194); + var node = createNode(195); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function isHeritageClause() { - return token() === 83 || token() === 106; + return token() === 84 || token() === 107; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222, fullStart); + var node = createNode(223, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107); + parseExpected(108); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134); + parseExpected(135); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56); + parseExpected(57); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -16171,14 +15658,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81); + parseExpected(82); node.name = parseIdentifier(); - if (parseExpected(15)) { + if (parseExpected(16)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16186,10 +15673,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226, scanner.getStartPos()); - if (parseExpected(15)) { + var node = createNode(227, scanner.getStartPos()); + if (parseExpected(16)) { node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -16197,29 +15684,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21) + node.body = parseOptional(22) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137) { + if (token() === 138) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 15) { + if (token() === 16) { node.body = parseModuleBlock(); } else { @@ -16229,14 +15716,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137) { + if (token() === 138) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126)) { + else if (parseOptional(127)) { flags |= 16; } else { - parseExpected(125); + parseExpected(126); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -16244,63 +15731,63 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 && + return token() === 130 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17; + return nextToken() === 18; } function nextTokenIsSlash() { - return nextToken() === 39; + return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228, fullStart); + var exportDeclaration = createNode(229, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116); - parseExpected(126); + parseExpected(117); + parseExpected(127); exportDeclaration.name = parseIdentifier(); - parseExpected(23); + parseExpected(24); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); + parseExpected(90); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 && token() !== 136) { - var importEqualsDeclaration = createNode(229, fullStart); + if (token() !== 25 && token() !== 137) { + var importEqualsDeclaration = createNode(230, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56); + parseExpected(57); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(230, fullStart); + var importDeclaration = createNode(231, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 37 || - token() === 15) { + token() === 38 || + token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136); + parseExpected(137); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(231, fullStart); + var importClause = createNode(232, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token() === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(233); + parseOptional(25)) { + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); } return finishNode(importClause); } @@ -16310,11 +15797,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(240); - parseExpected(129); - parseExpected(17); - node.expression = parseModuleSpecifier(); + var node = createNode(241); + parseExpected(130); parseExpected(18); + node.expression = parseModuleSpecifier(); + parseExpected(19); return finishNode(node); } function parseModuleSpecifier() { @@ -16328,22 +15815,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(232); - parseExpected(37); - parseExpected(116); + var namespaceImport = createNode(233); + parseExpected(38); + parseExpected(117); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 233 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238); + return parseImportOrExportSpecifier(239); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234); + return parseImportOrExportSpecifier(235); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16351,9 +15838,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116) { + if (token() === 117) { node.propertyName = identifierName; - parseExpected(116); + parseExpected(117); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -16362,23 +15849,23 @@ var ts; else { node.name = identifierName; } - if (kind === 234 && checkIdentifierIsKeyword) { + if (kind === 235 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(237, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37)) { - parseExpected(136); + if (parseOptional(38)) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237); - if (token() === 136 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(136); + node.exportClause = parseNamedImportsOrExports(238); + if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16386,14 +15873,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235, fullStart); + var node = createNode(236, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56)) { + if (parseOptional(57)) { node.isExportEquals = true; } else { - parseExpected(77); + parseExpected(78); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -16465,36 +15952,72 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 229 && node.moduleReference.kind === 240 - || node.kind === 230 - || node.kind === 235 + || node.kind === 230 && node.moduleReference.kind === 241 + || node.kind === 231 || node.kind === 236 + || node.kind === 237 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37: - case 53: - case 17: - case 19: - case 49: - case 15: - case 87: - case 22: - case 92: - case 97: + case 38: + case 54: + case 18: + case 20: + case 50: + case 16: + case 88: + case 23: + case 93: + case 98: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); - sourceFile = createSourceFile("file.js", 2, 1); + initializeState(content, 4, undefined, 1); + sourceFile = createSourceFile("file.js", 4, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -16505,21 +16028,21 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { var result = createNode(257, scanner.getTokenPos()); - parseExpected(15); - result.type = parseJSDocTopLevelType(); parseExpected(16); + result.type = parseJSDocTopLevelType(); + parseExpected(17); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47) { + if (token() === 48) { var unionType = createNode(261, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56) { + if (token() === 57) { var optionalType = createNode(268, type.pos); nextToken(); optionalType.type = type; @@ -16530,20 +16053,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19) { + if (token() === 20) { var arrayType = createNode(260, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20); + parseExpected(21); type = finishNode(arrayType); } - else if (token() === 53) { + else if (token() === 54) { var nullableType = createNode(263, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49) { + else if (token() === 50) { var nonNullableType = createNode(264, type.pos); nonNullableType.type = type; nextToken(); @@ -16557,40 +16080,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37: + case 38: return parseJSDocAllType(); - case 53: + case 54: return parseJSDocUnknownOrNullableType(); - case 17: + case 18: return parseJSDocUnionType(); - case 19: + case 20: return parseJSDocTupleType(); - case 49: + case 50: return parseJSDocNonNullableType(); - case 15: + case 16: return parseJSDocRecordType(); - case 87: + case 88: return parseJSDocFunctionType(); - case 22: + case 23: return parseJSDocVariadicType(); - case 92: + case 93: return parseJSDocConstructorType(); - case 97: + case 98: return parseJSDocThisType(); - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 93: - case 135: - case 127: + case 131: + case 121: + case 134: + case 104: + case 94: + case 136: + case 128: return parseTokenNode(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -16598,14 +16121,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } @@ -16618,33 +16141,33 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269); nextToken(); - parseExpected(17); + parseExpected(18); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18); - if (token() === 54) { + parseExpected(19); + if (token() === 55) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142); + var parameter = createNode(143); parameter.type = parseJSDocType(); - if (parseOptional(56)) { - parameter.questionToken = createNode(56); + if (parseOptional(57)) { + parameter.questionToken = createNode(57); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267); result.name = parseSimplePropertyName(); - if (token() === 25) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21)) { - if (token() === 25) { + while (parseOptional(22)) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); break; } @@ -16660,7 +16183,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27); + parseExpected(28); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -16671,7 +16194,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139, left.pos); + var result = createNode(140, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -16692,7 +16215,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20); + parseExpected(21); return finishNode(result); } function checkForTrailingComma(list) { @@ -16705,13 +16228,13 @@ var ts; var result = createNode(261); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); + parseExpected(19); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47)) { + while (parseOptional(48)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -16730,12 +16253,12 @@ var ts; function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 24 || - token() === 16 || - token() === 18 || - token() === 27 || - token() === 56 || - token() === 47) { + if (token() === 25 || + token() === 17 || + token() === 19 || + token() === 28 || + token() === 57 || + token() === 48) { var result = createNode(259, pos); return finishNode(result); } @@ -16746,7 +16269,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); + initializeState(content, 4, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -16768,6 +16291,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -16804,7 +16333,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 55: + case 56: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -16822,7 +16351,7 @@ var ts; state = 0; indent = 0; break; - case 37: + case 38: var asterisk = scanner.getTokenText(); if (state === 1) { state = 2; @@ -16833,7 +16362,7 @@ var ts; indent += asterisk.length; } break; - case 69: + case 70: pushComment(scanner.getTokenText()); state = 2; break; @@ -16890,8 +16419,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getTokenPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -16942,7 +16471,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 && token() !== 1) { + while (token() !== 56 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -16951,7 +16480,7 @@ var ts; } indent = 0; break; - case 55: + case 56: break; case 5: if (state === 2) { @@ -16965,7 +16494,7 @@ var ts; indent += whitespace.length; } break; - case 37: + case 38: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -16976,7 +16505,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55) { + if (token() === 56) { break; } nextJSDocToken(); @@ -17004,7 +16533,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15) { + if (token() !== 16) { return undefined; } return parseJSDocTypeExpression(); @@ -17015,14 +16544,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(19)) { + if (parseOptionalToken(20)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(56)) { + if (parseOptionalToken(57)) { parseExpression(); } - parseExpected(20); + parseExpected(21); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -17099,9 +16628,9 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + if (jsDocTypeReference.name.kind === 70) { + var name_11 = jsDocTypeReference.name; + if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17123,7 +16652,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55: + case 56: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -17137,13 +16666,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37: + case 38: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69: + case 70: canParseTag = false; case 1: break; @@ -17154,8 +16683,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getStartPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -17187,17 +16716,17 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name_12 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name_12) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(142, name_12.pos); + typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24) { + if (token() === 25) { nextJSDocToken(); skipWhitespace(); } @@ -17226,7 +16755,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69, pos); + var result = createNode(70, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -17297,8 +16826,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -17307,7 +16836,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 69: + case 70: return true; } return false; @@ -17370,8 +16899,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -17519,21 +17048,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - if (node.kind === 222 || node.kind === 223) { + if (node.kind === 223 || node.kind === 224) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 230 || node.kind === 229) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 226) { + else if (node.kind === 227) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17549,7 +17088,7 @@ var ts; }); return state_1; } - else if (node.kind === 225) { + else if (node.kind === 226) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -17558,6 +17097,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -17655,7 +17206,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { symbol.valueDeclaration = node; } } @@ -17665,7 +17216,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -17676,21 +17227,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148: + case 149: return "__constructor"; - case 156: - case 151: - return "__call"; case 157: case 152: - return "__new"; + return "__call"; + case 158: case 153: + return "__new"; + case 154: return "__index"; - case 236: + case 237: return "__export"; - case 235: + case 236: return node.isExportEquals ? "export=" : "default"; - case 187: + case 188: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17702,12 +17253,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220: case 221: + case 222: return ts.hasModifier(node, 512) ? "default" : undefined; case 269: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142: + case 143: ts.Debug.assert(node.parent.kind === 269); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); @@ -17715,10 +17266,10 @@ var ts; case 279: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { nameFromParentNode = nameIdentifier.text; } } @@ -17759,7 +17310,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17779,7 +17330,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 238 || (node.kind === 229 && hasExportModifier)) { + if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17896,64 +17447,64 @@ var ts; return; } switch (node.kind) { - case 205: + case 206: bindWhileStatement(node); break; - case 204: + case 205: bindDoStatement(node); break; - case 206: + case 207: bindForStatement(node); break; - case 207: case 208: + case 209: bindForInOrForOfStatement(node); break; - case 203: + case 204: bindIfStatement(node); break; - case 211: - case 215: + case 212: + case 216: bindReturnOrThrow(node); break; + case 211: case 210: - case 209: bindBreakOrContinueStatement(node); break; - case 216: + case 217: bindTryStatement(node); break; - case 213: + case 214: bindSwitchStatement(node); break; - case 227: + case 228: bindCaseBlock(node); break; case 249: bindCaseClause(node); break; - case 214: + case 215: bindLabeledStatement(node); break; - case 185: + case 186: bindPrefixUnaryExpressionFlow(node); break; - case 186: + case 187: bindPostfixUnaryExpressionFlow(node); break; - case 187: + case 188: bindBinaryExpressionFlow(node); break; - case 181: + case 182: bindDeleteExpressionFlow(node); break; - case 188: + case 189: bindConditionalExpressionFlow(node); break; - case 218: + case 219: bindVariableDeclarationFlow(node); break; - case 174: + case 175: bindCallExpressionFlow(node); break; default: @@ -17963,25 +17514,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return isNarrowableReference(expr); - case 174: + case 175: return hasNarrowableArgument(expr); - case 178: + case 179: return isNarrowingExpression(expr.expression); - case 187: + case 188: return isNarrowingBinaryExpression(expr); - case 185: - return expr.operator === 49 && isNarrowingExpression(expr.operand); + case 186: + return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 || - expr.kind === 97 || - expr.kind === 172 && isNarrowableReference(expr.expression); + return expr.kind === 70 || + expr.kind === 98 || + expr.kind === 173 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17992,41 +17543,41 @@ var ts; } } } - if (expr.expression.kind === 172 && + if (expr.expression.kind === 173 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableReference(expr.left); - case 30: case 31: case 32: case 33: + case 34: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91: + case 92: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178: + case 179: return isNarrowableOperand(expr.expression); - case 187: + case 188: switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowableOperand(expr.right); } } @@ -18045,7 +17596,7 @@ var ts; }; } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 256 ? 512 : 256; + flow.flags |= flow.flags & 512 ? 1024 : 512; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -18060,8 +17611,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 99 && flags & 64 || - expression.kind === 84 && flags & 32) { + if (expression.kind === 100 && flags & 64 || + expression.kind === 85 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -18095,6 +17646,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -18108,34 +17667,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203: - case 205: case 204: - return parent.expression === node; case 206: - case 188: + case 205: + return parent.expression === node; + case 207: + case 189: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178) { + if (node.kind === 179) { node = node.expression; } - else if (node.kind === 185 && node.operator === 49) { + else if (node.kind === 186 && node.operator === 50) { node = node.operand; } else { - return node.kind === 187 && (node.operatorToken.kind === 51 || - node.operatorToken.kind === 52); + return node.kind === 188 && (node.operatorToken.kind === 52 || + node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 || - node.parent.kind === 185 && - node.parent.operator === 49) { + while (node.parent.kind === 179 || + node.parent.kind === 186 && + node.parent.operator === 50) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -18208,7 +17767,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219) { + if (node.initializer.kind !== 220) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -18230,7 +17789,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211) { + if (node.kind === 212) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -18250,7 +17809,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -18270,21 +17829,32 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + if (!(currentFlow.flags & 1)) { + if ((flowAfterTry.flags & 1) && (flowAfterCatch.flags & 1)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - if (!node.finallyBlock || !(currentFlow.flags & 1)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -18361,7 +17931,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 && node.operatorToken.kind === 56) { + if (node.kind === 188 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -18372,10 +17942,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170) { + else if (node.kind === 171) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191) { + if (e.kind === 192) { bindAssignmentTargetFlow(e.expression); } else { @@ -18383,7 +17953,7 @@ var ts; } } } - else if (node.kind === 171) { + else if (node.kind === 172) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253) { @@ -18397,7 +17967,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -18408,7 +17978,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49) { + if (node.operator === 50) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -18418,20 +17988,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 || operator === 52) { + if (operator === 52 || operator === 53) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -18443,14 +18013,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 && !ts.isAssignmentTarget(node)) { + if (operator === 57 && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172) { + if (node.expression.kind === 173) { bindAssignmentTargetFlow(node.expression); } } @@ -18481,16 +18057,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 || node.parent.parent.kind === 208) { + if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 178) { + while (expr.kind === 179) { expr = expr.expression; } - if (expr.kind === 179 || expr.kind === 180) { + if (expr.kind === 180 || expr.kind === 181) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18498,54 +18074,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192: - case 221: - case 224: - case 171: - case 159: + case 193: + case 222: + case 225: + case 172: + case 160: case 281: case 265: return 1; - case 222: + case 223: return 1 | 64; case 269: - case 225: - case 223: + case 226: + case 224: return 1 | 32; case 256: return 1 | 4 | 32; - case 147: + case 148: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 148: - case 220: - case 146: case 149: + case 221: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return 1 | 4 | 32 | 8; - case 179: case 180: + case 181: return 1 | 4 | 32 | 8 | 16; - case 226: + case 227: return 4; - case 145: + case 146: return node.initializer ? 4 : 0; case 252: - case 206: case 207: case 208: - case 227: + case 209: + case 228: return 2; - case 199: + case 200: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18561,36 +18143,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 225: + case 226: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192: - case 221: + case 193: + case 222: return declareClassMember(node, symbolFlags, symbolExcludes); - case 224: + case 225: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159: - case 171: - case 222: + case 160: + case 172: + case 223: case 265: case 281: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156: case 157: - case 151: + case 158: case 152: case 153: - case 147: - case 146: + case 154: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 269: - case 223: + case 224: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18606,10 +18188,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 226)) { + if (body && (body.kind === 256 || body.kind === 227)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 || stat.kind === 235) { + if (stat.kind === 237 || stat.kind === 236) { return true; } } @@ -18681,15 +18263,20 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69) { + if (prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 147 + var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18711,7 +18298,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225: + case 226: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256: @@ -18732,8 +18319,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && + node.originalKeywordKind >= 107 && + node.originalKeywordKind <= 115 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -18761,17 +18348,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { + if (inStrictMode && node.expression.kind === 70) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && + return node.kind === 70 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { + if (name && name.kind === 70) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -18805,7 +18392,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 225 && + blockScopeContainer.kind !== 226 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18824,7 +18411,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -18848,7 +18435,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 138) { + if (node.kind > 139) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -18885,18 +18472,18 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172: + case 173: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187: + case 188: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -18921,30 +18508,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252: return checkStrictModeCatchClause(node); - case 181: + case 182: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 186: + case 187: return checkStrictModePostfixUnaryExpression(node); - case 185: + case 186: return checkStrictModePrefixUnaryExpression(node); - case 212: + case 213: return checkStrictModeWithStatement(node); - case 165: + case 166: seenThisKeyword = true; return; - case 154: + case 155: return checkTypePredicate(node); - case 141: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 142: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 143: return bindParameter(node); - case 218: - case 169: + case 219: + case 170: return bindVariableDeclarationOrBindingElement(node); + case 146: case 145: - case 144: case 266: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); case 280: @@ -18957,82 +18544,82 @@ var ts; case 247: emitFlags |= 16384; return; - case 151: case 152: case 153: + case 154: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 148: case 147: - case 146: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 220: + case 221: return bindFunctionDeclaration(node); - case 148: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 149: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 150: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 151: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 156: case 157: + case 158: case 269: return bindFunctionOrConstructorType(node); - case 159: + case 160: case 281: case 265: return bindAnonymousDeclaration(node, 2048, "__type"); - case 171: + case 172: return bindObjectLiteralExpression(node); - case 179: case 180: + case 181: return bindFunctionExpression(node); - case 174: + case 175: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 192: - case 221: + case 193: + case 222: inStrictMode = true; return bindClassLikeDeclaration(node); - case 222: + case 223: return bindBlockScopedDeclaration(node, 64, 792968); case 279: - case 223: - return bindBlockScopedDeclaration(node, 524288, 793064); case 224: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 225: + return bindEnumDeclaration(node); + case 226: return bindModuleDeclaration(node); - case 229: - case 232: - case 234: - case 238: + case 230: + case 233: + case 235: + case 239: return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 228: + case 229: return bindNamespaceExportDeclaration(node); - case 231: + case 232: return bindImportClause(node); - case 236: + case 237: return bindExportDeclaration(node); - case 235: + case 236: return bindExportAssignment(node); case 256: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199: + case 200: if (!ts.isFunctionLike(node.parent)) { return; } - case 226: + case 227: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69) { + if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165) { + if (parameterName && parameterName.kind === 166) { seenThisKeyword = true; } bind(type); @@ -19051,7 +18638,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -19095,7 +18682,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -19108,11 +18697,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 220 || container.kind === 179) { + if (container.kind === 221 || container.kind === 180) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 148) { + else if (container.kind === 149) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -19152,7 +18741,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 221) { + if (node.kind === 222) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -19270,15 +18859,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 201) || - node.kind === 221 || - (node.kind === 225 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 224 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || + node.kind === 222 || + (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 || + (node.kind !== 201 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -19292,52 +18881,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174: + case 175: return computeCallExpression(node, subtreeFlags); - case 225: + case 176: + return computeNewExpression(node, subtreeFlags); + case 226: return computeModuleDeclaration(node, subtreeFlags); - case 178: + case 179: return computeParenthesizedExpression(node, subtreeFlags); - case 187: + case 188: return computeBinaryExpression(node, subtreeFlags); - case 202: + case 203: return computeExpressionStatement(node, subtreeFlags); - case 142: + case 143: return computeParameter(node, subtreeFlags); - case 180: + case 181: return computeArrowFunction(node, subtreeFlags); - case 179: + case 180: return computeFunctionExpression(node, subtreeFlags); - case 220: + case 221: return computeFunctionDeclaration(node, subtreeFlags); - case 218: - return computeVariableDeclaration(node, subtreeFlags); case 219: + return computeVariableDeclaration(node, subtreeFlags); + case 220: return computeVariableDeclarationList(node, subtreeFlags); - case 200: + case 201: return computeVariableStatement(node, subtreeFlags); - case 214: + case 215: return computeLabeledStatement(node, subtreeFlags); - case 221: + case 222: return computeClassDeclaration(node, subtreeFlags); - case 192: + case 193: return computeClassExpression(node, subtreeFlags); case 251: return computeHeritageClause(node, subtreeFlags); - case 194: + case 195: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148: + case 149: return computeConstructor(node, subtreeFlags); - case 145: + case 146: return computePropertyDeclaration(node, subtreeFlags); - case 147: + case 148: return computeMethod(node, subtreeFlags); - case 149: case 150: + case 151: return computeAccessor(node, subtreeFlags); - case 229: + case 230: return computeImportEquals(node, subtreeFlags); - case 172: + case 173: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -19348,40 +18939,54 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537133909; + return transformFlags & ~537922901; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95: + case 96: return true; - case 172: case 173: + case 174: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95; + return expressionKind === 96; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576) { + transformFlags |= 768; + } + node.transformFlags = transformFlags | 536870912; + return transformFlags & ~537922901; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 - && (leftKind === 171 - || leftKind === 170)) { - transformFlags |= 192 | 256; + if (operatorTokenKind === 57 + && (leftKind === 172 + || leftKind === 171)) { + transformFlags |= 768 | 1024; } - else if (operatorTokenKind === 38 - || operatorTokenKind === 60) { - transformFlags |= 48; + else if (operatorTokenKind === 39 + || operatorTokenKind === 61) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19389,35 +18994,35 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - if (node.questionToken) { - transformFlags |= 3; - } - if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { + if (node.questionToken + || node.type + || subtreeFlags & 8192 + || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 131072; + transformFlags |= 3 | 524288; } - if (subtreeFlags & 2097152 || initializer || dotDotDotToken) { - transformFlags |= 192 | 65536; + if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { + transformFlags |= 768 | 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 195 - || expressionKind === 177) { + if (expressionKind === 196 + || expressionKind === 178) { transformFlags |= 3; } - if (expressionTransformFlags & 256) { - transformFlags |= 256; + if (expressionTransformFlags & 1024) { + transformFlags |= 1024; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -19426,36 +19031,38 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 192; - if ((subtreeFlags & 137216) - || (modifierFlags & 1)) { + transformFlags = subtreeFlags | 768; + if ((subtreeFlags & 548864) + || (modifierFlags & 1) + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - if (subtreeFlags & 137216) { + var transformFlags = subtreeFlags | 768; + if (subtreeFlags & 548864 + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83: - transformFlags |= 192; + case 84: + transformFlags |= 768; break; - case 106: + case 107: transformFlags |= 3; break; default: @@ -19463,135 +19070,148 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; + var transformFlags = subtreeFlags | 768; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { + if (ts.hasModifier(node, 2270) + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - if (!body - || typeParameters - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + var transformFlags = subtreeFlags | 768; + if (node.decorators + || ts.hasModifier(node, 2270) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - if (!body - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + if (node.decorators + || ts.hasModifier(node, 2270) + || node.type + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 4096; + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2)) { transformFlags = 3; } else { - transformFlags = subtreeFlags | 8388608; + transformFlags = subtreeFlags | 33554432; if (modifierFlags & 1) { - transformFlags |= 3 | 192; + transformFlags |= 3 | 768; } - if (modifierFlags & 256) { + if (modifierFlags & 2270 + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (modifierFlags & 256) { + transformFlags |= 48; + } + if (subtreeFlags & 327680) { + transformFlags |= 768; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - if (modifierFlags & 256) { + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 327680) { + transformFlags |= 768; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 256) { + var transformFlags = subtreeFlags | 768; + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 8192) { - transformFlags |= 16384; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 32768) { + transformFlags |= 65536; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550710101; + return transformFlags & ~592227669; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 95) { - transformFlags |= 8192; + if (expressionKind === 96) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 167 || nameKind === 168) { - transformFlags |= 192 | 2097152; + if (nameKind === 168 || nameKind === 169) { + transformFlags |= 768 | 8388608; + } + if (node.type) { + transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19603,23 +19223,23 @@ var ts; else { transformFlags = subtreeFlags; if (modifierFlags & 1) { - transformFlags |= 192 | 3; + transformFlags |= 768 | 3; } - if (declarationListTransformFlags & 2097152) { - transformFlags |= 192; + if (declarationListTransformFlags & 8388608) { + transformFlags |= 768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 1048576 + if (subtreeFlags & 4194304 && ts.isIterationStatement(node, true)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19627,15 +19247,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 256) { - transformFlags |= 192; + if (node.expression.transformFlags & 1024) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -19644,77 +19264,78 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~546335573; + return transformFlags & ~574729557; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608; - if (subtreeFlags & 2097152) { - transformFlags |= 192; + var transformFlags = subtreeFlags | 33554432; + if (subtreeFlags & 8388608) { + transformFlags |= 768; } if (node.flags & 3) { - transformFlags |= 192 | 1048576; + transformFlags |= 768 | 4194304; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536871765; + var excludeFlags = 536874325; switch (kind) { - case 112: - case 110: + case 119: + case 185: + transformFlags |= 48; + break; + case 113: case 111: - case 115: - case 122: - case 118: - case 74: - case 184: - case 224: + case 112: + case 116: + case 123: + case 75: + case 225: case 255: - case 177: - case 195: + case 178: case 196: - case 128: + case 197: + case 129: transformFlags |= 3; break; - case 241: case 242: case 243: case 244: + case 10: case 245: case 246: case 247: case 248: transformFlags |= 12; break; - case 82: - transformFlags |= 192 | 3; + case 83: + transformFlags |= 768 | 3; break; - case 77: - case 11: + case 78: case 12: case 13: case 14: - case 189: - case 176: + case 15: + case 190: + case 177: case 254: - case 208: - transformFlags |= 192; + case 209: + transformFlags |= 768; break; - case 190: - transformFlags |= 192 | 4194304; + case 191: + transformFlags |= 768 | 16777216; break; - case 117: - case 130: - case 127: - case 132: - case 120: + case 118: + case 131: + case 128: case 133: - case 103: - case 141: - case 144: - case 146: - case 151: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: case 154: @@ -19728,68 +19349,69 @@ var ts; case 162: case 163: case 164: - case 222: - case 223: case 165: + case 223: + case 224: case 166: + case 167: transformFlags = 3; excludeFlags = -3; break; - case 140: - transformFlags |= 524288; - if (subtreeFlags & 8192) { - transformFlags |= 32768; + case 141: + transformFlags |= 2097152; + if (subtreeFlags & 32768) { + transformFlags |= 131072; } break; - case 191: - transformFlags |= 262144; + case 192: + transformFlags |= 1048576; break; - case 95: - transformFlags |= 192; + case 96: + transformFlags |= 768; break; - case 97: - transformFlags |= 8192; + case 98: + transformFlags |= 32768; break; - case 167: case 168: - transformFlags |= 192 | 2097152; + case 169: + transformFlags |= 768 | 8388608; break; - case 143: - transformFlags |= 3 | 2048; + case 144: + transformFlags |= 3 | 8192; break; - case 171: - excludeFlags = 537430869; - if (subtreeFlags & 524288) { - transformFlags |= 192; + case 172: + excludeFlags = 539110741; + if (subtreeFlags & 2097152) { + transformFlags |= 768; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } break; - case 170: - case 175: - excludeFlags = 537133909; - if (subtreeFlags & 262144) { - transformFlags |= 192; + case 171: + case 176: + excludeFlags = 537922901; + if (subtreeFlags & 1048576) { + transformFlags |= 768; } break; - case 204: case 205: case 206: case 207: - if (subtreeFlags & 1048576) { - transformFlags |= 192; + case 208: + if (subtreeFlags & 4194304) { + transformFlags |= 768; } break; case 256: - if (subtreeFlags & 16384) { - transformFlags |= 192; + if (subtreeFlags & 65536) { + transformFlags |= 768; } break; - case 211: - case 209: + case 212: case 210: - transformFlags |= 8388608; + case 211: + transformFlags |= 33554432; break; } node.transformFlags = transformFlags | 536870912; @@ -19889,6 +19511,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); @@ -19932,6 +19555,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; var getGlobalTemplateStringsArrayType; var getGlobalESSymbolType; @@ -19972,6 +19596,66 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -20014,6 +19698,13 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -20098,7 +19789,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 && source.valueDeclaration.kind !== 225))) { + (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -20233,24 +19924,24 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 218 || + return declaration.kind !== 219 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200: - case 206: - case 208: + case 201: + case 207: + case 209: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 207: case 208: + case 209: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20268,7 +19959,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 && + current.parent.kind === 146 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -20294,15 +19985,15 @@ var ts; if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 142 || - lastLocation.kind === 141 + lastLocation.kind === 143 || + lastLocation.kind === 142 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 142 || + lastLocation.kind === 143 || (lastLocation === location.type && - result.valueDeclaration.kind === 142); + result.valueDeclaration.kind === 143); } } if (useResult) { @@ -20318,7 +20009,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225: + case 226: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { @@ -20330,7 +20021,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 238)) { + ts.getDeclarationOfKind(moduleExports[name], 239)) { break; } } @@ -20338,13 +20029,13 @@ var ts; break loop; } break; - case 224: + case 225: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 146: case 145: - case 144: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20354,9 +20045,9 @@ var ts; } } break; - case 221: - case 192: case 222: + case 193: + case 223: 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); @@ -20364,7 +20055,7 @@ var ts; } break loop; } - if (location.kind === 192 && meaning & 32) { + if (location.kind === 193 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20372,28 +20063,28 @@ var ts; } } break; - case 140: + case 141: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223) { 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; } } break; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 180: + case 151: + case 221: + case 181: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179: + case 180: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20406,8 +20097,8 @@ var ts; } } break; - case 143: - if (location.parent && location.parent.kind === 142) { + case 144: + if (location.parent && location.parent.kind === 143) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20449,7 +20140,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228) { + if (decls && decls.length === 1 && decls[0].kind === 229) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20457,7 +20148,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -20495,10 +20186,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69: - case 172: + case 70: + case 173: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194: + case 195: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20519,7 +20210,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, 218), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20536,10 +20227,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } - while (node && node.kind !== 230) { + while (node && node.kind !== 231) { node = node.parent; } return node; @@ -20549,10 +20240,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240) { + if (node.moduleReference.kind === 241) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -20610,28 +20301,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name_13 = specifier.propertyName || specifier.name; + if (name_13.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_13.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_13.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); } return symbol; } @@ -20653,19 +20344,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229: + case 230: return getTargetOfImportEqualsDeclaration(node); - case 231: - return getTargetOfImportClause(node); case 232: + return getTargetOfImportClause(node); + case 233: return getTargetOfNamespaceImport(node); - case 234: + case 235: return getTargetOfImportSpecifier(node); - case 238: + case 239: return getTargetOfExportSpecifier(node); - case 235: + case 236: return getTargetOfExportAssignment(node); - case 228: + case 229: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20709,10 +20400,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235) { + if (node.kind === 236) { checkExpressionCached(node.expression); } - else if (node.kind === 238) { + else if (node.kind === 239) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20720,15 +20411,15 @@ var ts; } } } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { + if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 139) { + if (entityName.kind === 70 || entityName.parent.kind === 140) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 229); + ts.Debug.assert(entityName.parent.kind === 230); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20740,16 +20431,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69) { + if (name.kind === 70) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 || name.kind === 172) { - var left = name.kind === 139 ? name.left : name.expression; - var right = name.kind === 139 ? name.right : name.name; + else if (name.kind === 140 || name.kind === 173) { + var left = name.kind === 140 ? name.left : name.expression; + var right = name.kind === 140 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -20932,7 +20623,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 && ts.nodeIsPresent(member.body)) { return member; } } @@ -21006,7 +20697,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225: + case 226: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -21039,7 +20730,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21070,7 +20761,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21084,10 +20775,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145: - case 147: - case 149: + case 146: + case 148: case 150: + case 151: continue; default: return false; @@ -21109,7 +20800,7 @@ var ts; return { accessibility: 1, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined, }; } return hasAccessibleDeclarations; @@ -21130,7 +20821,7 @@ var ts; } return { accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 }; @@ -21177,11 +20868,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 158 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 139 || entityName.kind === 172 || - entityName.parent.kind === 229) { + else if (entityName.kind === 140 || entityName.kind === 173 || + entityName.parent.kind === 230) { meaning = 1920; } else { @@ -21273,10 +20964,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164) { + while (node.kind === 165) { node = node.parent; } - if (node.kind === 223) { + if (node.kind === 224) { return getSymbolOfNode(node); } } @@ -21284,7 +20975,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 && + node.parent.kind === 227 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21298,10 +20989,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192: + case 193: return "(Anonymous class)"; - case 179: case 180: + case 181: return "(Anonymous function)"; } } @@ -21315,17 +21006,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } else { - writePunctuation(writer, 21); + writePunctuation(writer, 22); writer.writeSymbol(symbolName, symbol); } } @@ -21401,7 +21092,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 | 65536 | 16 | 16384)) { @@ -21422,23 +21113,23 @@ var ts; writer.writeStringLiteral(literalTypeToString(type)); } else { - writePunctuation(writer, 15); + writePunctuation(writer, 16); writeSpace(writer); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writeSpace(writer); - writePunctuation(writer, 16); + writePunctuation(writer, 17); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24) { + if (delimiter !== 25) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 ? 0 : 64); + writeType(types[i], delimiter === 25 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -21446,29 +21137,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 19); writePunctuation(writer, 20); + writePunctuation(writer, 21); } else if (type.target.flags & 262144) { - writePunctuation(writer, 19); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24); writePunctuation(writer, 20); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); + writePunctuation(writer, 21); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -21483,7 +21174,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } } @@ -21493,16 +21184,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } if (type.flags & 524288) { - writeTypeList(formatUnionTypes(type.types), 47); + writeTypeList(formatUnionTypes(type.types), 48); } else { - writeTypeList(type.types, 46); + writeTypeList(type.types, 47); } if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } } function writeAnonymousType(type, flags) { @@ -21520,7 +21211,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 117); + writeKeyword(writer, 118); } } else { @@ -21541,7 +21232,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 226; + return declaration.parent.kind === 256 || declaration.parent.kind === 227; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21550,37 +21241,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); + writeKeyword(writer, 102); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20); - writePunctuation(writer, 54); + writePunctuation(writer, 21); + writePunctuation(writer, 55); writeSpace(writer); writeType(info.type, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -21598,53 +21289,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); writePunctuation(writer, 16); + writePunctuation(writer, 17); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15); + writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132); - writeIndexSignature(resolved.numberIndexInfo, 130); + writeIndexSignature(resolved.stringIndexInfo, 133); + writeIndexSignature(resolved.numberIndexInfo, 131); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -21654,21 +21345,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16); + writePunctuation(writer, 17); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -21683,7 +21374,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83); + writeKeyword(writer, 84); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -21691,7 +21382,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -21700,36 +21391,36 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 167) { - writePunctuation(writer, 15); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 168) { writePunctuation(writer, 16); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 17); } - else if (bindingPattern.kind === 168) { - writePunctuation(writer, 19); + else if (bindingPattern.kind === 169) { + writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169); + ts.Debug.assert(bindingElement.kind === 170); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -21737,75 +21428,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - var flags_1 = 256; + writePunctuation(writer, 26); + var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); - flags_1 = 0; + flags = 0; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18); + writePunctuation(writer, 19); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97); + writeKeyword(writer, 98); } writeSpace(writer); - writeKeyword(writer, 124); + writeKeyword(writer, 125); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 34); + writePunctuation(writer, 35); } else { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } writeSpace(writer); if (signature.typePredicate) { @@ -21818,7 +21509,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -21854,63 +21545,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169: + case 170: return isDeclarationVisible(node.parent.parent); - case 218: + case 219: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 225: - case 221: + case 226: case 222: case 223: - case 220: case 224: - case 229: + case 221: + case 225: + case 230: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } return isDeclarationVisible(parent_10); + case 146: case 145: - case 144: - case 149: case 150: + case 151: + case 148: case 147: - case 146: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 148: - case 152: - case 151: + case 149: case 153: - case 142: - case 226: - case 156: + case 152: + case 154: + case 143: + case 227: case 157: - case 159: - case 155: + case 158: case 160: + case 156: case 161: case 162: case 163: case 164: + case 165: return isDeclarationVisible(node.parent); - case 231: case 232: - case 234: + case 233: + case 235: return false; - case 141: + case 142: case 256: - case 228: + case 229: return true; - case 235: + case 236: return false; default: return false; @@ -21919,10 +21610,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235) { + if (node.parent && node.parent.kind === 236) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 239) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22001,12 +21692,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218: case 219: + case 220: + case 235: case 234: case 233: case 232: - case 231: node = node.parent; break; default: @@ -22034,12 +21725,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69: + case 70: return name.text; case 9: case 8: return name.text; - case 140: + case 141: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -22047,7 +21738,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -22062,20 +21753,20 @@ var ts; return parentType; } var type; - if (pattern.kind === 167) { - var name_17 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_17)) { + if (pattern.kind === 168) { + var name_14 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_14)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = getTextOfPropertyName(name_17); + var text = getTextOfPropertyName(name_14); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); + error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_14)); return unknownType; } } @@ -22118,15 +21809,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 && - declaration.parent.kind === 219 && - declaration.parent.parent.kind === 200) { + if (declaration.kind === 219 && + declaration.parent.kind === 220 && + declaration.parent.parent.kind === 201) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142) { + else if (declaration.kind === 143) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -22134,9 +21825,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; @@ -22148,10 +21843,10 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 207) { + if (declaration.parent.parent.kind === 208) { return stringType; } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 209) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -22160,15 +21855,19 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { + if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var func = declaration.parent; - if (func.kind === 150 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); + if (func.kind === 151 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22181,8 +21880,7 @@ var ts; } var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -22255,7 +21953,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 + return pattern.kind === 168 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22280,7 +21978,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 ? root.parent : root; + var memberDeclaration = root.kind === 143 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -22293,7 +21991,7 @@ var ts; if (declaration.parent.kind === 252) { return links.type = anyType; } - if (declaration.kind === 235) { + if (declaration.kind === 236) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { @@ -22303,15 +22001,15 @@ var ts; return unknownType; } var type = void 0; - if (declaration.kind === 187 || - declaration.kind === 172 && declaration.parent.kind === 187) { + if (declaration.kind === 188 || + declaration.kind === 173 && declaration.parent.kind === 188) { if (declaration.flags & 1048576) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22337,7 +22035,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149) { + if (accessor.kind === 150) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22357,8 +22055,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149); - var setter = ts.getDeclarationOfKind(symbol, 150); + var getter = ts.getDeclarationOfKind(symbol, 150); + var setter = ts.getDeclarationOfKind(symbol, 151); if (getter && getter.flags & 1048576) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -22399,7 +22097,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149); + var getter_1 = ts.getDeclarationOfKind(symbol, 150); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -22410,7 +22108,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -22495,9 +22193,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 || node.kind === 192 || - node.kind === 220 || node.kind === 179 || - node.kind === 147 || node.kind === 180) { + if (node.kind === 222 || node.kind === 193 || + node.kind === 221 || node.kind === 180 || + node.kind === 148 || node.kind === 181) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22506,15 +22204,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 222); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); 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 === 222 || node.kind === 221 || - node.kind === 192 || node.kind === 223) { + if (node.kind === 223 || node.kind === 222 || + node.kind === 193 || node.kind === 224) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22640,7 +22338,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 === 222 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -22669,7 +22367,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222) { + if (declaration.kind === 223) { if (declaration.flags & 64) { return false; } @@ -22731,7 +22429,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223); + declaration = ts.getDeclarationOfKind(symbol, 224); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -22755,14 +22453,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 69 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22790,7 +22488,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 === 224) { + if (declaration.kind === 225) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22828,7 +22526,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -22877,20 +22575,20 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 166: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: + case 167: return true; - case 160: + case 161: return isIndependentType(node.elementType); - case 155: + case 156: return isIndependentTypeReference(node); } return false; @@ -22899,7 +22597,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -22915,12 +22613,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { + case 146: case 145: - case 144: return isIndependentVariableLikeDeclaration(declaration); - case 147: - case 146: case 148: + case 147: + case 149: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23486,7 +23184,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69) { + if (node.parameterName.kind === 70) { var parameterName = node.parameterName; return { kind: 1, @@ -23525,7 +23223,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166) { + if (param.type && param.type.kind === 167) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23537,10 +23235,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 149 || declaration.kind === 150) && + if ((declaration.kind === 150 || declaration.kind === 151) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 ? 150 : 149; + var otherKind = declaration.kind === 150 ? 151 : 150; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -23552,24 +23250,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 ? + var classType = declaration.kind === 149 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -23585,8 +23280,8 @@ var ts; return type; } } - if (declaration.kind === 149 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150); + if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23600,19 +23295,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: + case 181: case 269: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; @@ -23693,7 +23388,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 || signature.declaration.kind === 152; + var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; var type = createObjectType(2097152); type.members = emptySymbols; type.properties = emptyArray; @@ -23707,7 +23402,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 130 : 132; + var syntaxKind = kind === 1 ? 131 : 133; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -23734,7 +23429,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141).constraint; + return ts.getDeclarationOfKind(type.symbol, 142).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -23767,7 +23462,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); } function getTypeListId(types) { var result = ""; @@ -23867,11 +23562,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155: + case 156: return node.typeName; case 267: return node.name; - case 194: + case 195: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23879,7 +23574,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -23907,11 +23602,11 @@ var ts; var type = void 0; if (node.kind === 267) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 155 + var typeNameOrExpression = node.kind === 156 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -23940,9 +23635,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221: case 222: - case 224: + case 223: + case 225: return declaration; } } @@ -24317,9 +24012,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 148 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24338,25 +24033,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117: + case 118: case 258: case 259: return anyType; - case 132: + case 133: return stringType; - case 130: + case 131: return numberType; - case 120: + case 121: return booleanType; - case 133: + case 134: return esSymbolType; - case 103: + case 104: return voidType; - case 135: + case 136: return undefinedType; - case 93: + case 94: return nullType; - case 127: + case 128: return neverType; case 283: return nullType; @@ -24364,33 +24059,33 @@ var ts; return undefinedType; case 285: return neverType; - case 165: - case 97: - return getTypeFromThisTypeNode(node); case 166: + case 98: + return getTypeFromThisTypeNode(node); + case 167: return getTypeFromLiteralTypeNode(node); case 282: return getTypeFromLiteralTypeNode(node.literal); - case 155: + case 156: case 267: return getTypeFromTypeReference(node); - case 154: + case 155: return booleanType; - case 194: + case 195: return getTypeFromTypeReference(node); - case 158: + case 159: return getTypeFromTypeQueryNode(node); - case 160: + case 161: case 260: return getTypeFromArrayTypeNode(node); - case 161: - return getTypeFromTupleTypeNode(node); case 162: + return getTypeFromTupleTypeNode(node); + case 163: case 261: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); case 164: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: case 263: case 264: case 271: @@ -24399,14 +24094,14 @@ var ts; return getTypeFromTypeNode(node.type); case 265: return getTypeFromTypeNode(node.literal); - case 156: case 157: - case 159: + case 158: + case 160: case 281: case 269: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); - case 69: - case 139: + case 70: + case 140: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262: @@ -24562,23 +24257,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: - case 221: - case 192: + case 181: case 222: + case 193: case 223: + case 224: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24588,14 +24283,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222) { + if (ts.isClassLike(node) || node.kind === 223) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225: + case 226: case 256: return false; } @@ -24630,35 +24325,43 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179: case 180: + case 181: return isContextSensitiveFunctionLikeDeclaration(node); - case 171: + case 172: return ts.forEach(node.properties, isContextSensitive); - case 170: + case 171: return ts.forEach(node.elements, isContextSensitive); - case 188: + case 189: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187: - return node.operatorToken.kind === 52 && + case 188: + return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253: return isContextSensitive(node.initializer); + case 148: case 147: - case 146: return isContextSensitiveFunctionLikeDeclaration(node); - case 178: + case 179: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + if (node.typeParameters) { + return false; + } + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + if (node.kind === 181) { + return false; + } + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -25078,8 +24781,8 @@ var ts; } if (source.flags & 524288 && target.flags & 524288 || source.flags & 1048576 && target.flags & 1048576) { - if (result = eachTypeRelatedToSomeType(source, target, false)) { - if (result &= eachTypeRelatedToSomeType(target, source, false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -25130,7 +24833,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -25727,7 +25430,7 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -25735,7 +25438,7 @@ var ts; type.flags & 64 && type.flags & 16777216 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { @@ -25846,10 +25549,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -25890,25 +25593,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 146: case 145: - case 144: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142: + case 143: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169: + case 170: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: - case 179: + case 151: case 180: + case 181: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -25953,7 +25656,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -25961,7 +25664,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } function couldContainTypeParameters(type) { @@ -26202,7 +25905,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; inferenceSucceeded = !!unionOrSuperType; @@ -26243,10 +25946,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 158: + case 159: return true; - case 69: - case 139: + case 70: + case 140: node = node.parent; continue; default: @@ -26256,14 +25959,14 @@ var ts; ts.Debug.fail("should not get here"); } function getFlowCacheKey(node) { - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97) { + if (node.kind === 98) { return "0"; } - if (node.kind === 172) { + if (node.kind === 173) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -26271,31 +25974,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: return node; - case 172: + case 173: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69: - return target.kind === 69 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 || target.kind === 169) && + case 70: + return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 || target.kind === 170) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97: - return target.kind === 97; - case 172: - return target.kind === 172 && + case 98: + return target.kind === 98; + case 173: + return target.kind === 173 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172) { + while (source.kind === 173) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26304,15 +26007,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 && + return target.kind === 173 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69) { + if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172) { + if (expr.kind === 173) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -26342,7 +26045,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 && + if (callExpression.expression.kind === 173 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26468,7 +26171,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 || node.parent.kind === 253 ? + return node.parent.kind === 171 || node.parent.kind === 253 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -26487,17 +26190,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207: - return stringType; case 208: + return stringType; + case 209: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187: + case 188: return getAssignedTypeOfBinaryExpression(parent); - case 181: + case 182: return undefinedType; - case 170: + case 171: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191: + case 192: return getAssignedTypeOfSpreadElement(parent); case 253: return getAssignedTypeOfPropertyAssignment(parent); @@ -26509,7 +26212,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 ? + var type = pattern.kind === 168 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -26524,38 +26227,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207) { + if (node.parent.parent.kind === 208) { return stringType; } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 209) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 ? + return node.kind === 219 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 || node.kind === 169 ? + return node.kind === 219 || node.kind === 170 ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 && node.parent.kind === 188 && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178: + case 179: return getReferenceCandidate(node.expression); - case 187: + case 188: switch (node.operatorToken.kind) { - case 56: + case 57: return getReferenceCandidate(node.left); - case 24: + case 25: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 || + parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -26626,24 +26342,88 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 ? + autoArrayType : + createArrayType(elementType.flags & 524288 ? + getUnionType(elementType.types, true) : + elementType); + } + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || + parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 && + parent.expression === root && + parent.parent.kind === 188 && + parent.parent.operatorToken.kind === 57 && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 && getTypeWithFacts(result, 524288).flags & 8192) { + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512) { + if (flow.flags & 1024) { for (var i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { return visitedFlowTypes[i]; @@ -26673,18 +26453,25 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172) { + if (container && container !== flowContainer && reference.kind !== 173) { flow = container.flowNode; continue; } type = initialType; } else { - type = declaredType; + type = convertAutoToAny(declaredType); } - if (flow.flags & 512) { + if (flow.flags & 1024) { visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; @@ -26695,30 +26482,70 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 || node.parent.kind === 186) { + if (node.parent.kind === 186 || node.parent.kind === 187) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; } return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | 2048)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192)) { - var assumeTrue = (flow.flags & 32) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + var assumeTrue = (flow.flags & 32) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -26753,7 +26580,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { var id = getFlowNodeId(flow); @@ -26765,8 +26592,8 @@ var ts; return cache[key]; } for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), true); } } var antecedentTypes = []; @@ -26797,14 +26624,14 @@ var ts; break; } } - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 && + return expr.kind === 173 && declaredType.flags & 524288 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -26829,19 +26656,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56: + case 57: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30: case 31: case 32: case 33: + case 34: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 && right_1.kind === 9) { + if (left_1.kind === 183 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 && left_1.kind === 9) { + if (right_1.kind === 183 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -26860,9 +26687,9 @@ var ts; return declaredType; } break; - case 91: + case 92: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24: + case 25: return narrowType(type, expr.right, assumeTrue); } return type; @@ -26871,7 +26698,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -26879,10 +26706,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 || operator === 31; + var doubleEquals = operator === 31 || operator === 32; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 93 ? + value.kind === 94 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -26908,7 +26735,7 @@ var ts; } return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288)) { @@ -27019,7 +26846,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 || invokedExpression.kind === 172) { + if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -27034,18 +26861,18 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174: + case 175: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178: + case 179: return narrowType(type, expr.expression, assumeTrue); - case 187: + case 188: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185: - if (expr.operator === 49) { + case 186: + if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -27054,7 +26881,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 69) { + if (location.kind === 70) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -27068,7 +26895,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178) { + while (expression.kind === 179) { expression = expression.expression; } return expression; @@ -27077,9 +26904,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 || + node.kind === 227 || node.kind === 256 || - node.kind === 145) { + node.kind === 146) { return node; } } @@ -27107,10 +26934,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69) { + if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { symbol.isAssigned = true; } } @@ -27119,12 +26946,15 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 180) { + if (container.kind === 181) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -27142,7 +26972,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 221 + && declaration_1.kind === 222 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27154,11 +26984,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192) { + else if (declaration_1.kind === 193) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 && ts.hasModifier(container, 32)) { + if (container.kind === 146 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -27176,28 +27006,26 @@ var ts; if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 142; + var isParameter = ts.getRootDeclaration(declaration).kind === 143; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || - flowContainer.kind === 180 || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || + flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { @@ -27237,8 +27065,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 206 && - ts.getAncestor(symbol.valueDeclaration, 219).parent === container && + if (container.kind === 207 && + ts.getAncestor(symbol.valueDeclaration, 220).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27250,16 +27078,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 178) { + while (current.parent.kind === 179) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 || current.parent.kind === 186)) { + else if ((current.parent.kind === 186 || current.parent.kind === 187)) { var expr = current.parent; - isAssigned = expr.operator === 41 || expr.operator === 42; + isAssigned = expr.operator === 42 || expr.operator === 43; } if (!isAssigned) { return false; @@ -27276,7 +27104,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 145 || container.kind === 148) { + if (container.kind === 146 || container.kind === 149) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -27310,7 +27138,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 148) { + if (container.kind === 149) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -27320,29 +27148,29 @@ var ts; } } } - if (container.kind === 180) { + if (container.kind === 181) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 225: + case 226: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 224: + case 225: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 148: + case 149: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 146: case 145: - case 144: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140: + case 141: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -27351,7 +27179,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 179 && + if (container.kind === 180 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27363,7 +27191,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -27395,18 +27223,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142) { + if (n.kind === 143) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 180) { + while (container && container.kind === 181) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27415,16 +27243,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 140) { + while (current && current !== container && current.kind !== 141) { current = current.parent; } - if (current && current.kind === 140) { + if (current && current.kind === 141) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27439,7 +27267,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 147 && ts.getModifierFlags(container) & 256) { + if (container.kind === 148 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -27450,7 +27278,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171) { + if (container.parent.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -27468,7 +27296,7 @@ var ts; } return unknownType; } - if (container.kind === 148 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -27480,35 +27308,38 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 148; + return container.kind === 149; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 171) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || - container.kind === 150; + return container.kind === 148 || + container.kind === 147 || + container.kind === 150 || + container.kind === 151; } else { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || + return container.kind === 148 || + container.kind === 147 || container.kind === 150 || + container.kind === 151 || + container.kind === 146 || container.kind === 145 || - container.kind === 144 || - container.kind === 148; + container.kind === 149; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -27558,7 +27389,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -27569,11 +27400,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_18 = declaration.propertyName || declaration.name; + var name_15 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_18)) { - var text = getTextOfPropertyName(name_18); + !ts.isBindingPattern(name_15)) { + var text = getTextOfPropertyName(name_15); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -27610,7 +27441,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 && node.parent.initializer === node) { + if (node.parent.kind === 143 && node.parent.initializer === node) { return true; } node = node.parent; @@ -27619,8 +27450,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 148 || - functionDecl.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150))) { + functionDecl.kind === 149 || + functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -27639,7 +27470,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176) { + if (template.parent.kind === 177) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -27647,7 +27478,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { + if (operator >= 57 && operator <= 69) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -27655,14 +27486,14 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52) { + else if (operator === 53) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); } return type; } - else if (operator === 51 || operator === 24) { + else if (operator === 52 || operator === 25) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -27676,8 +27507,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -27771,36 +27602,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: - case 169: + case 170: return getContextualTypeForInitializerExpression(node); - case 180: - case 211: + case 181: + case 212: return getContextualTypeForReturnExpression(node); - case 190: + case 191: return getContextualTypeForYieldOperand(parent); - case 174: case 175: + case 176: return getContextualTypeForArgument(parent, node); - case 177: - case 195: + case 178: + case 196: return getTypeFromTypeNode(parent.type); - case 187: + case 188: return getContextualTypeForBinaryOperand(node); case 253: case 254: return getContextualTypeForObjectLiteralElement(parent); - case 170: + case 171: return getContextualTypeForElementExpression(node); - case 188: + case 189: return getContextualTypeForConditionalOperand(node); - case 197: - ts.Debug.assert(parent.parent.kind === 189); + case 198: + ts.Debug.assert(parent.parent.kind === 190); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178: + case 179: return getContextualType(parent); case 248: return getContextualType(parent); @@ -27820,7 +27651,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 || node.kind === 180; + return node.kind === 180 || node.kind === 181; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -27833,7 +27664,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -27843,8 +27674,8 @@ var ts; } var signatureList; var types = type.types; - 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 signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -27874,8 +27705,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 169 && !!node.initializer) || - (node.kind === 187 && node.operatorToken.kind === 56); + return (node.kind === 170 && !!node.initializer) || + (node.kind === 188 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -27884,7 +27715,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191) { + if (inDestructuringPattern && e.kind === 192) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -27896,7 +27727,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191; + hasSpreadElement = hasSpreadElement || e.kind === 192; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -27907,7 +27738,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 168 || pattern.kind === 170)) { + if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -27915,7 +27746,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193) { + if (patternElement.kind !== 194) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -27932,7 +27763,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -27976,7 +27807,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 || contextualType.pattern.kind === 171); + (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -27991,7 +27822,7 @@ var ts; if (memberDecl.kind === 253) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147) { + else if (memberDecl.kind === 148) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -28030,7 +27861,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 149 || memberDecl.kind === 150); + ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -28089,10 +27920,10 @@ var ts; case 248: checkJsxExpression(child); break; - case 241: + case 242: checkJsxElement(child); break; - case 242: + case 243: checkJsxSelfClosingElement(child); break; } @@ -28103,7 +27934,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 172 || tagName.kind === 97) { + if (tagName.kind === 173 || tagName.kind === 98) { return false; } else { @@ -28206,7 +28037,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } function getJsxElementPropertiesName() { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -28235,7 +28066,7 @@ var ts; } if (elemType.flags & 524288) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), true); } @@ -28411,7 +28242,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145; + return s.valueDeclaration ? s.valueDeclaration.kind : 146; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -28422,11 +28253,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 || node.kind === 218 ? + var errorNode = node.kind === 173 || node.kind === 219 ? node.name : node.right; - if (left.kind === 95) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 147) { + if (left.kind === 96) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -28446,7 +28277,7 @@ var ts; } return true; } - if (left.kind === 95) { + if (left.kind === 96) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -28520,7 +28351,7 @@ var ts; checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 172 || ts.isAssignmentTarget(node) || + if (node.kind !== 173 || ts.isAssignmentTarget(node) || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 524288)) { return propType; @@ -28542,7 +28373,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 + var left = node.kind === 173 ? node.expression : node.left; var type = checkExpression(left); @@ -28556,13 +28387,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219) { + if (initializer.kind === 220) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69) { + else if (initializer.kind === 70) { return getResolvedSymbol(initializer); } return undefined; @@ -28572,13 +28403,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69) { + if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 && + if (node.kind === 208 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -28594,7 +28425,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 && node.parent.expression === node) { + if (node.parent.kind === 176 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -28617,15 +28448,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_19 !== undefined) { - var prop = getPropertyOfType(objectType, name_19); + var name_16 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_16 !== undefined) { + var prop = getPropertyOfType(objectType, name_16); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_16, symbolToString(objectType.symbol)); return unknownType; } } @@ -28658,7 +28489,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 || indexArgumentExpression.kind === 172) { + if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -28701,10 +28532,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176) { + if (node.kind === 177) { checkExpression(node.template); } - else if (node.kind !== 143) { + else if (node.kind !== 144) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -28755,7 +28586,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191) { + if (arg && arg.kind === 192) { return i; } } @@ -28768,11 +28599,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176) { + if (node.kind === 177) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189) { + if (tagExpression.template.kind === 190) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -28780,11 +28611,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); + ts.Debug.assert(templateLiteral.kind === 12); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143) { + else if (node.kind === 144) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -28792,7 +28623,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 175); + ts.Debug.assert(callExpression.kind === 176); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -28851,9 +28682,9 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); @@ -28898,7 +28729,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175) { + if (thisType && thisType !== voidType && node.kind !== 176) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -28911,9 +28742,9 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -28926,28 +28757,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 174) { + if (node.kind === 175) { var callee = node.expression; - if (callee.kind === 172) { + if (callee.kind === 173) { return callee.expression; } - else if (callee.kind === 173) { + else if (callee.kind === 174) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 176) { + if (node.kind === 177) { var template = node.template; args = [undefined]; - if (template.kind === 189) { + if (template.kind === 190) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143) { + else if (node.kind === 144) { return undefined; } else { @@ -28956,21 +28787,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143) { + if (node.kind === 144) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return 1; - case 145: + case 146: return 2; - case 147: - case 149: + case 148: case 150: + case 151: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 142: + case 143: return 3; } } @@ -28979,48 +28810,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { return anyType; } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var element = node; switch (element.name.kind) { - case 69: + case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 140: + case 141: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -29037,20 +28868,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { return numberType; } - if (node.kind === 145) { + if (node.kind === 146) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -29070,27 +28901,27 @@ var ts; ts.Debug.fail("Decorators should not have a fourth synthetic argument."); return unknownType; } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 143) { + function getEffectiveArgumentType(node, argIndex) { + if (node.kind === 144) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 143 || - (argIndex === 0 && node.kind === 176)) { + if (node.kind === 144 || + (argIndex === 0 && node.kind === 177)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143) { + if (node.kind === 144) { return node.expression; } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return node.template; } else { @@ -29098,12 +28929,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176; - var isDecorator = node.kind === 143; + var isTaggedTemplate = node.kind === 177; + var isDecorator = node.kind === 144; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { + if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); } } @@ -29129,7 +28960,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -29244,7 +29075,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -29397,16 +29228,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147: - case 149: + case 148: case 150: + case 151: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -29433,13 +29264,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174: - return resolveCallExpression(node, candidatesOutArray); case 175: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 176: + return resolveNewExpression(node, candidatesOutArray); + case 177: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143: + case 144: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29468,17 +29299,17 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { return voidType; } - if (node.kind === 175) { + if (node.kind === 176) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 && - declaration.kind !== 152 && - declaration.kind !== 157 && + declaration.kind !== 149 && + declaration.kind !== 153 && + declaration.kind !== 158 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 69 ? + var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -29490,7 +29321,9 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, true) && + !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -29530,21 +29363,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } function assignBindingElementTypes(node) { @@ -29552,7 +29400,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69) { + if (element.name.kind === 70) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -29565,8 +29413,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 || - parameter.valueDeclaration.name.kind === 168)) { + (parameter.valueDeclaration.name.kind === 168 || + parameter.valueDeclaration.name.kind === 169)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -29605,7 +29453,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199) { + if (func.body.kind !== 200) { 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); @@ -29684,7 +29532,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -29713,7 +29561,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 || func.kind === 180)) { + func.kind === 180 || func.kind === 181)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -29730,7 +29578,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -29757,9 +29605,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179) { + if (!hasGrammarError && node.kind === 180) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -29793,14 +29641,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147) { + if (produceDiagnostics && node.kind !== 148) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -29810,7 +29658,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199) { + if (node.body.kind === 200) { checkSourceElement(node.body); } else { @@ -29845,10 +29693,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 172 || expr.kind === 173) && - expr.expression.kind === 97) { + (expr.kind === 173 || expr.kind === 174) && + expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148)) + if (!(func && func.kind === 149)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -29857,13 +29705,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 || expr.kind === 173) { + if (expr.kind === 173 || expr.kind === 174) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232; + return declaration && declaration.kind === 233; } } } @@ -29871,7 +29719,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 && node.kind !== 172 && node.kind !== 173) { + if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { error(expr, invalidReferenceMessage); return false; } @@ -29879,7 +29727,7 @@ var ts; var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); if (symbol) { if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 69 && !(symbol.flags & 3)) { + if (node.kind === 70 && !(symbol.flags & 3)) { error(expr, invalidReferenceMessage); return false; } @@ -29889,7 +29737,7 @@ var ts; } } } - else if (node.kind === 173) { + else if (node.kind === 174) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -29926,24 +29774,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 && node.operand.kind === 8) { + if (node.operator === 37 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 35: case 36: - case 50: + case 37: + case 51: if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49: + case 50: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 41: case 42: + case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); @@ -29969,8 +29817,8 @@ var ts; } if (type.flags & 1572864) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -29984,8 +29832,8 @@ var ts; } if (type.flags & 524288) { 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 (!isTypeOfKind(t, kind)) { return false; } @@ -29994,8 +29842,8 @@ var ts; } if (type.flags & 1048576) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -30033,24 +29881,24 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 || property.kind === 254) { - var name_20 = property.name; - if (name_20.kind === 140) { - checkComputedPropertyName(name_20); + var name_17 = property.name; + if (name_17.kind === 141) { + checkComputedPropertyName(name_17); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name_17)) { return undefined; } - var text = getTextOfPropertyName(name_20); + var text = getTextOfPropertyName(name_17); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -30065,7 +29913,7 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_17)); } } else { @@ -30083,8 +29931,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193) { - if (element.kind !== 191) { + if (element.kind !== 194) { + if (element.kind !== 192) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -30110,7 +29958,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -30137,14 +29985,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 && target.operatorToken.kind === 56) { + if (target.kind === 188 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170) { + if (target.kind === 171) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -30159,49 +30007,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69: + case 70: case 9: - case 10: - case 176: - case 189: case 11: + case 177: + case 190: + case 12: case 8: - case 99: - case 84: - case 93: - case 135: - case 179: - case 192: + case 100: + case 85: + case 94: + case 136: case 180: - case 170: + case 193: + case 181: case 171: - case 182: - case 196: + case 172: + case 183: + case 197: + case 243: case 242: - case 241: return true; - case 188: + case 189: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187: + case 188: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185: case 186: + case 187: switch (node.operator) { - case 49: - case 35: - case 36: case 50: + case 36: + case 37: + case 51: return true; } return false; - case 183: - case 177: - case 195: + case 184: + case 178: + case 196: default: return false; } @@ -30221,34 +30069,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 171 || left.kind === 170)) { + if (operator === 57 && (left.kind === 172 || left.kind === 171)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37: case 38: - case 59: - case 60: case 39: + case 60: case 61: case 40: case 62: - case 36: - case 58: - case 43: + case 41: case 63: + case 37: + case 59: case 44: case 64: case 45: case 65: - case 47: - case 67: - case 48: - case 68: case 46: case 66: + case 48: + case 68: + case 49: + case 69: + case 47: + case 67: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30272,8 +30120,8 @@ var ts; } } return numberType; - case 35: - case 57: + case 36: + case 58: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30302,24 +30150,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57) { + if (operator === 58) { checkAssignmentOperator(resultType); } return resultType; - case 25: - case 27: + case 26: case 28: case 29: + case 30: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30: case 31: case 32: case 33: + case 34: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -30330,22 +30178,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91: + case 92: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: + case 91: return checkInExpression(left, right, leftType, rightType); - case 51: + case 52: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52: + case 53: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56: + case 57: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24: + case 25: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -30363,21 +30211,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 48: + case 68: + return 53; + case 49: + case 69: + return 34; case 47: case 67: return 52; - case 48: - case 68: - return 33; - case 46: - case 66: - return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 && operator <= 68) { + if (produceDiagnostics && operator >= 57 && operator <= 69) { var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); @@ -30449,9 +30297,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 99: + case 100: return trueType; - case 84: + case 85: return falseType; } } @@ -30480,7 +30328,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 || node.kind === 195; + return node.kind === 178 || node.kind === 196; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -30506,14 +30354,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -30536,7 +30384,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139) { + if (node.kind === 140) { type = checkQualifiedName(node); } else { @@ -30544,9 +30392,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 172 && node.parent.expression === node) || - (node.parent.kind === 173 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 139) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 && node.parent.expression === node) || + (node.parent.kind === 174 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 140) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -30555,79 +30403,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69: + case 70: return checkIdentifier(node); - case 97: + case 98: return checkThisExpression(node); - case 95: + case 96: return checkSuperExpression(node); - case 93: + case 94: return nullWideningType; case 9: case 8: - case 99: - case 84: + case 100: + case 85: return checkLiteralExpression(node); - case 189: + case 190: return checkTemplateExpression(node); - case 11: + case 12: return stringType; - case 10: + case 11: return globalRegExpType; - case 170: - return checkArrayLiteral(node, contextualMapper); case 171: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 172: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 173: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 174: + return checkIndexedAccess(node); case 175: - return checkCallExpression(node); case 176: + return checkCallExpression(node); + case 177: return checkTaggedTemplateExpression(node); - case 178: + case 179: return checkExpression(node.expression, contextualMapper); - case 192: + case 193: return checkClassExpression(node); - case 179: case 180: + case 181: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182: + case 183: return checkTypeOfExpression(node); - case 177: - case 195: - return checkAssertion(node); + case 178: case 196: + return checkAssertion(node); + case 197: return checkNonNullAssertion(node); - case 181: + case 182: return checkDeleteExpression(node); - case 183: - return checkVoidExpression(node); case 184: - return checkAwaitExpression(node); + return checkVoidExpression(node); case 185: - return checkPrefixUnaryExpression(node); + return checkAwaitExpression(node); case 186: - return checkPostfixUnaryExpression(node); + return checkPrefixUnaryExpression(node); case 187: - return checkBinaryExpression(node, contextualMapper); + return checkPostfixUnaryExpression(node); case 188: + return checkBinaryExpression(node, contextualMapper); + case 189: return checkConditionalExpression(node, contextualMapper); - case 191: + case 192: return checkSpreadElementExpression(node, contextualMapper); - case 193: + case 194: return undefinedWideningType; - case 190: + case 191: return checkYieldExpression(node); case 248: return checkJsxExpression(node); - case 241: - return checkJsxElement(node); case 242: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 243: + return checkJsxSelfClosingElement(node); + case 244: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -30648,7 +30496,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -30659,7 +30507,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 || func.kind === 152 || func.kind === 157) { + if (func.kind === 149 || func.kind === 153 || func.kind === 158) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -30671,15 +30519,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 || - node.kind === 220 || - node.kind === 179; + return node.kind === 148 || + node.kind === 221 || + node.kind === 180; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 && + if (param.name.kind === 70 && param.name.text === parameter.text) { return i; } @@ -30714,9 +30562,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name_18 = _a[_i].name; + if (ts.isBindingPattern(name_18) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_18, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -30729,13 +30577,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 181: + case 152: + case 221: case 180: - case 151: - case 220: - case 179: - case 156: + case 157: + case 148: case 147: - case 146: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -30748,27 +30596,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 69 && - name_22.text === predicateVariableName) { + var name_19 = element.name; + if (name_19.kind === 70 && + name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 168 || - name_22.kind === 167) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name_19.kind === 169 || + name_19.kind === 168) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 153) { + if (node.kind === 154) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 || node.kind === 220 || node.kind === 157 || - node.kind === 151 || node.kind === 148 || - node.kind === 152) { + else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || + node.kind === 152 || node.kind === 149 || + node.kind === 153) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -30780,10 +30628,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152: + case 153: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151: + case 152: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -30810,11 +30658,17 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Accessor; + (function (Accessor) { + Accessor[Accessor["Getter"] = 1] = "Getter"; + Accessor[Accessor["Setter"] = 2] = "Setter"; + Accessor[Accessor["Property"] = 3] = "Property"; + })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -30823,18 +30677,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149: + case 150: addName(names, member.name, memberName, 1); break; - case 150: + case 151: addName(names, member.name, memberName, 2); break; - case 145: + case 146: addName(names, member.name, memberName, 3); break; } @@ -30860,12 +30714,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144) { + if (member.kind == 145) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 69: + case 70: memberName = member.name.text; break; default: @@ -30882,7 +30736,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222) { + if (node.kind === 223) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -30897,7 +30751,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132: + case 133: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -30905,7 +30759,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130: + case 131: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -30961,15 +30815,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97) { + if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 && n.kind !== 220) { + else if (n.kind !== 180 && n.kind !== 221) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 && + return n.kind === 146 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30989,7 +30843,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31012,18 +30866,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149) { + if (node.kind === 150) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 149 ? 150 : 149; + var otherKind = node.kind === 150 ? 151 : 150; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -31037,11 +30891,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149) { + if (node.kind === 150) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171) { + if (node.parent.kind !== 172) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -31127,9 +30981,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 222 && - n.parent.kind !== 221 && - n.parent.kind !== 192 && + if (n.parent.kind !== 223 && + n.parent.kind !== 222 && + n.parent.kind !== 193 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31206,7 +31060,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 147 || node.kind === 146) && + var reportError = (node.kind === 148 || node.kind === 147) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -31239,11 +31093,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 || node.parent.kind === 159 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 220 || node.kind === 147 || node.kind === 146 || node.kind === 148) { + if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31354,16 +31208,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222: + case 223: return 2097152; - case 225: + case 226: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 221: - case 224: + case 222: + case 225: return 2097152 | 1048576; - case 229: + case 230: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31511,22 +31365,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221: + case 222: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147: - case 149: + case 148: case 150: + case 151: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -31535,9 +31389,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 155) { + if (node && node.kind === 156) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 ? 793064 : 1920; + var meaning = root.parent.kind === 156 ? 793064 : 1920; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -31571,20 +31425,20 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 221: + case 222: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147: - case 149: + case 148: case 150: + case 151: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145: - case 142: + case 146: + case 143: checkTypeAnnotationAsExpression(node); break; } @@ -31604,7 +31458,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 140) { + if (node.name && node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -31647,42 +31501,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256: - case 225: + case 226: checkUnusedModuleMembers(node); break; - case 221: - case 192: + case 222: + case 193: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222: + case 223: checkUnusedTypeParameters(node); break; - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: checkUnusedLocalsAndParameters(node); break; - case 148: - case 179: - case 220: - case 180: - case 147: case 149: + case 180: + case 221: + case 181: + case 148: case 150: + case 151: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146: - case 151: + case 147: case 152: case 153: - case 156: + case 154: case 157: + case 158: checkUnusedTypeParameters(node); break; } @@ -31691,11 +31545,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -31715,19 +31569,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; + return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 || member.kind === 145) { + if (member.kind === 148 || member.kind === 146) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148) { + else if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -31772,7 +31626,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 199) { + if (node.kind === 200) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -31794,19 +31648,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 || - node.kind === 144 || + if (node.kind === 146 || + node.kind === 145 || + node.kind === 148 || node.kind === 147 || - node.kind === 146 || - node.kind === 149 || - node.kind === 150) { + node.kind === 150 || + node.kind === 151) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -31820,7 +31674,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; + var isDeclaration_1 = node.kind !== 70; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -31841,7 +31695,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; + var isDeclaration_2 = node.kind !== 70; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -31851,13 +31705,13 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31869,7 +31723,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31881,7 +31735,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 218 && !node.initializer) { + if (node.kind === 219 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -31891,25 +31745,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219); - var container = varDeclList.parent.kind === 200 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); + var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 199 && ts.isFunctionLike(container.parent) || + (container.kind === 200 && ts.isFunctionLike(container.parent) || + container.kind === 227 || container.kind === 226 || - container.kind === 225 || container.kind === 256); 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); + var name_20 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_20, name_20); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142) { + if (ts.getRootDeclaration(node).kind !== 143) { return; } var func = ts.getContainingFunction(node); @@ -31918,10 +31772,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 172) { + if (n.kind === 173) { return visit(n.expression); } - else if (n.kind === 69) { + else if (n.kind === 70) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -31932,7 +31786,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142) { + if (symbol.valueDeclaration.kind === 143) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -31941,7 +31795,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 145 && + if (current.parent.kind === 146 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -31958,25 +31812,25 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169) { - if (node.propertyName && node.propertyName.kind === 140) { + if (node.kind === 170) { + if (node.propertyName && node.propertyName.kind === 141) { checkComputedPropertyName(node.propertyName); } var parent_13 = node.parent.parent; var parentType = getTypeForBindingElementParent(parent_13); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); + var name_21 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); if (parent_13.initializer && property && getParentOfSymbol(property)) { checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } @@ -31984,12 +31838,12 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 142 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31998,7 +31852,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32016,9 +31870,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 && node.kind !== 144) { + if (node.kind !== 146 && node.kind !== 145) { checkExportsOnMergedDeclarations(node); - if (node.kind === 218 || node.kind === 169) { + if (node.kind === 219 || node.kind === 170) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -32028,8 +31882,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 && right.kind === 218) || - (left.kind === 218 && right.kind === 142)) { + if ((left.kind === 143 && right.kind === 219) || + (left.kind === 219 && right.kind === 143)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32056,7 +31910,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 171) { + if (node.modifiers && node.parent.kind === 172) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -32075,7 +31929,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201) { + if (node.thenStatement.kind === 202) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32092,12 +31946,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219) { + if (node.initializer && node.initializer.kind === 220) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32115,13 +31969,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -32139,7 +31993,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { 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); @@ -32149,7 +32003,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { @@ -32322,7 +32176,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150))); + return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -32344,12 +32198,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 150) { + if (func.kind === 151) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148) { + else if (func.kind === 149) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -32367,7 +32221,7 @@ var ts; } } } - else if (func.kind !== 148 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -32424,7 +32278,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 && current.label.text === node.label.text) { + if (current.kind === 215 && 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; @@ -32450,7 +32304,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { + if (catchClause.variableDeclaration.name.kind !== 70) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -32518,7 +32372,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 140 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -32569,7 +32423,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 || declaration.kind === 222) { + if (declaration.kind === 222 || declaration.kind === 223) { if (!firstDecl) { firstDecl = declaration; } @@ -32706,7 +32560,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 192) { + if (derivedClassDecl.kind === 193) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -32750,7 +32604,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 || kind === 150; + return kind === 150 || kind === 151; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -32817,7 +32671,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -32912,18 +32766,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185: + case 186: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35: return value_1; - case 36: return -value_1; - case 50: return ~value_1; + case 36: return value_1; + case 37: return -value_1; + case 51: return ~value_1; } return undefined; - case 187: + case 188: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -32933,37 +32787,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 47: return left | right; - case 46: return left & right; - case 44: return left >> right; - case 45: return left >>> right; - case 43: return left << right; - case 48: return left ^ right; - case 37: return left * right; - case 39: return left / right; - case 35: return left + right; - case 36: return left - right; - case 40: return left % right; + case 48: return left | right; + case 47: return left & right; + case 45: return left >> right; + case 46: return left >>> right; + case 44: return left << right; + case 49: return left ^ right; + case 38: return left * right; + case 40: return left / right; + case 36: return left + right; + case 37: return left - right; + case 41: return left % right; } return undefined; case 8: return +e.text; - case 178: + case 179: return evalConstant(e.expression); - case 69: + case 70: + case 174: case 173: - case 172: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69) { + if (e.kind === 70) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 173) { + if (e.kind === 174) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32977,10 +32831,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 69) { + if (current.kind === 70) { break; } - else if (current.kind === 172) { + else if (current.kind === 173) { current = current.expression; } else { @@ -33040,7 +32894,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 224) { + if (declaration.kind !== 225) { return false; } var enumDeclaration = declaration; @@ -33063,8 +32917,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 === 221 || - (declaration.kind === 220 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 || + (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33123,7 +32977,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, 221); + var mergedClass = ts.getDeclarationOfKind(symbol, 222); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33166,36 +33020,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200: + case 201: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229: case 230: + case 231: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169: - case 218: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 170: + case 219: + var name_22 = node.name; + if (ts.isBindingPattern(name_22)) { + for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 221: - case 224: - case 220: case 222: case 225: + case 221: case 223: + case 226: + case 224: if (isGlobalAugmentation) { return; } @@ -33211,17 +33065,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69: + case 70: return node; - case 139: + case 140: do { node = node.left; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; - case 172: + case 173: do { node = node.expression; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; } } @@ -33231,9 +33085,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 ? + error(moduleName, node.kind === 237 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33254,7 +33108,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 ? + var message = node.kind === 239 ? 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)); @@ -33281,7 +33135,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { checkImportBinding(importClause.namedBindings); } else { @@ -33316,7 +33170,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.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); } } @@ -33332,7 +33186,7 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -33346,7 +33200,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33370,14 +33224,14 @@ var ts; return; } var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 225 && !ts.isAmbientModule(container)) { + if (container.kind === 226 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { markExportAsReferenced(node); } else { @@ -33385,7 +33239,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { @@ -33437,7 +33291,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 && declaration.kind !== 147) || + return (declaration.kind !== 221 && declaration.kind !== 148) || !!declaration.body; } } @@ -33448,118 +33302,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141: - return checkTypeParameter(node); case 142: + return checkTypeParameter(node); + case 143: return checkParameter(node); + case 146: case 145: - case 144: return checkPropertyDeclaration(node); - case 156: case 157: - case 151: + case 158: case 152: - return checkSignatureDeclaration(node); case 153: return checkSignatureDeclaration(node); + case 154: + return checkSignatureDeclaration(node); + case 148: case 147: - case 146: return checkMethodDeclaration(node); - case 148: - return checkConstructorDeclaration(node); case 149: + return checkConstructorDeclaration(node); case 150: + case 151: return checkAccessorDeclaration(node); - case 155: + case 156: return checkTypeReferenceNode(node); - case 154: + case 155: return checkTypePredicate(node); - case 158: - return checkTypeQuery(node); case 159: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 160: - return checkArrayType(node); + return checkTypeLiteral(node); case 161: - return checkTupleType(node); + return checkArrayType(node); case 162: + return checkTupleType(node); case 163: - return checkUnionOrIntersectionType(node); case 164: + return checkUnionOrIntersectionType(node); + case 165: return checkSourceElement(node.type); - case 220: + case 221: return checkFunctionDeclaration(node); - case 199: - case 226: - return checkBlock(node); case 200: + case 227: + return checkBlock(node); + case 201: return checkVariableStatement(node); - case 202: - return checkExpressionStatement(node); case 203: - return checkIfStatement(node); + return checkExpressionStatement(node); case 204: - return checkDoStatement(node); + return checkIfStatement(node); case 205: - return checkWhileStatement(node); + return checkDoStatement(node); case 206: - return checkForStatement(node); + return checkWhileStatement(node); case 207: - return checkForInStatement(node); + return checkForStatement(node); case 208: - return checkForOfStatement(node); + return checkForInStatement(node); case 209: + return checkForOfStatement(node); case 210: - return checkBreakOrContinueStatement(node); case 211: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 212: - return checkWithStatement(node); + return checkReturnStatement(node); case 213: - return checkSwitchStatement(node); + return checkWithStatement(node); case 214: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 215: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 216: + return checkThrowStatement(node); + case 217: return checkTryStatement(node); - case 218: + case 219: return checkVariableDeclaration(node); - case 169: + case 170: return checkBindingElement(node); - case 221: - return checkClassDeclaration(node); case 222: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 223: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 224: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 225: + return checkEnumDeclaration(node); + case 226: return checkModuleDeclaration(node); - case 230: + case 231: return checkImportDeclaration(node); - case 229: + case 230: return checkImportEqualsDeclaration(node); - case 236: + case 237: return checkExportDeclaration(node); - case 235: + case 236: return checkExportAssignment(node); - case 201: + case 202: checkGrammarStatementInAmbientContext(node); return; - case 217: + case 218: checkGrammarStatementInAmbientContext(node); return; - case 239: + case 240: return checkMissingDeclaration(node); } } @@ -33572,17 +33426,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179: case 180: + case 181: + case 148: case 147: - case 146: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149: case 150: + case 151: checkAccessorDeferred(node); break; - case 192: + case 193: checkClassExpressionDeferred(node); break; } @@ -33654,7 +33508,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 && node.parent.statement === node) { + if (node.parent.kind === 213 && node.parent.statement === node) { return true; } node = node.parent; @@ -33680,24 +33534,24 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225: + case 226: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 224: + case 225: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 192: + case 193: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 221: case 222: + case 223: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 179: + case 180: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -33730,33 +33584,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 && + return name.kind === 70 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141: - case 221: + case 142: case 222: case 223: case 224: + case 225: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139) { + while (node.parent && node.parent.kind === 140) { node = node.parent; } - return node.parent && (node.parent.kind === 155 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172) { + while (node.parent && node.parent.kind === 173) { node = node.parent; } - return node.parent && node.parent.kind === 194; + return node.parent && node.parent.kind === 195; } function forEachEnclosingClass(node, callback) { var result; @@ -33773,13 +33627,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139) { + while (nodeOnRightSide.parent.kind === 140) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -33791,7 +33645,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -33803,20 +33657,20 @@ var ts; default: } } - if (entityName.parent.kind === 235 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 172 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 229); + if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 230); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 194) { + if (entityName.parent.kind === 195) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -33832,20 +33686,20 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 69) { + if (entityName.kind === 70) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 172) { + else if (entityName.kind === 173) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139) { + else if (entityName.kind === 140) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -33854,13 +33708,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } else if (entityName.parent.kind === 246) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { return resolveEntityName(entityName, 1); } return undefined; @@ -33878,12 +33732,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69) { + if (node.kind === 70) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 && - node.parent.parent.kind === 167 && + else if (node.parent.kind === 170 && + node.parent.parent.kind === 168 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -33893,11 +33747,11 @@ var ts; } } switch (node.kind) { - case 69: - case 172: - case 139: + case 70: + case 173: + case 140: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: + case 98: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -33905,21 +33759,21 @@ var ts; return sig.thisParameter; } } - case 95: + case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165: + case 166: return getTypeFromTypeNode(node).symbol; - case 121: + case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148) { + if (constructorDeclaration && constructorDeclaration.kind === 149) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 || node.parent.kind === 236) && + ((node.parent.kind === 231 || node.parent.kind === 237) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -33927,7 +33781,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 173 && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -33991,12 +33845,12 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 || expr.kind === 170); - if (expr.parent.kind === 208) { + ts.Debug.assert(expr.kind === 172 || expr.kind === 171); + if (expr.parent.kind === 209) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 187) { + if (expr.parent.kind === 188) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -34004,7 +33858,7 @@ var ts; var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 170); + ts.Debug.assert(expr.parent.kind === 171); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -34040,9 +33894,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_26 = symbol.name; + var name_23 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_23); if (symbol) { symbols_3.push(symbol); } @@ -34145,7 +33999,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 === 199 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34185,18 +34039,18 @@ var ts; return true; } switch (node.kind) { - case 229: - case 231: + case 230: case 232: - case 234: - case 238: + case 233: + case 235: + case 239: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236: + case 237: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235: + case 236: return node.expression - && node.expression.kind === 69 + && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -34428,7 +34282,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 172) || (node.kind === 69 && isInTypeQuery(node)) + var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -34575,6 +34429,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -34634,14 +34489,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -34658,28 +34513,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128) { - if (node.kind === 144 || node.kind === 146) { + if (modifier.kind !== 129) { + if (node.kind === 145 || node.kind === 147) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153) { + if (node.kind === 154) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74: - if (node.kind !== 224 && node.parent.kind === 221) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); + case 75: + if (node.kind !== 225 && node.parent.kind === 222) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; + case 113: case 112: case 111: - case 110: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111) { + if (modifier.kind === 112) { lastProtected = modifier; } - else if (modifier.kind === 110) { + else if (modifier.kind === 111) { lastPrivate = modifier; } if (flags & 28) { @@ -34694,11 +34549,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 110) { + if (modifier.kind === 111) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -34707,7 +34562,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113: + case 114: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -34717,10 +34572,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -34729,17 +34584,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 128: + case 129: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 && node.kind !== 144 && node.kind !== 153 && node.kind !== 142) { + else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 82: + case 83: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -34752,45 +34607,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 122: + case 123: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 115: + case 116: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221) { - if (node.kind !== 147 && - node.kind !== 145 && - node.kind !== 149 && - node.kind !== 150) { + if (node.kind !== 222) { + if (node.kind !== 148 && + node.kind !== 146 && + node.kind !== 150 && + node.kind !== 151) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -34802,14 +34657,14 @@ var ts; } flags |= 128; break; - case 118: + case 119: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -34817,7 +34672,7 @@ var ts; break; } } - if (node.kind === 148) { + if (node.kind === 149) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -34832,13 +34687,13 @@ var ts; } return; } - else if ((node.kind === 230 || node.kind === 229) && flags & 2) { + else if ((node.kind === 231 || node.kind === 230) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -34854,38 +34709,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149: case 150: - case 148: + case 151: + case 149: + case 146: case 145: - case 144: + case 148: case 147: - case 146: - case 153: - case 225: + case 154: + case 226: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 179: case 180: - case 142: + case 181: + case 143: return false; default: - if (node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 227 || node.parent.kind === 256) { return false; } switch (node.kind) { - case 220: - return nodeHasAnyModifiersExcept(node, 118); case 221: - return nodeHasAnyModifiersExcept(node, 115); + return nodeHasAnyModifiersExcept(node, 119); case 222: - case 200: + return nodeHasAnyModifiersExcept(node, 116); case 223: - return true; + case 201: case 224: - return nodeHasAnyModifiersExcept(node, 74); + return true; + case 225: + return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); return false; @@ -34897,10 +34752,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147: - case 220: - case 179: + case 148: + case 221: case 180: + case 181: if (!node.asteriskToken) { return false; } @@ -34916,7 +34771,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -34958,11 +34813,11 @@ var ts; } function checkGrammarFunctionLikeDeclaration(node) { var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180) { + if (node.kind === 181) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34997,7 +34852,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 132 && parameter.type.kind !== 130) { + if (parameter.type.kind !== 133 && parameter.type.kind !== 131) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -35024,7 +34879,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193) { + if (arg.kind === 194) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -35050,7 +34905,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -35063,7 +34918,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -35078,14 +34933,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -35094,19 +34949,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 140) { + if (node.kind !== 141) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 220 || - node.kind === 179 || - node.kind === 147); + ts.Debug.assert(node.kind === 221 || + node.kind === 180 || + node.kind === 148); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -35118,7 +34973,7 @@ var ts; } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -35131,9 +34986,9 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_27 = prop.name; - if (name_27.kind === 140) { - checkGrammarComputedPropertyName(name_27); + var name_24 = prop.name; + if (name_24.kind === 141) { + checkGrammarComputedPropertyName(name_24); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -35141,32 +34996,32 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 || prop.kind !== 147) { + if (mod.kind !== 119 || prop.kind !== 148) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8) { - checkGrammarNumericLiteral(name_27); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_24.kind === 8) { + checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147) { + else if (prop.kind === 148) { currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = GetAccessor; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_24); if (effectiveName === undefined) { continue; } @@ -35176,18 +35031,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_24, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_24)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -35200,12 +35055,12 @@ var ts; continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_25 = jsxAttr.name; + if (!seen[name_25.text]) { + seen[name_25.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_25, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 248 && !initializer.expression) { @@ -35217,7 +35072,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219) { + if (forInOrOfStatement.initializer.kind === 220) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35225,20 +35080,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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); @@ -35262,11 +35117,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 ? + return grammarErrorOnNode(accessor.name, kind === 150 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150) { + else if (kind === 151) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -35285,10 +35140,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -35303,8 +35158,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -35319,10 +35174,10 @@ 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 === 222) { + else if (node.parent.kind === 223) { 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 === 159) { + else if (node.parent.kind === 160) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -35333,9 +35188,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214: + case 215: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 209 + var isMisplacedContinueLabel = node.kind === 210 && !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); @@ -35343,8 +35198,8 @@ var ts; return false; } break; - case 213: - if (node.kind === 210 && !node.label) { + case 214: + if (node.kind === 211 && !node.label) { return false; } break; @@ -35357,13 +35212,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 + var message = node.kind === 211 ? 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 === 210 + var message = node.kind === 211 ? 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); @@ -35375,7 +35230,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 168 || node.name.kind === 167) { + if (node.name.kind === 169 || node.name.kind === 168) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35385,11 +35240,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 && node.parent.parent.kind !== 208) { + if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -35420,8 +35275,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.originalKeywordKind === 108) { + if (name.kind === 70) { + if (name.originalKeywordKind === 109) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -35446,15 +35301,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203: case 204: case 205: - case 212: case 206: + case 213: case 207: case 208: + case 209: return false; - case 214: + case 215: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -35509,7 +35364,7 @@ var ts; return true; } } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 223) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35517,7 +35372,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159) { + else if (node.parent.kind === 160) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35530,13 +35385,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 222 || - node.kind === 223 || + if (node.kind === 223 || + node.kind === 224 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || - node.kind === 228 || + node.kind === 229 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -35545,7 +35400,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 === 200) { + if (ts.isDeclaration(decl) || decl.kind === 201) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -35564,7 +35419,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 === 199 || node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { 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); @@ -35603,46 +35458,46 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139] = [ + _a[140] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143] = [ + _a[144] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177] = [ + _a[178] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195] = [ + _a[196] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196] = [ + _a[197] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224] = [ + _a[225] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225] = [ + _a[226] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226] = [ + _a[227] = [ { name: "statements", test: ts.isStatement } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240] = [ + _a[241] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255] = [ @@ -35658,41 +35513,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return initial; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return initial; } var result = initial; switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: case 287: break; - case 140: + case 141: result = reduceNode(node.expression, f, result); break; - case 142: + case 143: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 143: + case 144: result = reduceNode(node.expression, f, result); break; - case 145: + case 146: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147: + case 148: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35701,12 +35556,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148: + case 149: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 149: + case 150: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35714,51 +35569,51 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 150: + case 151: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 167: case 168: + case 169: result = ts.reduceLeft(node.elements, f, result); break; - case 169: + case 170: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 170: + case 171: result = ts.reduceLeft(node.elements, f, result); break; - case 171: + case 172: result = ts.reduceLeft(node.properties, f, result); break; - case 172: + case 173: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 173: + case 174: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 174: + case 175: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 175: + case 176: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176: + case 177: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179: + case 180: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -35766,117 +35621,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180: + case 181: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178: - case 181: + case 179: case 182: case 183: case 184: - case 190: + case 185: case 191: - case 196: + case 192: + case 197: result = reduceNode(node.expression, f, result); break; - case 185: case 186: + case 187: result = reduceNode(node.operand, f, result); break; - case 187: + case 188: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188: + case 189: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189: + case 190: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192: + case 193: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194: + case 195: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 197: + case 198: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 199: + case 200: result = ts.reduceLeft(node.statements, f, result); break; - case 200: + case 201: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202: + case 203: result = reduceNode(node.expression, f, result); break; - case 203: + case 204: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204: + case 205: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 205: - case 212: + case 206: + case 213: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 206: + case 207: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207: case 208: + case 209: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211: - case 215: + case 212: + case 216: result = reduceNode(node.expression, f, result); break; - case 213: + case 214: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214: + case 215: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216: + case 217: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218: + case 219: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219: + case 220: result = ts.reduceLeft(node.declarations, f, result); break; - case 220: + case 221: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35885,7 +35740,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 221: + case 222: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35893,49 +35748,49 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227: + case 228: result = ts.reduceLeft(node.clauses, f, result); break; - case 230: + case 231: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231: - result = reduceNode(node.name, f, result); - result = reduceNode(node.namedBindings, f, result); - break; case 232: result = reduceNode(node.name, f, result); + result = reduceNode(node.namedBindings, f, result); break; case 233: - case 237: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNode(node.name, f, result); break; case 234: case 238: + result = ts.reduceLeft(node.elements, f, result); + break; + case 235: + case 239: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235: + case 236: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236: + case 237: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 241: + case 242: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242: case 243: + case 244: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -36078,153 +35933,153 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return node; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return node; } switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: return node; - case 140: + case 141: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 142: + case 143: return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 145: + case 146: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: - return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 148: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 149: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 150: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 167: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 168: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 169: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 170: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 171: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 172: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 173: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 174: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 175: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 177: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 180: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 181: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); case 182: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 183: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 184: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 185: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187: + case 188: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 186: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 187: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 190: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 191: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 192: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 193: 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 194: + case 195: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 197: + case 198: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 199: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 200: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 201: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 202: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 203: - 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 204: - 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 205: - 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 206: - 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 207: - 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 208: - 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 209: - 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 210: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 211: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 212: - 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 213: - 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 214: - 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 215: - 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 216: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 217: 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 218: - 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 219: - 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 220: - 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 221: + 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 222: 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 227: + case 228: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230: - 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 231: - 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 232: - 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 233: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 234: - 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 235: - 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 236: - 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 237: - 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 238: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 239: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 242: - 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 243: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + case 244: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -36325,67 +36180,67 @@ var ts; return transformFlags | aggregateTransformFlagsForNode(child); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 && kind <= 166) { + if (kind >= 155 && kind <= 167) { return -3; } switch (kind) { - case 174: case 175: - case 170: - return 537133909; - case 225: - return 546335573; - case 142: - return 538968917; + case 176: + case 171: + return 537922901; + case 226: + return 574729557; + case 143: + return 545262933; + case 181: + return 592227669; case 180: - return 550710101; - case 179: - case 220: - return 550726485; - case 219: - return 538968917; case 221: - case 192: - return 537590613; - case 148: - return 550593365; - case 147: + return 592293205; + case 220: + return 545262933; + case 222: + case 193: + return 539749717; case 149: + return 591760725; + case 148: case 150: - return 550593365; - case 117: - case 130: - case 127: - case 132: - case 120: - case 133: - case 103: - case 141: - case 144: - case 146: case 151: + return 591760725; + case 118: + case 131: + case 128: + case 133: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: - case 222: + case 154: case 223: + case 224: return -3; - case 171: - return 537430869; + case 172: + return 539110741; default: - return 536871765; + return 536874325; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -36423,7 +36278,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -36443,9 +36298,9 @@ var ts; } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -36460,10 +36315,10 @@ var ts; } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -36495,9 +36350,9 @@ var ts; } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -36519,7 +36374,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -36540,7 +36395,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -36550,17 +36405,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171) { + if (target.kind === 172) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170) { + else if (target.kind === 171) { emitArrayLiteralAssignment(target, value, location); } else { - var name_29 = ts.getMutableClone(target); - ts.setSourceMapRange(name_29, target); - ts.setCommentRange(name_29, target); - emitAssignment(name_29, value, location, undefined); + var name_26 = ts.getMutableClone(target); + ts.setSourceMapRange(name_26, target); + ts.setCommentRange(name_26, target); + emitAssignment(name_26, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -36585,8 +36440,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193) { - if (e.kind !== 191) { + if (e.kind !== 194) { + if (e.kind !== 192) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -36615,7 +36470,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167) { + else if (name.kind === 168) { var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); } @@ -36635,7 +36490,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53), defaultValue, ts.createToken(54), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54), defaultValue, ts.createToken(55), value); } function createDestructuringPropertyAccess(expression, propertyName) { if (ts.isComputedPropertyName(propertyName)) { @@ -36673,6 +36528,12 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -36683,8 +36544,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(172); context.enableSubstitution(173); + context.enableSubstitution(174); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -36694,7 +36555,6 @@ var ts; var enabledSubstitutions; var classAliases; var applicableSubstitutions; - var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -36728,15 +36588,32 @@ var ts; } return node; } + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 236: + return visitExportAssignment(node); + case 237: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } function namespaceElementVisitor(node) { return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 236 || - node.kind === 230 || + if (node.kind === 237 || node.kind === 231 || - (node.kind === 229 && - node.moduleReference.kind === 240)) { + node.kind === 232 || + (node.kind === 230 && + node.moduleReference.kind === 241)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -36752,15 +36629,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 148: - return undefined; - case 145: - case 153: case 149: + return undefined; + case 146: + case 154: case 150: - case 147: + case 151: + case 148: return visitorWorker(node); - case 198: + case 199: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -36772,84 +36649,87 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82: - case 77: + case 83: + case 78: return currentNamespace ? undefined : node; - case 112: - case 110: + case 113: case 111: - case 115: - case 118: - case 74: - case 122: - case 128: - case 160: + case 112: + case 116: + case 75: + case 123: + case 129: case 161: - case 159: - case 154: - case 141: - case 117: - case 120: - case 132: - case 130: - case 127: - case 103: + case 162: + case 160: + case 155: + case 142: + case 118: + case 121: case 133: + case 131: + case 128: + case 104: + case 134: + case 158: case 157: + case 159: case 156: - case 158: - case 155: - case 162: case 163: case 164: case 165: case 166: - case 153: - case 143: + case 167: + case 154: + case 144: + case 224: + case 146: + case 149: + return visitConstructor(node); case 223: - case 145: - case 148: - return undefined; - case 222: return ts.createNotEmittedStatement(node); - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); case 251: return visitHeritageClause(node); - case 194: + case 195: return visitExpressionWithTypeArguments(node); - case 147: + case 148: return visitMethodDeclaration(node); - case 149: - return visitGetAccessor(node); case 150: + return visitGetAccessor(node); + case 151: return visitSetAccessor(node); - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: - return visitFunctionExpression(node); case 180: + return visitFunctionExpression(node); + case 181: return visitArrowFunction(node); - case 142: + case 143: return visitParameter(node); - case 178: + case 179: return visitParenthesizedExpression(node); - case 177: - case 195: - return visitAssertionExpression(node); + case 178: case 196: + return visitAssertionExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 197: return visitNonNullExpression(node); - case 224: + case 225: return visitEnumDeclaration(node); - case 184: - return visitAwaitExpression(node); - case 200: + case 201: return visitVariableStatement(node); - case 225: + case 219: + return visitVariableDeclaration(node); + case 226: return visitModuleDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -36859,14 +36739,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256: + case 228: case 227: - case 226: - case 199: + case 200: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 222: case 221: - case 220: if (ts.hasModifier(node, 2)) { break; } @@ -36891,14 +36771,14 @@ var ts; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; @@ -36938,7 +36818,7 @@ var ts; classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); } if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); @@ -36984,7 +36864,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); if (staticProperties.length > 0) { var expressions = []; @@ -36995,7 +36875,7 @@ var ts; } ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -37012,13 +36892,13 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072; + var hasParameterPropertyAssignments = node.transformFlags & 524288; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); } function transformConstructorParameters(constructor) { @@ -37026,7 +36906,7 @@ var ts; ? ts.visitNodes(constructor.parameters, visitor, ts.isParameter) : []; } - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; startLexicalEnvironment(); @@ -37039,7 +36919,7 @@ var ts; statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } @@ -37054,7 +36934,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -37088,24 +36968,24 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 145 + return member.kind === 146 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); } } - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -37113,7 +36993,7 @@ var ts; } return expressions; } - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); @@ -37161,12 +37041,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149: case 150: + case 151: return getAllDecoratorsOfAccessors(node, member); - case 147: + case 148: return getAllDecoratorsOfMethod(member); - case 145: + case 146: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -37244,7 +37124,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 145 + ? member.kind === 146 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -37332,43 +37212,43 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 - || kind === 149 + return kind === 148 || kind === 150 - || kind === 145; + || kind === 151 + || kind === 146; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 147; + return node.kind === 148; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 - || kind === 192 - || kind === 147 - || kind === 149 - || kind === 150; + return kind === 222 + || kind === 193 + || kind === 148 + || kind === 150 + || kind === 151; } function serializeTypeOfNode(node) { switch (node.kind) { - case 145: - case 142: - case 149: - return serializeTypeNode(node.type); + case 146: + case 143: case 150: + return serializeTypeNode(node.type); + case 151: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221: - case 192: - case 147: + case 222: + case 193: + case 148: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 160) { + if (node && node.kind === 161) { return node.elementType; } - else if (node && node.kind === 155) { + else if (node && node.kind === 156) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -37414,52 +37294,52 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103: + case 104: return ts.createVoidZero(); - case 164: + case 165: return serializeTypeNode(node.type); - case 156: case 157: + case 158: return ts.createIdentifier("Function"); - case 160: case 161: + case 162: return ts.createIdentifier("Array"); - case 154: - case 120: + case 155: + case 121: return ts.createIdentifier("Boolean"); - case 132: + case 133: return ts.createIdentifier("String"); - case 166: + case 167: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 99: - case 84: + case 100: + case 85: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130: + case 131: return ts.createIdentifier("Number"); - case 133: + case 134: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155: + case 156: return serializeTypeReferenceNode(node); + case 164: case 163: - case 162: { 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 !== 69) { + if (serializedIndividual.kind !== 70) { serializedUnion = undefined; break; } @@ -37476,10 +37356,10 @@ var ts; return serializedUnion; } } - case 158: case 159: - case 117: - case 165: + case 160: + case 118: + case 166: break; default: ts.Debug.failBadSyntaxKind(node); @@ -37520,22 +37400,22 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69: - var name_30 = ts.getMutableClone(node); - name_30.flags &= ~8; - name_30.original = undefined; - name_30.parent = currentScope; + case 70: + var name_27 = ts.getMutableClone(node); + name_27.flags &= ~8; + name_27.original = undefined; + name_27.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } - return name_30; - case 139: + return name_27; + case 140: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69) { + if (node.left.kind === 70) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -37548,7 +37428,7 @@ var ts; return ts.createPropertyAccess(left, node.right); } function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53), ts.createIdentifier("Symbol"), ts.createToken(54), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54), ts.createIdentifier("Symbol"), ts.createToken(55), ts.createIdentifier("Object")); } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; @@ -37580,9 +37460,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 83) { + if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83, types, node); + return ts.createHeritageClause(84, types, node); } return undefined; } @@ -37593,6 +37473,12 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; @@ -37643,36 +37529,33 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -37694,42 +37577,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, node.body, true); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); - } - } function visitParameter(node) { if (ts.parameterIsThisKeyword(node)) { return undefined; @@ -37756,14 +37603,14 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); } } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } function visitParenthesizedExpression(node) { var innerExpression = ts.skipOuterExpressions(node.expression, ~2); @@ -37781,6 +37628,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } function shouldEmitEnumDeclaration(node) { return !ts.isConst(node) || compilerOptions.preserveConstEnums @@ -37812,7 +37665,7 @@ var ts; var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); @@ -37855,7 +37708,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -37870,9 +37723,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_31 = node.symbol && node.symbol.name; - if (name_31) { - return currentScopeFirstDeclarationsOfName[name_31] === node; + var name_28 = node.symbol && node.symbol.name; + if (name_28) { + return currentScopeFirstDeclarationsOfName[name_28] === node; } } return false; @@ -37887,7 +37740,7 @@ var ts; ts.createVariableDeclaration(getDeclarationName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 224) { + if (node.kind === 225) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -37920,7 +37773,7 @@ var ts; var localName = getLocalName(node); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); @@ -37938,7 +37791,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226) { + if (body.kind === 227) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -37961,17 +37814,67 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 226) { + if (body.kind !== 227) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225) { + if (moduleDeclaration.body.kind === 226) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + function visitImportDeclaration(node) { + if (!node.importClause) { + return node; + } + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + return importClause + ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) + : undefined; + } + function visitImportClause(node) { + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + function visitNamedImportBindings(node) { + if (node.kind === 233) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + function visitImportSpecifier(node) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + function visitExportAssignment(node) { + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + function visitExportDeclaration(node) { + if (!node.exportClause) { + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + return undefined; + } + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + return exportClause + ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) + : undefined; + } + function visitNamedExports(node) { + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + function visitExportSpecifier(node) { + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } function shouldEmitImportEqualsDeclaration(node) { return resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) @@ -37979,7 +37882,9 @@ var ts; } function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -38063,7 +37968,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_32 = ts.getMutableClone(node.name); + var name_29 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -38072,9 +37977,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_32, emitFlags); + ts.setEmitFlags(name_29, emitFlags); } - return name_32; + return name_29; } else { return ts.getGeneratedNameForNode(node); @@ -38091,57 +37996,32 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(69); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4) === 0) { - enabledSubstitutions |= 4; - context.enableSubstitution(174); - context.enableSubstitution(172); - context.enableSubstitution(173); - context.enableEmitNotification(221); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(148); + context.enableSubstitution(70); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(69); + context.enableSubstitution(70); classAliases = ts.createMap(); } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); context.enableSubstitution(254); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 - || kind === 148 - || kind === 147 - || kind === 149 - || kind === 150; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 226; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224; + return ts.getOriginalNode(node).kind === 225; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - if (enabledSubstitutions & 4 && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -38150,7 +38030,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -38164,31 +38043,26 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_30 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_30); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, node); + return ts.createPropertyAssignment(name_30, initializer, node); } - return ts.createPropertyAssignment(name_33, exportedName, node); + return ts.createPropertyAssignment(name_30, exportedName, node); } } return node; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 172: - return substitutePropertyAccessExpression(node); case 173: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 174: - if (enabledSubstitutions & 4) { - return substituteCallExpression(node); - } - break; + return substituteElementAccessExpression(node); } return node; } @@ -38218,8 +38092,8 @@ var ts; if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 225) || - (applicableSubstitutions & 8 && container.kind === 224); + var substitute = (applicableSubstitutions & 2 && container.kind === 226) || + (applicableSubstitutions & 8 && container.kind === 225); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38227,37 +38101,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -38285,18 +38132,6 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); @@ -38329,9 +38164,9 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 241: - return visitJsxElement(node, false); case 242: + return visitJsxElement(node, false); + case 243: return visitJsxSelfClosingElement(node, false); case 248: return visitJsxExpression(node); @@ -38342,13 +38177,13 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 244: + case 10: return visitJsxText(node); case 248: return visitJsxExpression(node); - case 241: - return visitJsxElement(node, true); case 242: + return visitJsxElement(node, true); + case 243: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38465,16 +38300,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 241) { + if (node.kind === 242) { return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_31); } } } @@ -38752,13 +38587,30 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFileExternalHelpersModuleName; + var enabledSubstitutions; + var applicableSubstitutions; + var currentSuperContainer; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -38768,13 +38620,265 @@ var ts; else if (node.transformFlags & 32) { return ts.visitEachChild(node, visitor, context); } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119: + return undefined; + case 185: + return visitAwaitExpression(node); + case 148: + return visitMethodDeclaration(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + } + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression(undefined, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, node.body, true); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4); + } + } + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } + } + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(175); + context.enableSubstitution(173); + context.enableSubstitution(174); + context.enableEmitNotification(222); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(149); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173: + return substitutePropertyAccessExpression(node); + case 174: + return substituteElementAccessExpression(node); + case 175: + if (enabledSubstitutions & 1) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); + } + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); + } + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 + || kind === 149 + || kind === 148 + || kind === 150 + || kind === 151; + } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64) { + return visitorWorker(node); + } + else if (node.transformFlags & 128) { + return ts.visitEachChild(node, visitor, context); + } else { return node; } } function visitorWorker(node) { switch (node.kind) { - case 187: + case 188: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38784,7 +38888,7 @@ var ts; function visitBinaryExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60) { + if (node.operatorToken.kind === 61) { var target = void 0; var value = void 0; if (ts.isElementAccessExpression(left)) { @@ -38804,7 +38908,7 @@ var ts; } return ts.createAssignment(target, ts.createMathPow(value, right, node), node); } - else if (node.operatorToken.kind === 38) { + else if (node.operatorToken.kind === 39) { return ts.createMathPow(left, right, node); } else { @@ -38813,11 +38917,33 @@ var ts; } } } - ts.transformES7 = transformES7; + ts.transformES2016 = transformES2016; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6(context) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; @@ -38880,15 +39006,15 @@ var ts; return visited; } function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 214 || + return (node.transformFlags & 256) !== 0 || + node.kind === 215 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128) { + else if (node.transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -38907,18 +39033,18 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 211: + case 212: return visitReturnStatement(node); - case 200: + case 201: return visitVariableStatement(node); - case 213: + case 214: return visitSwitchStatement(node); + case 211: case 210: - case 209: return visitBreakOrContinueStatement(node); - case 97: + case 98: return visitThisKeyword(node); - case 69: + case 70: return visitIdentifier(node); default: return ts.visitEachChild(node, visitor, context); @@ -38926,74 +39052,74 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 82: + case 83: return node; - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); - case 142: + case 143: return visitParameter(node); - case 220: + case 221: return visitFunctionDeclaration(node); - case 180: + case 181: return visitArrowFunction(node); - case 179: + case 180: return visitFunctionExpression(node); - case 218: + case 219: return visitVariableDeclaration(node); - case 69: + case 70: return visitIdentifier(node); - case 219: + case 220: return visitVariableDeclarationList(node); - case 214: + case 215: return visitLabeledStatement(node); - case 204: - return visitDoStatement(node); case 205: - return visitWhileStatement(node); + return visitDoStatement(node); case 206: - return visitForStatement(node); + return visitWhileStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 202: + case 203: return visitExpressionStatement(node); - case 171: + case 172: return visitObjectLiteralExpression(node); case 254: return visitShorthandPropertyAssignment(node); - case 170: + case 171: return visitArrayLiteralExpression(node); - case 174: - return visitCallExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); - case 178: + case 179: return visitParenthesizedExpression(node, true); - case 187: + case 188: return visitBinaryExpression(node, true); - case 11: case 12: case 13: case 14: + case 15: return visitTemplateLiteral(node); - case 176: + case 177: return visitTaggedTemplateExpression(node); - case 189: - return visitTemplateExpression(node); case 190: + return visitTemplateExpression(node); + case 191: return visitYieldExpression(node); - case 95: - return visitSuperKeyword(node); - case 190: + case 96: + return visitSuperKeyword(); + case 191: return ts.visitEachChild(node, visitor, context); - case 147: + case 148: return visitMethodDeclaration(node); case 256: return visitSourceFileNode(node); - case 200: + case 201: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39008,7 +39134,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 180) { + if (currentNode.kind !== 181) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39016,14 +39142,14 @@ var ts; } } switch (currentNode.kind) { - case 200: + case 201: enclosingVariableStatement = currentNode; break; + case 220: case 219: - case 218: - case 169: - case 167: + case 170: case 168: + case 169: break; default: enclosingVariableStatement = undefined; @@ -39051,7 +39177,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180) { + if (enclosingFunction && enclosingFunction.kind === 181) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39071,13 +39197,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 210 ? 2 : 4; + var jump = node.kind === 211 ? 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 === 210) { + if (node.kind === 211) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39087,7 +39213,7 @@ var ts; } } else { - if (node.kind === 210) { + if (node.kind === 211) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39106,10 +39232,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 24, copyExpr); + expr = ts.createBinary(expr, 25, copyExpr); } } - returnExpression = ts.createBinary(expr, 24, returnExpression); + returnExpression = ts.createBinary(expr, 25, returnExpression); } return ts.createReturn(returnExpression); } @@ -39136,7 +39262,7 @@ var ts; return statement; } function isExportModifier(node) { - return node.kind === 82; + return node.kind === 83; } function visitClassExpression(node) { return transformClassLikeDeclarationToExpression(node); @@ -39146,7 +39272,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); if (ts.getEmitFlags(node) & 524288) { ts.setEmitFlags(classFunction, 524288); } @@ -39166,7 +39292,7 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); var localName = getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; @@ -39236,17 +39362,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 211) { + if (statement.kind === 212) { return true; } - else if (statement.kind === 203) { + else if (statement.kind === 204) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 199) { + else if (statement.kind === 200) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39275,7 +39401,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39311,7 +39437,7 @@ var ts; } } function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536) !== 0; + return (node.transformFlags & 262144) !== 0; } function addDefaultValueAssignmentsIfNeeded(statements, node) { if (!shouldAddDefaultValueAssignments(node)) { @@ -39319,22 +39445,22 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); } } } function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); } else if (initializer) { statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); @@ -39350,7 +39476,7 @@ var ts; statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -39375,7 +39501,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 && node.kind !== 180) { + if (node.transformFlags & 65536 && node.kind !== 181) { captureThisForNode(statements, node, ts.createThis()); } } @@ -39392,20 +39518,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 198: + case 199: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 147: + case 148: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 148: + case 149: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39445,6 +39571,7 @@ var ts; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384); var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -39452,6 +39579,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -39468,7 +39596,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 8192) { + if (node.transformFlags & 32768) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -39483,10 +39611,10 @@ var ts; } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180) { + if (node.kind !== 181) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } @@ -39516,7 +39644,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 180); + ts.Debug.assert(node.kind === 181); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -39543,16 +39671,16 @@ var ts; ts.setEmitFlags(block, 32); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16, closeBraceLocation); + ts.setTokenSourceMapRange(block, 17, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 178: + case 179: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 187: + case 188: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -39560,9 +39688,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 178: + case 179: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 187: + case 188: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -39581,16 +39709,16 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24, acc); }), node); + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { return undefined; @@ -39608,7 +39736,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 2097152 + if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -39627,8 +39755,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 && enclosingBlockScopeContainer.kind !== 208 + && enclosingBlockScopeContainer.kind !== 209 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -39651,7 +39779,7 @@ var ts; if (ts.isBindingPattern(node.name)) { var recordTempVariablesInLine = !enclosingVariableStatement || !ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenVariableDestructuring(context, node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + return ts.flattenVariableDestructuring(node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); } return ts.visitEachChild(node, visitor, context); } @@ -39694,7 +39822,7 @@ var ts; var initializer = node.initializer; var statements = []; var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 + var rhsReference = expression.kind === 70 ? ts.createUniqueName(expression.text) : ts.createTempVariable(undefined); if (ts.isVariableDeclarationList(initializer)) { @@ -39703,7 +39831,7 @@ var ts; } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); var declarationList = ts.createVariableDeclarationList(declarations, initializer); ts.setOriginalNode(declarationList, initializer); var firstDeclaration = declarations[0]; @@ -39759,8 +39887,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 4194304 - || property.name.kind === 140) { + if (property.transformFlags & 16777216 + || property.name.kind === 141) { numInitialProperties = i; break; } @@ -39786,7 +39914,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 69) { + if (node.kind === 70) { state.hoistedLocalVariables.push(node); } else { @@ -39815,11 +39943,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 206: case 207: case 208: + case 209: var initializer = node.initializer; - if (initializer && initializer.kind === 219) { + if (initializer && initializer.kind === 220) { loopInitializer = initializer; } break; @@ -39858,7 +39986,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 4194304) !== 0; + && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256; @@ -39867,7 +39995,7 @@ var ts; loopBodyFlags |= 2097152; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ])); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -39926,7 +40054,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 214 + statements.push(currentParent.kind === 215 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -39934,7 +40062,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56, source); + return ts.createBinary(target, 57, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -39949,7 +40077,7 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37), call) : call; + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); @@ -39968,10 +40096,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -40038,21 +40166,21 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; case 253: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; case 254: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 147: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); + case 148: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -40060,21 +40188,21 @@ var ts; } } } - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); if (startsOnNewLine) { expression.startsOnNewLine = true; @@ -40104,17 +40232,17 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { ts.setEmitFlags(thisArg, 128); } var resultingCall; - if (node.transformFlags & 262144) { + if (node.transformFlags & 1048576) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, 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); } - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 128); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -40125,18 +40253,18 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 262144) !== 0); + ts.Debug.assert((node.transformFlags & 1048576) !== 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, []); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -40147,7 +40275,7 @@ var ts; ? visitSpanOfSpreadElements : visitSpanOfNonSpreadElements; } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfSpreadElements(chunk) { return ts.map(chunk, visitExpressionOfSpreadElement); } function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { @@ -40188,7 +40316,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; + var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.createLiteral(text, node); @@ -40222,11 +40350,11 @@ var ts; } } } - function visitSuperKeyword(node) { + function visitSuperKeyword() { return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 174 + && currentParent.kind !== 175 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40253,20 +40381,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(97); - context.enableEmitNotification(148); - context.enableEmitNotification(147); + context.enableSubstitution(98); context.enableEmitNotification(149); + context.enableEmitNotification(148); context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(181); context.enableEmitNotification(180); - context.enableEmitNotification(179); - context.enableEmitNotification(220); + context.enableEmitNotification(221); } } function onSubstituteNode(emitContext, node) { @@ -40291,10 +40419,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 169: - case 221: - case 224: - case 218: + case 170: + case 222: + case 225: + case 219: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40302,9 +40430,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 97: + case 98: return substituteThisKeyword(node); } return node; @@ -40331,7 +40459,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_36 = ts.getMutableClone(node.name); + var name_33 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -40340,9 +40468,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_36, emitFlags); + ts.setEmitFlags(name_33, emitFlags); } - return name_36; + return name_33; } return ts.getGeneratedNameForNode(node); } @@ -40359,29 +40487,74 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { return false; } var expression = callArgument.expression; return ts.isIdentifier(expression) && expression === parameter.name; } } - ts.transformES6 = transformES6; + ts.transformES2015 = transformES2015; })(ts || (ts = {})); var ts; (function (ts) { + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -40427,7 +40600,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024) { + if (node.transformFlags & 4096) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -40442,10 +40615,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512) { + else if (transformFlags & 2048) { return visitGenerator(node); } - else if (transformFlags & 1024) { + else if (transformFlags & 4096) { return ts.visitEachChild(node, visitor, context); } else { @@ -40454,13 +40627,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 213: - return visitSwitchStatement(node); case 214: + return visitSwitchStatement(node); + case 215: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -40468,30 +40641,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); - case 149: case 150: + case 151: return visitAccessorDeclaration(node); - case 200: + case 201: return visitVariableStatement(node); - case 206: - return visitForStatement(node); case 207: + return visitForStatement(node); + case 208: return visitForInStatement(node); - case 210: + case 211: return visitBreakStatement(node); - case 209: + case 210: return visitContinueStatement(node); - case 211: + case 212: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 | 8388608)) { + else if (node.transformFlags & (4096 | 33554432)) { return ts.visitEachChild(node, visitor, context); } else { @@ -40501,21 +40674,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187: - return visitBinaryExpression(node); case 188: + return visitBinaryExpression(node); + case 189: return visitConditionalExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 170: - return visitArrayLiteralExpression(node); case 171: + return visitArrayLiteralExpression(node); + case 172: return visitObjectLiteralExpression(node); - case 173: - return visitElementAccessExpression(node); case 174: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40523,9 +40696,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40555,7 +40728,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -40628,7 +40801,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -40658,23 +40831,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 - && kind <= 68; + return kind >= 58 + && kind <= 69; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57: return 35; case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; - case 63: return 43; + case 63: return 41; case 64: return 44; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; + case 69: return 49; } } function visitRightAssociativeBinaryExpression(node) { @@ -40682,10 +40855,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172: + case 173: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173: + case 174: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -40694,7 +40867,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -40707,7 +40880,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24) { + else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } var clone_6 = ts.getMutableClone(node); @@ -40721,7 +40894,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -40737,7 +40910,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { visit(node.left); visit(node.right); } @@ -40780,7 +40953,7 @@ var ts; function visitArrayLiteralExpression(node) { return visitElements(node.elements, node.multiLine); } - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); var temp = declareLocal(); var hasAssignedTemp = false; @@ -40841,14 +41014,14 @@ var ts; function visitCallExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, false), node), node); + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node); } return ts.visitEachChild(node, visitor, context); } function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, false)), undefined, [], node), node); + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), undefined, [], node), node); } return ts.visitEachChild(node, visitor, context); } @@ -40877,35 +41050,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199: + case 200: return transformAndEmitBlock(node); - case 202: - return transformAndEmitExpressionStatement(node); case 203: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 204: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 205: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 206: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 207: + return transformAndEmitForStatement(node); + case 208: return transformAndEmitForInStatement(node); - case 209: - return transformAndEmitContinueStatement(node); case 210: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 211: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 212: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 213: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 214: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 215: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 216: + return transformAndEmitThrowStatement(node); + case 217: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41290,7 +41463,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304) !== 0; + return node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -41320,9 +41493,9 @@ 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_8 = ts.getMutableClone(name_37); + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -41431,7 +41604,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69); + context.enableSubstitution(70); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -41630,7 +41803,7 @@ var ts; } return expression; } - return ts.createNode(193); + return ts.createNode(194); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -41718,7 +41891,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -41985,6 +42158,51 @@ var ts; var _a; })(ts || (ts = {})); var ts; +(function (ts) { + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173); + context.enableSubstitution(253); + return transformSourceFile; + function transformSourceFile(node) { + return node; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, node); + } + return node; + } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.createLiteral(name, name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; (function (ts) { function transformModule(context) { var transformModuleDelegates = ts.createMap((_a = {}, @@ -42003,10 +42221,10 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableSubstitution(254); context.enableEmitNotification(256); var currentSourceFile; @@ -42023,7 +42241,7 @@ var ts; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; var updated = transformModule_1(node); ts.aggregateTransformFlags(updated); @@ -42068,7 +42286,7 @@ var ts; ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter("require"), ts.createParameter("exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) @@ -42089,7 +42307,7 @@ var ts; return body; } function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + if (exportEquals) { if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, exportEquals); ts.setEmitFlags(statement, 12288 | 49152); @@ -42104,21 +42322,21 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42194,14 +42412,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); - } + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); } return ts.singleOrMany(statements); } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { + else { return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) @@ -42210,14 +42426,12 @@ var ts; } } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } + if (node.isExportEquals) { + return undefined; } - return undefined; + var statements = []; + addExportDefault(statements, node.expression, node); + return statements; } function addExportDefault(statements, expression, location) { tryAddExportDefaultCompat(statements); @@ -42248,16 +42462,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_38 = names_1[_i]; - addExportMemberAssignments(statements, name_38); + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); } } } function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_39 = node.name; - if (ts.isIdentifier(name_39)) { - names.push(name_39); + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -42280,9 +42494,9 @@ var ts; } function visitVariableStatement(node) { var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 || - originalKind === 224 || - originalKind === 221) { + if (originalKind === 226 || + originalKind === 225 || + originalKind === 222) { if (!ts.hasModifier(node, 1)) { return node; } @@ -42328,7 +42542,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } else { return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); @@ -42338,7 +42552,8 @@ var ts; var statements = []; var name = node.name || ts.getGeneratedNameForNode(node); if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); + var isAsync = ts.hasModifier(node, 256); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); addExportMemberAssignment(statements, node); } else { @@ -42367,10 +42582,10 @@ var ts; function visitExpressionStatement(node) { var original = ts.getOriginalNode(node); var origKind = original.kind; - if (origKind === 224 || origKind === 225) { + if (origKind === 225 || origKind === 226) { return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); } - else if (origKind === 221) { + else if (origKind === 222) { var classDecl = original; if (classDecl.name) { var statements = [node]; @@ -42383,8 +42598,8 @@ var ts; function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { var statements = [node]; if (ts.hasModifier(original, 1) && - original.kind === 224 && - ts.isFirstDeclarationOfKind(original, 224)) { + original.kind === 225 && + ts.isFirstDeclarationOfKind(original, 225)) { addVarForExportedEnumOrNamespaceDeclaration(statements, original); } addExportMemberAssignments(statements, original.name); @@ -42432,12 +42647,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); + case 187: case 186: - case 185: return substituteUnaryExpression(node); } return node; @@ -42471,8 +42686,8 @@ var ts; if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { ts.setEmitFlags(node, 128); var transformedUnaryExpression = void 0; - if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); + if (node.kind === 187) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); ts.setEmitFlags(transformedUnaryExpression, 128); } var nestedExportAssignment = void 0; @@ -42504,21 +42719,11 @@ var ts; var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { - if (languageVersion >= 1) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), node); - } + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(declaration)) { - var name_40 = declaration.propertyName || declaration.name; - if (name_40.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_40.text), node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); - } + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), node); } } } @@ -42544,9 +42749,7 @@ var ts; return statement; } function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 && languageVersion === 0 - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -42593,15 +42796,14 @@ var ts; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableEmitNotification(256); var exportFunctionForFileMap = []; var currentSourceFile; @@ -42641,7 +42843,7 @@ var ts; } function transformSystemModuleWorker(node) { ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); exportFunctionForFile = ts.createUniqueName("exports"); contextObjectForFile = ts.createUniqueName("context"); exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; @@ -42650,7 +42852,7 @@ var ts; addSystemModuleBody(statements, node, dependencyGroups); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, [ + var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); @@ -42673,7 +42875,7 @@ var ts; var exportStarFunction = addExportStarIfNeeded(statements); statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) ]), true))); } function addExportStarIfNeeded(statements) { @@ -42684,7 +42886,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { var externalImport = externalImports_2[_i]; - if (externalImport.kind === 236 && externalImport.exportClause) { + if (externalImport.kind === 237 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -42702,7 +42904,7 @@ var ts; } for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { var externalImport = externalImports_3[_b]; - if (externalImport.kind !== 236) { + if (externalImport.kind !== 237) { continue; } var exportDecl = externalImport; @@ -42731,15 +42933,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 230: + case 231: if (!entry.importClause) { break; } - case 229: + case 230: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 236: + case 237: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -42755,19 +42957,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); } return ts.createArrayLiteral(setters, undefined, true); } function visitSourceElement(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); default: return visitNestedNode(node); @@ -42791,41 +42993,41 @@ var ts; } function visitNestedNodeWorker(node) { switch (node.kind) { - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 206: - return visitForStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 214: + case 215: return visitLabeledStatement(node); - case 212: - return visitWithStatement(node); case 213: + return visitWithStatement(node); + case 214: return visitSwitchStatement(node); - case 227: + case 228: return visitCaseBlock(node); case 249: return visitCaseClause(node); case 250: return visitDefaultClause(node); - case 216: + case 217: return visitTryStatement(node); case 252: return visitCatchClause(node); - case 199: + case 200: return visitBlock(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42852,20 +43054,14 @@ var ts; return undefined; } function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - return undefined; + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } + if (node.isExportEquals) { + return undefined; } - return undefined; + return createExportStatement(ts.createLiteral("default"), node.expression); } function visitVariableStatement(node) { var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || @@ -42897,16 +43093,17 @@ var ts; return ts.createAssignment(name, node.initializer); } else { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - var name_41 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); + var name_38 = node.name || ts.getGeneratedNameForNode(node); + var isAsync = ts.hasModifier(node, 256); + var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512)) { - recordExportName(name_41); + recordExportName(name_38); } ts.setOriginalNode(newNode, node); node = newNode; @@ -42916,14 +43113,14 @@ var ts; } function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_42 = getDeclarationName(originalNode); - if (originalNode.kind === 224) { - hoistVariableDeclaration(name_42); + if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { + var name_39 = getDeclarationName(originalNode); + if (originalNode.kind === 225) { + hoistVariableDeclaration(name_39); } return [ node, - createExportStatement(name_42, name_42) + createExportStatement(name_39, name_39) ]; } return node; @@ -42958,7 +43155,7 @@ var ts; ; return ts.createFor(expressions.length ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); + : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); } else { return ts.visitEachChild(node, visitNestedNode, context); @@ -42970,7 +43167,7 @@ var ts; var name = firstDeclaration.name; return ts.isIdentifier(name) ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } function visitForInStatement(node) { var initializer = node.initializer; @@ -43096,12 +43293,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); - case 185: case 186: + case 187: return substituteUnaryExpression(node); } return node; @@ -43126,14 +43323,14 @@ var ts; ts.setEmitFlags(node, 128); var left = node.left; switch (left.kind) { - case 69: + case 70: var exportDeclaration = resolver.getReferencedExportContainer(left); if (exportDeclaration) { return createExportExpression(left, node); } break; + case 172: case 171: - case 170: if (hasExportedReferenceInDestructuringPattern(left)) { return substituteDestructuring(node); } @@ -43147,9 +43344,9 @@ var ts; } function hasExportedReferenceInDestructuringPattern(node) { switch (node.kind) { - case 69: + case 70: return isExportedBinding(node); - case 171: + case 172: for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var property = _a[_i]; if (hasExportedReferenceInObjectDestructuringElement(property)) { @@ -43157,7 +43354,7 @@ var ts; } } break; - case 170: + case 171: for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { var element = _c[_b]; if (hasExportedReferenceInArrayDestructuringElement(element)) { @@ -43191,7 +43388,7 @@ var ts; function hasExportedReferenceInDestructuringElement(node) { if (ts.isBinaryExpression(node)) { var left = node.left; - return node.operatorToken.kind === 56 + return node.operatorToken.kind === 57 && isDestructuringPattern(left) && hasExportedReferenceInDestructuringPattern(left); } @@ -43211,9 +43408,9 @@ var ts; } function isDestructuringPattern(node) { var kind = node.kind; - return kind === 69 - || kind === 171 - || kind === 170; + return kind === 70 + || kind === 172 + || kind === 171; } function substituteDestructuring(node) { return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); @@ -43222,19 +43419,19 @@ var ts; var operand = node.operand; var operator = node.operator; var substitute = ts.isIdentifier(operand) && - (node.kind === 186 || - (node.kind === 185 && (operator === 41 || operator === 42))); + (node.kind === 187 || + (node.kind === 186 && (operator === 42 || operator === 43))); if (substitute) { var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); ts.setEmitFlags(expr, 128); var call = createExportExpression(operand, expr); - if (node.kind === 185) { + if (node.kind === 186) { return call; } else { - return operator === 41 + return operator === 42 ? ts.createSubtract(call, ts.createLiteral(1)) : ts.createAdd(call, ts.createLiteral(1)); } @@ -43293,12 +43490,7 @@ var ts; else { return undefined; } - if (name.originalKeywordKind && languageVersion === 0) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); } function collectDependencyGroups(externalImports) { var groupIndices = ts.createMap(); @@ -43369,17 +43561,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6Module(context) { + function transformES2015Module(context) { var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; return ts.visitEachChild(node, visitor, context); } return node; @@ -43387,115 +43576,33 @@ var ts; function visitor(node) { switch (node.kind) { case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 231: - return visitImportClause(node); - case 233: - case 232: - return visitNamedBindings(node); - case 234: - return visitImportSpecifier(node); - case 235: - return visitExportAssignment(node); + return undefined; case 236: - return visitExportDeclaration(node); - case 237: - return visitNamedExports(node); - case 238: - return visitExportSpecifier(node); + return visitExportAssignment(node); } return node; } function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? ts.createExportDeclaration(undefined, undefined, newExportClause, node.moduleSpecifier) - : undefined; - } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration(undefined, undefined, newImportClause, node.moduleSpecifier); - } - } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; - } - function visitNamedBindings(node) { - if (node.kind === 232) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; - } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + return node.isExportEquals ? undefined : node; } } - ts.transformES6Module = transformES6Module; + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -43506,11 +43613,19 @@ var ts; if (jsx === 2) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); + if (languageVersion < 4) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3) { + transformers.push(ts.transformES2016); + } if (languageVersion < 2) { - transformers.push(ts.transformES6); + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -43530,7 +43645,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -43670,7 +43785,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -43714,7 +43829,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230); + ts.Debug.assert(aliasEmitInfo.node.kind === 231); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -43745,7 +43860,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -43785,10 +43900,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218) { + if (declaration.kind === 219) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 || declaration.kind === 234 || declaration.kind === 231) { + else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -43799,7 +43914,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 230) { + if (moduleElementEmitInfo.node.kind === 231) { moduleElementEmitInfo.isVisible = true; } else { @@ -43807,12 +43922,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -43924,67 +44039,67 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 165: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: case 166: + case 167: return writeTextOfNode(currentText, type); - case 194: + case 195: return emitExpressionWithTypeArguments(type); - case 155: + case 156: return emitTypeReference(type); - case 158: + case 159: return emitTypeQuery(type); - case 160: - return emitArrayType(type); case 161: - return emitTupleType(type); + return emitArrayType(type); case 162: - return emitUnionType(type); + return emitTupleType(type); case 163: - return emitIntersectionType(type); + return emitUnionType(type); case 164: + return emitIntersectionType(type); + case 165: return emitParenType(type); - case 156: case 157: + case 158: return emitSignatureDeclarationWithJsDocComments(type); - case 159: + case 160: return emitTypeLiteral(type); - case 69: + case 70: return emitEntityName(type); - case 139: + case 140: return emitEntityName(type); - case 154: + case 155: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69) { + if (entityName.kind === 70) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 ? entityName.left : entityName.expression; - var right = entityName.kind === 139 ? entityName.right : entityName.name; + var left = entityName.kind === 140 ? entityName.left : entityName.expression; + var right = entityName.kind === 140 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 229 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 172); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44058,14 +44173,14 @@ var ts; var count = 0; while (true) { count++; - var name_43 = baseName + "_" + count; - if (!(name_43 in currentIdentifiers)) { - return name_43; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } function emitExportAssignment(node) { - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -44086,11 +44201,11 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -44104,7 +44219,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 || + else if (node.kind === 230 || (node.parent.kind === 256 && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { @@ -44116,7 +44231,7 @@ var ts; }); } else { - if (node.kind === 230) { + if (node.kind === 231) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44134,23 +44249,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220: + case 221: return writeFunctionDeclaration(node); - case 200: + case 201: return writeVariableStatement(node); - case 222: + case 223: return writeInterfaceDeclaration(node); - case 221: + case 222: return writeClassDeclaration(node); - case 223: - return writeTypeAliasDeclaration(node); case 224: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 225: + return writeEnumDeclaration(node); + case 226: return writeModuleDeclaration(node); - case 229: - return writeImportEqualsDeclaration(node); case 230: + return writeImportEqualsDeclaration(node); + case 231: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -44165,7 +44280,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 222 && !noDeclare) { + else if (node.kind !== 223 && !noDeclare) { write("declare "); } } @@ -44205,7 +44320,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -44215,7 +44330,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44238,7 +44353,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 232) { + if (node.importClause.namedBindings.kind === 233) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44255,13 +44370,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; var moduleSpecifier; - if (parent.kind === 229) { + if (parent.kind === 230) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225) { + else if (parent.kind === 226) { moduleSpecifier = parent.name; } else { @@ -44329,7 +44444,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226) { + while (node.body && node.body.kind !== 227) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -44363,7 +44478,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -44399,7 +44514,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -44409,49 +44524,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - (node.parent.parent && node.parent.parent.kind === 159)) { - ts.Debug.assert(node.parent.kind === 147 || - node.parent.kind === 146 || - node.parent.kind === 156 || + if (node.parent.kind === 157 || + node.parent.kind === 158 || + (node.parent.parent && node.parent.parent.kind === 160)) { + ts.Debug.assert(node.parent.kind === 148 || + node.parent.kind === 147 || node.parent.kind === 157 || - node.parent.kind === 151 || - node.parent.kind === 152); + node.parent.kind === 158 || + node.parent.kind === 152 || + node.parent.kind === 153); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 221: + case 222: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222: + case 223: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151: + case 152: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 148: case 147: - case 146: 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 === 221) { + else if (node.parent.parent.kind === 222) { 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 220: + case 221: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -44479,16 +44594,16 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93) { + else if (!isImplementsList && node.expression.kind === 94) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 222) { 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; @@ -44568,17 +44683,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 218 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 145 || node.kind === 144 || - (node.kind === 142 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 || node.kind === 145 || + (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 || node.kind === 144) && node.parent.kind === 159) { + if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -44591,14 +44706,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218) { + if (node.kind === 219) { 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 : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 145 || node.kind === 144) { + else if (node.kind === 146 || node.kind === 145) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44606,7 +44721,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 === 221) { + else if (node.parent.kind === 222) { 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 : @@ -44632,7 +44747,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193) { + if (element.kind !== 194) { elements.push(element); } } @@ -44698,7 +44813,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 149 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -44711,7 +44826,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 + return accessor.kind === 150 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -44720,7 +44835,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150) { + if (accessorWithTypeAnnotation.kind === 151) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -44766,17 +44881,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220) { + if (node.kind === 221) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 || node.kind === 148) { + else if (node.kind === 148 || node.kind === 149) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220) { + if (node.kind === 221) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148) { + else if (node.kind === 149) { write("constructor"); } else { @@ -44796,15 +44911,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153) { + if (node.kind === 154) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 152 || node.kind === 157) { + if (node.kind === 153 || node.kind === 158) { write("new "); } - else if (node.kind === 156) { + else if (node.kind === 157) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -44815,20 +44930,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153) { + if (node.kind === 154) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 156 || node.kind === 157; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159) { + var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -44842,23 +44957,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152: + case 153: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 151: + case 152: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153: + case 154: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 148: case 147: - case 146: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44866,7 +44981,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 === 221) { + else if (node.parent.kind === 222) { 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 : @@ -44879,7 +44994,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220: + case 221: 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 : @@ -44911,9 +45026,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - node.parent.parent.kind === 159) { + if (node.parent.kind === 157 || + node.parent.kind === 158 || + node.parent.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -44929,22 +45044,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148: + case 149: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 152: + case 153: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 151: + case 152: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44952,7 +45067,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 === 221) { + else if (node.parent.parent.kind === 222) { 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 : @@ -44964,7 +45079,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 220: + case 221: 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 : @@ -44975,12 +45090,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 167) { + if (bindingPattern.kind === 168) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168) { + else if (bindingPattern.kind === 169) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -44991,10 +45106,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193) { + if (bindingElement.kind === 194) { write(" "); } - else if (bindingElement.kind === 169) { + else if (bindingElement.kind === 170) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45004,7 +45119,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69); + ts.Debug.assert(bindingElement.name.kind === 70); if (bindingElement.dotDotDotToken) { write("..."); } @@ -45016,37 +45131,37 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220: - case 225: - case 229: - case 222: case 221: + case 226: + case 230: case 223: + case 222: case 224: + case 225: return emitModuleElement(node, isModuleElementVisible(node)); - case 200: + case 201: return emitModuleElement(node, isVariableStatementVisible(node)); - case 230: + case 231: return emitModuleElement(node, !node.importClause); - case 236: + case 237: return emitExportDeclaration(node); + case 149: case 148: case 147: - case 146: return writeFunctionDeclaration(node); - case 152: - case 151: case 153: + case 152: + case 154: return emitSignatureDeclarationWithJsDocComments(node); - case 149: case 150: + case 151: return emitAccessorDeclaration(node); + case 146: case 145: - case 144: return emitPropertyDeclaration(node); case 255: return emitEnumMemberDeclaration(node); - case 235: + case 236: return emitExportAssignment(node); case 256: return emitSourceFile(node); @@ -45066,7 +45181,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { if (isBundledEmit && !addBundledFileReference) { return; } @@ -45131,7 +45246,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { if (disabled) { @@ -45334,7 +45449,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } function getSourceMappingURL() { @@ -45398,7 +45513,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -45436,7 +45551,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 219) { + if (node.kind === 220) { declarationListContainerEnd = end; } } @@ -45512,7 +45627,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -45530,7 +45645,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { if (!writer.isAtStartOfLine()) { writer.write(" "); } @@ -45553,7 +45668,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -45636,8 +45751,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); @@ -45815,191 +45936,205 @@ var ts; function pipelineEmitInIdentifierNameContext(node) { var kind = node.kind; switch (kind) { - case 69: + case 70: return emitIdentifier(node); } } function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { - case 12: case 13: case 14: + case 15: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 74: - case 77: - case 82: - case 103: - case 110: + case 75: + case 78: + case 83: + case 104: case 111: case 112: case 113: - case 115: + case 114: + case 116: case 117: case 118: + case 119: case 120: + case 121: case 122: - case 130: + case 123: + case 124: + case 125: + case 126: + case 127: case 128: + case 129: + case 130: + case 131: case 132: case 133: + case 134: + case 135: + case 136: case 137: + case 138: + case 139: writeTokenText(kind); return; - case 139: - return emitQualifiedName(node); case 140: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 141: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 142: - return emitParameter(node); + return emitTypeParameter(node); case 143: - return emitDecorator(node); + return emitParameter(node); case 144: - return emitPropertySignature(node); + return emitDecorator(node); case 145: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 146: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 147: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 148: - return emitConstructor(node); + return emitMethodDeclaration(node); case 149: + return emitConstructor(node); case 150: - return emitAccessorDeclaration(node); case 151: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 152: - return emitConstructSignature(node); + return emitCallSignature(node); case 153: - return emitIndexSignature(node); + return emitConstructSignature(node); case 154: - return emitTypePredicate(node); + return emitIndexSignature(node); case 155: - return emitTypeReference(node); + return emitTypePredicate(node); case 156: - return emitFunctionType(node); + return emitTypeReference(node); case 157: - return emitConstructorType(node); + return emitFunctionType(node); case 158: - return emitTypeQuery(node); + return emitConstructorType(node); case 159: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 160: - return emitArrayType(node); + return emitTypeLiteral(node); case 161: - return emitTupleType(node); + return emitArrayType(node); case 162: - return emitUnionType(node); + return emitTupleType(node); case 163: - return emitIntersectionType(node); + return emitUnionType(node); case 164: + return emitIntersectionType(node); + case 165: return emitParenthesizedType(node); - case 194: + case 195: return emitExpressionWithTypeArguments(node); - case 165: - return emitThisType(node); case 166: - return emitLiteralType(node); + return emitThisType(); case 167: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 168: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 169: + return emitArrayBindingPattern(node); + case 170: return emitBindingElement(node); - case 197: - return emitTemplateSpan(node); case 198: - return emitSemicolonClassElement(node); + return emitTemplateSpan(node); case 199: - return emitBlock(node); + return emitSemicolonClassElement(); case 200: - return emitVariableStatement(node); + return emitBlock(node); case 201: - return emitEmptyStatement(node); + return emitVariableStatement(node); case 202: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 203: - return emitIfStatement(node); + return emitExpressionStatement(node); case 204: - return emitDoStatement(node); + return emitIfStatement(node); case 205: - return emitWhileStatement(node); + return emitDoStatement(node); case 206: - return emitForStatement(node); + return emitWhileStatement(node); case 207: - return emitForInStatement(node); + return emitForStatement(node); case 208: - return emitForOfStatement(node); + return emitForInStatement(node); case 209: - return emitContinueStatement(node); + return emitForOfStatement(node); case 210: - return emitBreakStatement(node); + return emitContinueStatement(node); case 211: - return emitReturnStatement(node); + return emitBreakStatement(node); case 212: - return emitWithStatement(node); + return emitReturnStatement(node); case 213: - return emitSwitchStatement(node); + return emitWithStatement(node); case 214: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 215: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 216: - return emitTryStatement(node); + return emitThrowStatement(node); case 217: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 218: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 219: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 220: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 221: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 222: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 223: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 224: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 225: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 226: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 227: + return emitModuleBlock(node); + case 228: return emitCaseBlock(node); - case 229: - return emitImportEqualsDeclaration(node); case 230: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 231: - return emitImportClause(node); + return emitImportDeclaration(node); case 232: - return emitNamespaceImport(node); + return emitImportClause(node); case 233: - return emitNamedImports(node); + return emitNamespaceImport(node); case 234: - return emitImportSpecifier(node); + return emitNamedImports(node); case 235: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 236: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 237: - return emitNamedExports(node); + return emitExportDeclaration(node); case 238: - return emitExportSpecifier(node); + return emitNamedExports(node); case 239: - return; + return emitExportSpecifier(node); case 240: + return; + case 241: return emitExternalModuleReference(node); - case 244: + case 10: return emitJsxText(node); - case 243: + case 244: return emitJsxOpeningElement(node); case 245: return emitJsxClosingElement(node); @@ -46034,73 +46169,73 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 10: case 11: + case 12: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 84: - case 93: - case 95: - case 99: - case 97: + case 85: + case 94: + case 96: + case 100: + case 98: writeTokenText(kind); return; - case 170: - return emitArrayLiteralExpression(node); case 171: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 172: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 173: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 174: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 175: - return emitNewExpression(node); + return emitCallExpression(node); case 176: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 177: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 178: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 179: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 180: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 181: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 182: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 183: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 184: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 185: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 186: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 187: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 188: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 189: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 190: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 191: - return emitSpreadElementExpression(node); + return emitYieldExpression(node); case 192: - return emitClassExpression(node); + return emitSpreadElementExpression(node); case 193: + return emitClassExpression(node); + case 194: return; - case 195: - return emitAsExpression(node); case 196: + return emitAsExpression(node); + case 197: return emitNonNullExpression(node); - case 241: - return emitJsxElement(node); case 242: + return emitJsxElement(node); + case 243: return emitJsxSelfClosingElement(node); case 288: return emitPartiallyEmittedExpression(node); @@ -46136,7 +46271,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -46206,7 +46341,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 ? "get " : "set "); + write(node.kind === 150 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -46234,7 +46369,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } function emitTypePredicate(node) { @@ -46288,7 +46423,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -46356,7 +46491,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -46371,7 +46506,7 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21)) < 0; + return text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -46388,11 +46523,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488); } function emitTaggedTemplateExpression(node) { @@ -46452,16 +46589,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 185 - && ((node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) - || (node.operator === 36 && (operand.operator === 36 || operand.operator === 42))); + return operand.kind === 186 + && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) + || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24; + var isCommaOperator = node.operatorToken.kind !== 25; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -46522,16 +46659,16 @@ var ts; emitExpression(node.expression); emit(node.literal); } - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); write(" "); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } else { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); emitBlockStatements(node); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } } function emitBlockStatements(node) { @@ -46547,7 +46684,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -46555,16 +46692,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88, node.pos, node); + var openParenPos = writeToken(89, node.pos, node); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitExpression(node.expression); - writeToken(18, node.expression.end, node); + writeToken(19, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80, node.thenStatement.end, node); - if (node.elseStatement.kind === 203) { + writeToken(81, node.thenStatement.end, node); + if (node.elseStatement.kind === 204) { write(" "); emit(node.elseStatement); } @@ -46593,9 +46730,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -46605,28 +46742,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219) { + if (node.kind === 220) { emit(node); } else { @@ -46635,17 +46772,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75, node.pos); + writeToken(76, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70, node.pos); + writeToken(71, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94, node.pos, node); + writeToken(95, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -46656,11 +46793,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96, node.pos); + var openParenPos = writeToken(97, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); write(" "); emit(node.caseBlock); } @@ -46685,11 +46822,12 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); write(";"); } function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -46716,13 +46854,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -46745,7 +46883,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { if (ts.getEmitFlags(body) & 32) { return true; } @@ -46769,14 +46907,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16, body.statements.end, body); + writeToken(17, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -46854,7 +46992,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225) { + while (body.kind === 226) { write("."); emit(body.name); body = body.body; @@ -46877,9 +47015,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15, node.pos); + writeToken(16, node.pos); emitList(node, node.clauses, 65); - writeToken(16, node.clauses.end); + writeToken(17, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -46890,7 +47028,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47010,7 +47148,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47048,11 +47186,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72, node.pos); + var openParenPos = writeToken(73, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emit(node.variableDeclaration); - writeToken(18, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -47159,7 +47297,7 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192) { + if ((languageVersion < 4) && (!awaiterEmitted && node.flags & 8192)) { writeLines(awaiterHelper); if (languageVersion < 2) { writeLines(generatorHelper); @@ -47468,7 +47606,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -47525,21 +47663,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_44 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_44)) { + var name_41 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_44; + return name_41; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_45 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_45)) { - return name_45; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -47575,19 +47713,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 69: + case 70: return makeUniqueName(getTextOfNode(node)); + case 226: case 225: - case 224: return generateNameForModuleOrEnum(node); - case 230: - case 236: + case 231: + case 237: return generateNameForImportOrExportDeclaration(node); - case 220: case 221: - case 235: + case 222: + case 236: return generateNameForExportDefault(); - case 192: + case 193: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -47657,6 +47795,68 @@ var ts; } } ts.emitFiles = emitFiles; + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -47876,10 +48076,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_46 = names_2[_i]; - var result = name_46 in cache - ? cache[name_46] - : cache[name_46] = loader(name_46, containingFile); + var name_43 = names_2[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -48110,7 +48310,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -48188,7 +48388,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -48209,14 +48409,14 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -48226,16 +48426,16 @@ var ts; return false; } switch (node.kind) { - case 229: + case 230: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235: + case 236: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221: + case 222: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -48244,29 +48444,29 @@ var ts; break; case 251: var heritageClause = node; - if (heritageClause.token === 106) { + if (heritageClause.token === 107) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222: + case 223: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 226: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: - case 220: + case 221: + case 181: + case 221: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -48274,20 +48474,20 @@ var ts; return true; } break; - case 200: + case 201: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218: + case 219: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174: case 175: + case 176: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -48295,7 +48495,7 @@ var ts; return true; } break; - case 142: + case 143: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -48311,12 +48511,12 @@ var ts; return true; } break; - case 145: + case 146: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113) { + if (modifier.kind !== 114) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -48326,14 +48526,14 @@ var ts; return true; } break; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177: + case 178: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 143: + case 144: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, 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)); } @@ -48361,18 +48561,18 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112: - case 110: + case 113: case 111: - case 128: - case 122: + case 112: + case 129: + case 123: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 113: - case 82: - case 74: - case 77: - case 115: + case 114: + case 83: + case 75: + case 78: + case 116: } } } @@ -48405,7 +48605,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -48444,9 +48644,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 231: case 230: - case 229: - case 236: + case 237: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -48458,7 +48658,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225: + case 226: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -48485,7 +48685,7 @@ var ts; } } } - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -48493,7 +48693,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -48503,13 +48703,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -48533,7 +48733,7 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -48542,16 +48742,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -48578,12 +48778,11 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -48593,10 +48792,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -48618,7 +48817,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -48629,7 +48828,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } } } @@ -48655,7 +48854,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -48675,7 +48874,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -48845,7 +49044,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -48854,10 +49053,10 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } if (emitFilesSeen.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -48865,7 +49064,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -48874,15299 +49073,17615 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var ScriptSnapshot; - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMap({ + "preserve": 1, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + }, + { + name: "reactNamespace", + type: "string", + description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + }, + { + name: "listFiles", + type: "boolean", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMap({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMap({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_in_the_given_directory, + paramType: ts.Diagnostics.DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMap({ + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2, + "es2016": 3, + "es2017": 4, + }), + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, + paramType: ts.Diagnostics.VERSION, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMap({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { - return undefined; - }; - return StringScriptSnapshot; - }()); - function fromString(text) { - return new StringScriptSnapshot(text); + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + } + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMap({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.ts", + "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", + "es2016.array.include": "lib.es2016.array.include.d.ts", + "es2017.object": "lib.es2017.object.d.ts", + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } - ScriptSnapshot.fromString = fromString; - })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); - var TextChange = (function () { - function TextChange() { + ]; + ts.typingOptionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" + } + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" + } } - return TextChange; - }()); - ts.TextChange = TextChange; - var HighlightSpanKind; - (function (HighlightSpanKind) { - HighlightSpanKind.none = "none"; - HighlightSpanKind.definition = "definition"; - HighlightSpanKind.reference = "reference"; - HighlightSpanKind.writtenReference = "writtenReference"; - })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); - (function (IndentStyle) { - IndentStyle[IndentStyle["None"] = 0] = "None"; - IndentStyle[IndentStyle["Block"] = 1] = "Block"; - IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; - (function (SymbolDisplayPartKind) { - SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; - SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; - SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; - SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; - SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; - SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; - SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; - SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; - SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; - (function (TokenClass) { - TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; - TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; - TokenClass[TokenClass["Operator"] = 2] = "Operator"; - TokenClass[TokenClass["Comment"] = 3] = "Comment"; - TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; - TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; - TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; - TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; - TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; - var ScriptElementKind; - (function (ScriptElementKind) { - ScriptElementKind.unknown = ""; - ScriptElementKind.warning = "warning"; - ScriptElementKind.keyword = "keyword"; - ScriptElementKind.scriptElement = "script"; - ScriptElementKind.moduleElement = "module"; - ScriptElementKind.classElement = "class"; - ScriptElementKind.localClassElement = "local class"; - ScriptElementKind.interfaceElement = "interface"; - ScriptElementKind.typeElement = "type"; - ScriptElementKind.enumElement = "enum"; - ScriptElementKind.enumMemberElement = "const"; - ScriptElementKind.variableElement = "var"; - ScriptElementKind.localVariableElement = "local var"; - ScriptElementKind.functionElement = "function"; - ScriptElementKind.localFunctionElement = "local function"; - ScriptElementKind.memberFunctionElement = "method"; - ScriptElementKind.memberGetAccessorElement = "getter"; - ScriptElementKind.memberSetAccessorElement = "setter"; - ScriptElementKind.memberVariableElement = "property"; - ScriptElementKind.constructorImplementationElement = "constructor"; - ScriptElementKind.callSignatureElement = "call"; - ScriptElementKind.indexSignatureElement = "index"; - ScriptElementKind.constructSignatureElement = "construct"; - ScriptElementKind.parameterElement = "parameter"; - ScriptElementKind.typeParameterElement = "type parameter"; - ScriptElementKind.primitiveType = "primitive type"; - ScriptElementKind.label = "label"; - ScriptElementKind.alias = "alias"; - ScriptElementKind.constElement = "const"; - ScriptElementKind.letElement = "let"; - ScriptElementKind.directory = "directory"; - ScriptElementKind.externalModuleName = "external module name"; - })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); - var ScriptElementKindModifier; - (function (ScriptElementKindModifier) { - ScriptElementKindModifier.none = ""; - ScriptElementKindModifier.publicMemberModifier = "public"; - ScriptElementKindModifier.privateMemberModifier = "private"; - ScriptElementKindModifier.protectedMemberModifier = "protected"; - ScriptElementKindModifier.exportedModifier = "export"; - ScriptElementKindModifier.ambientModifier = "declare"; - ScriptElementKindModifier.staticModifier = "static"; - ScriptElementKindModifier.abstractModifier = "abstract"; - })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames = (function () { - function ClassificationTypeNames() { - } - return ClassificationTypeNames; - }()); - ClassificationTypeNames.comment = "comment"; - ClassificationTypeNames.identifier = "identifier"; - ClassificationTypeNames.keyword = "keyword"; - ClassificationTypeNames.numericLiteral = "number"; - ClassificationTypeNames.operator = "operator"; - ClassificationTypeNames.stringLiteral = "string"; - ClassificationTypeNames.whiteSpace = "whitespace"; - ClassificationTypeNames.text = "text"; - ClassificationTypeNames.punctuation = "punctuation"; - ClassificationTypeNames.className = "class name"; - ClassificationTypeNames.enumName = "enum name"; - ClassificationTypeNames.interfaceName = "interface name"; - ClassificationTypeNames.moduleName = "module name"; - ClassificationTypeNames.typeParameterName = "type parameter name"; - ClassificationTypeNames.typeAliasName = "type alias name"; - ClassificationTypeNames.parameterName = "parameter name"; - ClassificationTypeNames.docCommentTagName = "doc comment tag name"; - ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; - ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; - ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; - ClassificationTypeNames.jsxAttribute = "jsx attribute"; - ClassificationTypeNames.jsxText = "jsx text"; - ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; - ts.ClassificationTypeNames = ClassificationTypeNames; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.scanner = ts.createScanner(2, true); - ts.emptyArray = []; - function getMeaningFromDeclaration(node) { - switch (node.kind) { - case 142: - case 218: - case 169: - case 145: - case 144: - case 253: - case 254: - case 255: - case 147: - case 146: - case 148: - case 149: - case 150: - case 220: - case 179: - case 180: - case 252: - return 1; - case 141: - case 222: - case 223: - case 159: - return 2; - case 221: - case 224: - return 1 | 2; - case 225: - if (ts.isAmbientModule(node)) { - return 4 | 1; - } - else if (ts.getModuleInstanceState(node) === 1) { - return 4 | 1; - } - else { - return 4; - } - case 233: - case 234: - case 229: - case 230: - case 235: - case 236: - return 1 | 2 | 4; - case 256: - return 4 | 1; + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; } - return 1 | 2 | 4; + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; + } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; } - ts.getMeaningFromDeclaration = getMeaningFromDeclaration; - function getMeaningFromLocation(node) { - if (node.parent.kind === 235) { - return 1 | 2 | 4; - } - else if (isInRightSideOfImport(node)) { - return getMeaningFromRightHandSideOfImportEquals(node); - } - else if (ts.isDeclarationName(node)) { - return getMeaningFromDeclaration(node.parent); - } - else if (isTypeReference(node)) { - return 2; - } - else if (isNamespaceReference(node)) { - return 4; + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + var key = trimString((value || "")).toLowerCase(); + var map = opt.type; + if (key in map) { + return map[key]; } else { - return 1; + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); } } - ts.getMeaningFromLocation = getMeaningFromLocation; - function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69); - if (node.parent.kind === 139 && - node.parent.right === node && - node.parent.parent.kind === 229) { - return 1 | 2 | 4; + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; } - return 4; - } - function isInRightSideOfImport(node) { - while (node.parent.kind === 139) { - node = node.parent; + if (value === "") { + return []; } - return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; - } - function isNamespaceReference(node) { - return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); - } - function isQualifiedNameNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 139) { - while (root.parent && root.parent.kind === 139) { - root = root.parent; - } - isLastClause = root.right === node; + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); } - return root.parent.kind === 155 && !isLastClause; } - function isPropertyAccessNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 172) { - while (root.parent && root.parent.kind === 172) { - root = root.parent; + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + if (s in shortOptionNames) { + s = shortOptionNames[s]; + } + if (s in optionNameMap) { + var opt = optionNameMap[s]; + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + fileNames.push(s); + } } - isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 && root.parent.parent.kind === 251) { - var decl = root.parent.parent.parent; - return (decl.kind === 221 && root.parent.parent.token === 106) || - (decl.kind === 222 && root.parent.parent.token === 83); + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); + } + } + else { + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); } - return false; } - function isTypeReference(node) { - if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); } - return node.parent.kind === 155 || - (node.parent.kind === 194 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 && !ts.isPartOfExpression(node)) || - node.kind === 165; - } - function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174); - } - ts.isCallExpressionTarget = isCallExpressionTarget; - function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175); - } - ts.isNewExpressionTarget = isNewExpressionTarget; - function isCallOrNewExpressionTarget(node, kind) { - var target = climbPastPropertyAccess(node); - return target && target.parent && target.parent.kind === kind && target.parent.expression === target; - } - function climbPastPropertyAccess(node) { - return isRightSideOfPropertyAccess(node) ? node.parent : node; - } - ts.climbPastPropertyAccess = climbPastPropertyAccess; - function getTargetLabel(referenceNode, labelName) { - while (referenceNode) { - if (referenceNode.kind === 214 && referenceNode.label.text === labelName) { - return referenceNode.label; - } - referenceNode = referenceNode.parent; + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } - return undefined; - } - ts.getTargetLabel = getTargetLabel; - function isJumpStatementTarget(node) { - return node.kind === 69 && - (node.parent.kind === 210 || node.parent.kind === 209) && - node.parent.label === node; - } - ts.isJumpStatementTarget = isJumpStatementTarget; - function isLabelOfLabeledStatement(node) { - return node.kind === 69 && - node.parent.kind === 214 && - node.parent.label === node; - } - function isLabelName(node) { - return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); - } - ts.isLabelName = isLabelName; - function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 && node.parent.right === node; - } - ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; - function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 && node.parent.name === node; - } - ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; - function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 && node.parent.name === node; + return parseConfigFileTextToJson(fileName, text); } - ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; - function isNameOfFunctionDeclaration(node) { - return node.kind === 69 && - ts.isFunctionLike(node.parent) && node.parent.name === node; + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } } - ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 || node.kind === 8) { - switch (node.parent.kind) { - case 145: - case 144: - case 253: - case 255: - case 147: - case 146: - case 149: - case 150: - case 225: - return node.parent.name === node; - case 173: - return node.parent.argumentExpression === node; - case 140: - return true; + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; } } - return false; - } - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; - function isExpressionOfExternalModuleImportEqualsDeclaration(node) { - return ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && - ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node; - } - ts.isExpressionOfExternalModuleImportEqualsDeclaration = isExpressionOfExternalModuleImportEqualsDeclaration; - function isInsideComment(sourceFile, token, position) { - return position <= token.getStart(sourceFile) && - (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || - isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); - function isInsideCommentRange(comments) { - return ts.forEach(comments, function (comment) { - if (comment.pos < position && position < comment.end) { - return true; + function getNameOfCompilerOptionValue(value, customTypeMap) { + for (var key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; } - else if (position === comment.end) { - var text = sourceFile.text; - var width = comment.end - comment.pos; - if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47) { - return true; - } - else { - return !(text.charCodeAt(comment.end - 1) === 47 && - text.charCodeAt(comment.end - 2) === 42); + } + return undefined; + } + function serializeCompilerOptions(options) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { + switch (name_44) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name_44] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name_44] = convertedValue; + } + else { + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; } } - return false; - }); + } + return result; } } - ts.isInsideComment = isInsideComment; - function getContainerNode(node) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 256: - case 147: - case 146: - case 220: - case 179: - case 149: - case 150: - case 221: - case 222: - case 224: - case 225: - return node; + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; } } + return output; } - ts.getContainerNode = getContainerNode; - function getNodeKind(node) { - switch (node.kind) { - case 256: - return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225: - return ts.ScriptElementKind.moduleElement; - case 221: - case 192: - return ts.ScriptElementKind.classElement; - case 222: return ts.ScriptElementKind.interfaceElement; - case 223: return ts.ScriptElementKind.typeElement; - case 224: return ts.ScriptElementKind.enumElement; - case 218: - return getKindOfVariableDeclaration(node); - case 169: - return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 180: - case 220: - case 179: - return ts.ScriptElementKind.functionElement; - case 149: return ts.ScriptElementKind.memberGetAccessorElement; - case 150: return ts.ScriptElementKind.memberSetAccessorElement; - case 147: - case 146: - return ts.ScriptElementKind.memberFunctionElement; - case 145: - case 144: - return ts.ScriptElementKind.memberVariableElement; - case 153: return ts.ScriptElementKind.indexSignatureElement; - case 152: return ts.ScriptElementKind.constructSignatureElement; - case 151: return ts.ScriptElementKind.callSignatureElement; - case 148: return ts.ScriptElementKind.constructorImplementationElement; - case 141: return ts.ScriptElementKind.typeParameterElement; - case 255: return ts.ScriptElementKind.enumMemberElement; - case 142: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229: - case 234: - case 231: - case 238: - case 232: - return ts.ScriptElementKind.alias; - case 279: - return ts.ScriptElementKind.typeElement; - default: - return ts.ScriptElementKind.unknown; - } - function getKindOfVariableDeclaration(v) { - return ts.isConst(v) - ? ts.ScriptElementKind.constElement - : ts.isLet(v) - ? ts.ScriptElementKind.letElement - : ts.ScriptElementKind.variableElement; - } - } - ts.getNodeKind = getNodeKind; - function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 ? node.parent : node; - var type = typeChecker.getTypeAtLocation(searchNode); - if (type && type.flags & 32) { - return type; + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + var errors = []; + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typingOptions: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; } - return undefined; - } - ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; - function isThis(node) { - switch (node.kind) { - case 97: - return true; - case 69: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142; - default: - return false; + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); } - } - ts.isThis = isThis; - var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= range.end; - } - ts.startEndContainsRange = startEndContainsRange; - function rangeContainsStartEnd(range, start, end) { - return range.pos <= start && range.end >= end; - } - ts.rangeContainsStartEnd = rangeContainsStartEnd; - function rangeOverlapsWithStartEnd(r1, start, end) { - return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); - } - ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; - function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { - var start = Math.max(start1, start2); - var end = Math.min(end1, end2); - return start < end; - } - ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; - function positionBelongsToNode(candidate, position, sourceFile) { - return candidate.end > position || !isCompletedNode(candidate, sourceFile); - } - ts.positionBelongsToNode = positionBelongsToNode; - function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { - return false; + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typingOptions: typingOptions, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); + } + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; } - switch (n.kind) { - case 221: - case 222: - case 224: - case 171: - case 167: - case 159: - case 199: - case 226: - case 227: - case 233: - case 237: - return nodeEndsWith(n, 16, sourceFile); - case 252: - return isCompletedNode(n.block, sourceFile); - case 175: - if (!n.arguments) { - return true; + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; } - case 174: - case 178: - case 164: - return nodeEndsWith(n, 18, sourceFile); - case 156: - case 157: - return isCompletedNode(n.type, sourceFile); - case 148: - case 149: - case 150: - case 220: - case 179: - case 147: - case 146: - case 152: - case 151: - case 180: - if (n.body) { - return isCompletedNode(n.body, sourceFile); + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); } - if (n.type) { - return isCompletedNode(n.type, sourceFile); + } + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; } - return hasChildOfKind(n, 18, sourceFile); - case 225: - return n.body && isCompletedNode(n.body, sourceFile); - case 203: - if (n.elseStatement) { - return isCompletedNode(n.elseStatement, sourceFile); + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); } - return isCompletedNode(n.thenStatement, sourceFile); - case 202: - return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23); - case 170: - case 168: - case 173: - case 140: - case 161: - return nodeEndsWith(n, 20, sourceFile); - case 153: - if (n.type) { - return isCompletedNode(n.type, sourceFile); + } + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; } - return hasChildOfKind(n, 20, sourceFile); - case 249: - case 250: - return false; - case 206: - case 207: - case 208: - case 205: - return isCompletedNode(n.statement, sourceFile); - case 204: - var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); - if (hasWhileKeyword) { - return nodeEndsWith(n, 18, sourceFile); + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); } - return isCompletedNode(n.statement, sourceFile); - case 158: - return isCompletedNode(n.exprName, sourceFile); - case 182: - case 181: - case 183: - case 190: - case 191: - var unaryWordExpression = n; - return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176: - return isCompletedNode(n.template, sourceFile); - case 189: - var lastSpan = ts.lastOrUndefined(n.templateSpans); - return isCompletedNode(lastSpan, sourceFile); - case 197: - return ts.nodeIsPresent(n.literal); - case 236: - case 230: - return ts.nodeIsPresent(n.moduleSpecifier); - case 185: - return isCompletedNode(n.operand, sourceFile); - case 187: - return isCompletedNode(n.right, sourceFile); - case 188: - return isCompletedNode(n.whenFalse, sourceFile); - default: - return true; - } - } - ts.isCompletedNode = isCompletedNode; - function nodeEndsWith(n, expectedLastToken, sourceFile) { - var children = n.getChildren(sourceFile); - if (children.length) { - var last = ts.lastOrUndefined(children); - if (last.kind === expectedLastToken) { - return true; } - else if (last.kind === 23 && children.length !== 1) { - return children[children.length - 2].kind === expectedLastToken; + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + else { + excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; } + return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); } - return false; + var _b; } - function findListItemInfo(node) { - var list = findContainingList(node); - if (!list) { - return undefined; + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; } - var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); - return { - listItemIndex: listItemIndex, - list: list - }; - } - ts.findListItemInfo = findListItemInfo; - function hasChildOfKind(n, kind, sourceFile) { - return !!findChildOfKind(n, kind, sourceFile); - } - ts.hasChildOfKind = hasChildOfKind; - function findChildOfKind(n, kind, sourceFile) { - return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); - } - ts.findChildOfKind = findChildOfKind; - function findContainingList(node) { - var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 286 && c.pos <= node.pos && c.end >= node.end) { - return c; - } - }); - ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); - return syntaxList; + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; } - ts.findContainingList = findContainingList; - function getTouchingWord(sourceFile, position, includeJsDocComment) { - if (includeJsDocComment === void 0) { includeJsDocComment = false; } - return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }, includeJsDocComment); + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; } - ts.getTouchingWord = getTouchingWord; - function getTouchingPropertyName(sourceFile, position, includeJsDocComment) { - if (includeJsDocComment === void 0) { includeJsDocComment = false; } - return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }, includeJsDocComment); + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; } - ts.getTouchingPropertyName = getTouchingPropertyName; - function getTouchingToken(sourceFile, position, includeItemAtEndPosition, includeJsDocComment) { - if (includeJsDocComment === void 0) { includeJsDocComment = false; } - return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition, includeJsDocComment); + ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; } - ts.getTouchingToken = getTouchingToken; - function getTokenAtPosition(sourceFile, position, includeJsDocComment) { - if (includeJsDocComment === void 0) { includeJsDocComment = false; } - return getTokenAtPositionWorker(sourceFile, position, true, undefined, includeJsDocComment); + function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { enableAutoDiscovery: true, include: [], exclude: [] } + : { enableAutoDiscovery: false, include: [], exclude: [] }; + convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); + return options; } - ts.getTokenAtPosition = getTokenAtPosition; - function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition, includeJsDocComment) { - if (includeJsDocComment === void 0) { includeJsDocComment = false; } - var current = sourceFile; - outer: while (true) { - if (isToken(current)) { - return current; - } - if (includeJsDocComment) { - var jsDocChildren = ts.filter(current.getChildren(), ts.isJSDocNode); - for (var _i = 0, jsDocChildren_1 = jsDocChildren; _i < jsDocChildren_1.length; _i++) { - var jsDocChild = jsDocChildren_1[_i]; - var start = allowPositionInLeadingTrivia ? jsDocChild.getFullStart() : jsDocChild.getStart(sourceFile, includeJsDocComment); - if (start <= position) { - var end = jsDocChild.getEnd(); - if (position < end || (position === end && jsDocChild.kind === 1)) { - current = jsDocChild; - continue outer; - } - else if (includeItemAtEndPosition && end === position) { - var previousToken = findPrecedingToken(position, sourceFile, jsDocChild); - if (previousToken && includeItemAtEndPosition(previousToken)) { - return previousToken; - } - } - } - } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (id in optionNameMap) { + var opt = optionNameMap[id]; + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } - for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { - var child = current.getChildAt(i); - if (ts.isJSDocNode(child)) { - continue; - } - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); - if (start <= position) { - var end = child.getEnd(); - if (position < end || (position === end && child.kind === 1)) { - current = child; - continue outer; - } - else if (includeItemAtEndPosition && end === position) { - var previousToken = findPrecedingToken(position, sourceFile, child); - if (previousToken && includeItemAtEndPosition(previousToken)) { - return previousToken; - } - } - } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); } - return current; } } - function findTokenOnLeftOfPosition(file, position) { - var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { - return tokenAtPosition; + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); } - return findPrecedingToken(position, file); - } - ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; - function findNextToken(previousToken, parent) { - return find(parent); - function find(n) { - if (isToken(n) && n.pos === previousToken.end) { - return n; + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); } - var children = n.getChildren(); - for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { - var child = children_2[_i]; - var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || - (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child)) { - return find(child); + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } } - return undefined; + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); } } - ts.findNextToken = findNextToken; - function findPrecedingToken(position, sourceFile, startNode) { - return find(startNode || sourceFile); - function findRightmostToken(n) { - if (isToken(n) || n.kind === 244) { - return n; - } - var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); - return candidate && findRightmostToken(candidate); - } - function find(n) { - if (isToken(n) || n.kind === 244) { - return n; - } - var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; i++) { - var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 244)) { - var start = child.getStart(sourceFile); - var lookInPreviousChild = (start >= position) || - (child.kind === 244 && start === child.end); - if (lookInPreviousChild) { - var candidate = findRightmostChildNodeWithTokens(children, i); - return candidate && findRightmostToken(candidate); - } - else { - return find(child); - } - } - } - ts.Debug.assert(startNode !== undefined || n.kind === 256); - if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); - return candidate && findRightmostToken(candidate); - } - } - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { - for (var i = exclusiveStartPosition - 1; i >= 0; i--) { - if (nodeHasTokens(children[i])) { - return children[i]; - } - } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + if (key in opt.type) { + return opt.type[key]; } - } - ts.findPrecedingToken = findPrecedingToken; - function isInString(sourceFile, position) { - var previousToken = findPrecedingToken(position, sourceFile); - if (previousToken && previousToken.kind === 9) { - var start = previousToken.getStart(); - var end = previousToken.getEnd(); - if (start < position && position < end) { - return true; - } - if (position === end) { - return !!previousToken.isUnterminated; - } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); } - return false; - } - ts.isInString = isInString; - function isInComment(sourceFile, position) { - return isInCommentHelper(sourceFile, position, undefined); } - ts.isInComment = isInComment; - function isInsideJsxElementOrAttribute(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - if (!token) { - return false; - } - if (token.kind === 244) { - return true; - } - if (token.kind === 25 && token.parent.kind === 244) { - return true; - } - if (token.kind === 25 && token.parent.kind === 248) { - return true; - } - if (token && token.kind === 16 && token.parent.kind === 248) { - return true; - } - if (token.kind === 25 && token.parent.kind === 245) { - return true; - } - return false; + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; - function isInTemplateString(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); } - ts.isInTemplateString = isInTemplateString; - function isInCommentHelper(sourceFile, position, predicate) { - var token = getTokenAtPosition(sourceFile, position); - if (token && position <= token.getStart(sourceFile)) { - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return predicate ? - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end) && - predicate(c); }) : - ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end); }); + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); } - return false; - } - ts.isInCommentHelper = isInCommentHelper; - function hasDocComment(sourceFile, position) { - var token = getTokenAtPosition(sourceFile, position); - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - return ts.forEach(commentRanges, jsDocPrefix); - function jsDocPrefix(c) { - var text = sourceFile.text; - return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; + if (exclude) { + exclude = validateSpecs(exclude, errors, true); } - } - ts.hasDocComment = hasDocComment; - function getJsDocTagAtPosition(sourceFile, position) { - var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { - switch (node.kind) { - case 102: - case 108: - case 74: - node = node.parent === undefined ? undefined : node.parent.parent; - break; - default: - node = node.parent; - break; + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap[keyMapper(file)] = file; } } - if (node) { - if (node.jsDocComments) { - for (var _i = 0, _a = node.jsDocComments; _i < _a.length; _i++) { - var jsDocComment = _a[_i]; - if (jsDocComment.tags) { - for (var _b = 0, _c = jsDocComment.tags; _b < _c.length; _b++) { - var tag = _c[_b]; - if (tag.pos <= position && position <= tag.end) { - return tag; - } - } - } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { + wildcardFileMap[key] = file; } } } - return undefined; - } - ts.getJsDocTagAtPosition = getJsDocTagAtPosition; - function nodeHasTokens(n) { - return n.getWidth() !== 0; - } - function getNodeModifiers(node) { - var flags = ts.getCombinedModifierFlags(node); - var result = []; - if (flags & 8) - result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 16) - result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 4) - result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 32) - result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 128) - result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1) - result.push(ts.ScriptElementKindModifier.exportedModifier); - if (ts.isInAmbientContext(node)) - result.push(ts.ScriptElementKindModifier.ambientModifier); - return result.length > 0 ? result.join(",") : ts.ScriptElementKindModifier.none; - } - ts.getNodeModifiers = getNodeModifiers; - function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 || node.kind === 174) { - return node.typeArguments; - } - if (ts.isFunctionLike(node) || node.kind === 221 || node.kind === 222) { - return node.typeParameters; - } - return undefined; - } - ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 && n.kind <= 138; - } - ts.isToken = isToken; - function isWord(kind) { - return kind === 69 || ts.isKeyword(kind); - } - ts.isWord = isWord; - function isPropertyName(kind) { - return kind === 9 || kind === 8 || isWord(kind); - } - function isComment(kind) { - return kind === 2 || kind === 3; - } - ts.isComment = isComment; - function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 9 - || kind === 10 - || ts.isTemplateLiteralKind(kind)) { - return true; - } - return false; - } - ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; - function isPunctuation(kind) { - return 15 <= kind && kind <= 68; - } - ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { - return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); + var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); + wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; } - ts.isInsideTemplateLiteral = isInsideTemplateLiteral; - function isAccessibilityModifier(kind) { - switch (kind) { - case 112: - case 110: - case 111: - return true; + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { + var spec = specs_2[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else { + validSpecs.push(spec); + } } - return false; + return validSpecs; } - ts.isAccessibilityModifier = isAccessibilityModifier; - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) { - return false; + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = ts.createMap(); + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var name_45 = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(name_45)) { + continue; + } + var match = wildcardDirectoryPattern.exec(name_45); + if (match) { + var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); + var flags = watchRecursivePattern.test(name_45) ? 1 : 0; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } + } } } - else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) { - return false; + for (var key in wildcardDirectories) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } } } } - return true; + return wildcardDirectories; } - ts.compareDataObjects = compareDataObjects; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 || - node.kind === 171) { - if (node.parent.kind === 187 && - node.parent.left === node && - node.parent.operatorToken.kind === 56) { - return true; - } - if (node.parent.kind === 208 && - node.parent.initializer === node) { - return true; - } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 ? node.parent.parent : node.parent)) { + function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { return true; } } return false; } - ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; - function hasTrailingDirectorySeparator(path) { - var lastCharacter = path.charAt(path.length - 1); - return lastCharacter === "/" || lastCharacter === "\\"; - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - function isInReferenceComment(sourceFile, position) { - return isInCommentHelper(sourceFile, position, isReferenceComment); - function isReferenceComment(c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return tripleSlashDirectivePrefixRegex.test(commentText); + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + delete wildcardFiles[lowerPriorityPath]; } } - ts.isInReferenceComment = isInReferenceComment; - function isInNonReferenceComment(sourceFile, position) { - return isInCommentHelper(sourceFile, position, isNonReferenceComment); - function isNonReferenceComment(c) { - var commentText = sourceFile.text.substring(c.pos, c.end); - return !tripleSlashDirectivePrefixRegex.test(commentText); - } + function addFileToOutput(output, file) { + output.push(file); + return output; + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); } - ts.isInNonReferenceComment = isInNonReferenceComment; })(ts || (ts = {})); +var ts; (function (ts) { - function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142; - } - ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; - var displayPartWriter = getDisplayPartWriter(); - function getDisplayPartWriter() { - var displayParts; - var lineStart; - var indent; - resetWriter(); - return { - displayParts: function () { return displayParts; }, - writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, - writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, - writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, - writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, - writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, - writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, - writeSymbol: writeSymbol, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - clear: resetWriter, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - function writeIndent() { - if (lineStart) { - var indentString = ts.getIndentString(indent); - if (indentString) { - displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); - } - lineStart = false; + var ScriptSnapshot; + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + StringScriptSnapshot.prototype.getChangeRange = function () { + return undefined; + }; + return StringScriptSnapshot; + }()); + function fromString(text) { + return new StringScriptSnapshot(text); } - function writeKind(text, kind) { - writeIndent(); - displayParts.push(displayPart(text, kind)); - } - function writeSymbol(text, symbol) { - writeIndent(); - displayParts.push(symbolPart(text, symbol)); + ScriptSnapshot.fromString = fromString; + })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); + var TextChange = (function () { + function TextChange() { } - function writeLine() { - displayParts.push(lineBreakPart()); - lineStart = true; + return TextChange; + }()); + ts.TextChange = TextChange; + var HighlightSpanKind; + (function (HighlightSpanKind) { + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; + })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + (function (IndentStyle) { + IndentStyle[IndentStyle["None"] = 0] = "None"; + IndentStyle[IndentStyle["Block"] = 1] = "Block"; + IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; + })(ts.IndentStyle || (ts.IndentStyle = {})); + var IndentStyle = ts.IndentStyle; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(ts.OutputFileType || (ts.OutputFileType = {})); + var OutputFileType = ts.OutputFileType; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(ts.EndOfLineState || (ts.EndOfLineState = {})); + var EndOfLineState = ts.EndOfLineState; + (function (TokenClass) { + TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; + TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; + TokenClass[TokenClass["Operator"] = 2] = "Operator"; + TokenClass[TokenClass["Comment"] = 3] = "Comment"; + TokenClass[TokenClass["Whitespace"] = 4] = "Whitespace"; + TokenClass[TokenClass["Identifier"] = 5] = "Identifier"; + TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; + TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; + TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; + })(ts.TokenClass || (ts.TokenClass = {})); + var TokenClass = ts.TokenClass; + var ScriptElementKind; + (function (ScriptElementKind) { + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + ScriptElementKind.keyword = "keyword"; + ScriptElementKind.scriptElement = "script"; + ScriptElementKind.moduleElement = "module"; + ScriptElementKind.classElement = "class"; + ScriptElementKind.localClassElement = "local class"; + ScriptElementKind.interfaceElement = "interface"; + ScriptElementKind.typeElement = "type"; + ScriptElementKind.enumElement = "enum"; + ScriptElementKind.enumMemberElement = "const"; + ScriptElementKind.variableElement = "var"; + ScriptElementKind.localVariableElement = "local var"; + ScriptElementKind.functionElement = "function"; + ScriptElementKind.localFunctionElement = "local function"; + ScriptElementKind.memberFunctionElement = "method"; + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + ScriptElementKind.memberVariableElement = "property"; + ScriptElementKind.constructorImplementationElement = "constructor"; + ScriptElementKind.callSignatureElement = "call"; + ScriptElementKind.indexSignatureElement = "index"; + ScriptElementKind.constructSignatureElement = "construct"; + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + ScriptElementKind.directory = "directory"; + ScriptElementKind.externalModuleName = "external module name"; + })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); + var ScriptElementKindModifier; + (function (ScriptElementKindModifier) { + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; + })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { } - function resetWriter() { - displayParts = []; - lineStart = true; - indent = 0; + return ClassificationTypeNames; + }()); + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; + ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; + ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; + ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.scanner = ts.createScanner(4, true); + ts.emptyArray = []; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; + })(ts.SemanticMeaning || (ts.SemanticMeaning = {})); + var SemanticMeaning = ts.SemanticMeaning; + function getMeaningFromDeclaration(node) { + switch (node.kind) { + case 143: + case 219: + case 170: + case 146: + case 145: + case 253: + case 254: + case 255: + case 148: + case 147: + case 149: + case 150: + case 151: + case 221: + case 180: + case 181: + case 252: + return 1; + case 142: + case 223: + case 224: + case 160: + return 2; + case 222: + case 225: + return 1 | 2; + case 226: + if (ts.isAmbientModule(node)) { + return 4 | 1; + } + else if (ts.getModuleInstanceState(node) === 1) { + return 4 | 1; + } + else { + return 4; + } + case 234: + case 235: + case 230: + case 231: + case 236: + case 237: + return 1 | 2 | 4; + case 256: + return 4 | 1; } + return 1 | 2 | 4; } - function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); - function displayPartKind(symbol) { - var flags = symbol.flags; - if (flags & 3) { - return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; - } - else if (flags & 4) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 32768) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 65536) { - return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 8) { - return ts.SymbolDisplayPartKind.enumMemberName; - } - else if (flags & 16) { - return ts.SymbolDisplayPartKind.functionName; - } - else if (flags & 32) { - return ts.SymbolDisplayPartKind.className; - } - else if (flags & 64) { - return ts.SymbolDisplayPartKind.interfaceName; - } - else if (flags & 384) { - return ts.SymbolDisplayPartKind.enumName; - } - else if (flags & 1536) { - return ts.SymbolDisplayPartKind.moduleName; - } - else if (flags & 8192) { - return ts.SymbolDisplayPartKind.methodName; - } - else if (flags & 262144) { - return ts.SymbolDisplayPartKind.typeParameterName; - } - else if (flags & 524288) { - return ts.SymbolDisplayPartKind.aliasName; + ts.getMeaningFromDeclaration = getMeaningFromDeclaration; + function getMeaningFromLocation(node) { + if (node.parent.kind === 236) { + return 1 | 2 | 4; + } + else if (isInRightSideOfImport(node)) { + return getMeaningFromRightHandSideOfImportEquals(node); + } + else if (ts.isDeclarationName(node)) { + return getMeaningFromDeclaration(node.parent); + } + else if (isTypeReference(node)) { + return 2; + } + else if (isNamespaceReference(node)) { + return 4; + } + else { + return 1; + } + } + ts.getMeaningFromLocation = getMeaningFromLocation; + function getMeaningFromRightHandSideOfImportEquals(node) { + ts.Debug.assert(node.kind === 70); + if (node.parent.kind === 140 && + node.parent.right === node && + node.parent.parent.kind === 230) { + return 1 | 2 | 4; + } + return 4; + } + function isInRightSideOfImport(node) { + while (node.parent.kind === 140) { + node = node.parent; + } + return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; + } + function isNamespaceReference(node) { + return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); + } + function isQualifiedNameNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 140) { + while (root.parent && root.parent.kind === 140) { + root = root.parent; } - else if (flags & 8388608) { - return ts.SymbolDisplayPartKind.aliasName; + isLastClause = root.right === node; + } + return root.parent.kind === 156 && !isLastClause; + } + function isPropertyAccessNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 173) { + while (root.parent && root.parent.kind === 173) { + root = root.parent; } - return ts.SymbolDisplayPartKind.text; + isLastClause = root.name === node; + } + if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { + var decl = root.parent.parent.parent; + return (decl.kind === 222 && root.parent.parent.token === 107) || + (decl.kind === 223 && root.parent.parent.token === 84); } + return false; } - ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { - return { - text: text, - kind: ts.SymbolDisplayPartKind[kind] - }; + function isTypeReference(node) { + if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + return node.parent.kind === 156 || + (node.parent.kind === 195 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 && !ts.isPartOfExpression(node)) || + node.kind === 166; } - ts.displayPart = displayPart; - function spacePart() { - return displayPart(" ", ts.SymbolDisplayPartKind.space); + function isCallExpressionTarget(node) { + return isCallOrNewExpressionTarget(node, 175); } - ts.spacePart = spacePart; - function keywordPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); + ts.isCallExpressionTarget = isCallExpressionTarget; + function isNewExpressionTarget(node) { + return isCallOrNewExpressionTarget(node, 176); } - ts.keywordPart = keywordPart; - function punctuationPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); + ts.isNewExpressionTarget = isNewExpressionTarget; + function isCallOrNewExpressionTarget(node, kind) { + var target = climbPastPropertyAccess(node); + return target && target.parent && target.parent.kind === kind && target.parent.expression === target; } - ts.punctuationPart = punctuationPart; - function operatorPart(kind) { - return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); + function climbPastPropertyAccess(node) { + return isRightSideOfPropertyAccess(node) ? node.parent : node; } - ts.operatorPart = operatorPart; - function textOrKeywordPart(text) { - var kind = ts.stringToToken(text); - return kind === undefined - ? textPart(text) - : keywordPart(kind); + ts.climbPastPropertyAccess = climbPastPropertyAccess; + function getTargetLabel(referenceNode, labelName) { + while (referenceNode) { + if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { + return referenceNode.label; + } + referenceNode = referenceNode.parent; + } + return undefined; } - ts.textOrKeywordPart = textOrKeywordPart; - function textPart(text) { - return displayPart(text, ts.SymbolDisplayPartKind.text); + ts.getTargetLabel = getTargetLabel; + function isJumpStatementTarget(node) { + return node.kind === 70 && + (node.parent.kind === 211 || node.parent.kind === 210) && + node.parent.label === node; } - ts.textPart = textPart; - var carriageReturnLineFeed = "\r\n"; - function getNewLineOrDefaultFromHost(host) { - return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + ts.isJumpStatementTarget = isJumpStatementTarget; + function isLabelOfLabeledStatement(node) { + return node.kind === 70 && + node.parent.kind === 215 && + node.parent.label === node; } - ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; - function lineBreakPart() { - return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); + function isLabelName(node) { + return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } - ts.lineBreakPart = lineBreakPart; - function mapToDisplayParts(writeDisplayParts) { - writeDisplayParts(displayPartWriter); - var result = displayPartWriter.displayParts(); - displayPartWriter.clear(); - return result; + ts.isLabelName = isLabelName; + function isRightSideOfQualifiedName(node) { + return node.parent.kind === 140 && node.parent.right === node; } - ts.mapToDisplayParts = mapToDisplayParts; - function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - }); + ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; + function isRightSideOfPropertyAccess(node) { + return node && node.parent && node.parent.kind === 173 && node.parent.name === node; } - ts.typeToDisplayParts = typeToDisplayParts; - function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - return mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); - }); + ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; + function isNameOfModuleDeclaration(node) { + return node.parent.kind === 226 && node.parent.name === node; } - ts.symbolToDisplayParts = symbolToDisplayParts; - function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - return mapToDisplayParts(function (writer) { - typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); - }); + ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; + function isNameOfFunctionDeclaration(node) { + return node.kind === 70 && + ts.isFunctionLike(node.parent) && node.parent.name === node; } - ts.signatureToDisplayParts = signatureToDisplayParts; - function getDeclaredName(typeChecker, symbol, location) { - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140) { - return location.text; + ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; + function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { + if (node.kind === 9 || node.kind === 8) { + switch (node.parent.kind) { + case 146: + case 145: + case 253: + case 255: + case 148: + case 147: + case 150: + case 151: + case 226: + return node.parent.name === node; + case 174: + return node.parent.argumentExpression === node; + case 141: + return true; + } } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; + return false; } - ts.getDeclaredName = getDeclaredName; - function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 234 || location.parent.kind === 238) && - location.parent.propertyName === location; + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; + function isExpressionOfExternalModuleImportEqualsDeclaration(node) { + return ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && + ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node; } - ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; - function stripQuotes(name) { - var length = name.length; - if (length >= 2 && - name.charCodeAt(0) === name.charCodeAt(length - 1) && - (name.charCodeAt(0) === 34 || name.charCodeAt(0) === 39)) { - return name.substring(1, length - 1); + ts.isExpressionOfExternalModuleImportEqualsDeclaration = isExpressionOfExternalModuleImportEqualsDeclaration; + function isInsideComment(sourceFile, token, position) { + return position <= token.getStart(sourceFile) && + (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || + isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); + function isInsideCommentRange(comments) { + return ts.forEach(comments, function (comment) { + if (comment.pos < position && position < comment.end) { + return true; + } + else if (position === comment.end) { + var text = sourceFile.text; + var width = comment.end - comment.pos; + if (width <= 2 || text.charCodeAt(comment.pos + 1) === 47) { + return true; + } + else { + return !(text.charCodeAt(comment.end - 1) === 47 && + text.charCodeAt(comment.end - 2) === 42); + } + } + return false; + }); } - ; - return name; } - ts.stripQuotes = stripQuotes; - function scriptKindIs(fileName, host) { - var scriptKinds = []; - for (var _i = 2; _i < arguments.length; _i++) { - scriptKinds[_i - 2] = arguments[_i]; + ts.isInsideComment = isInsideComment; + function getContainerNode(node) { + while (true) { + node = node.parent; + if (!node) { + return undefined; + } + switch (node.kind) { + case 256: + case 148: + case 147: + case 221: + case 180: + case 150: + case 151: + case 222: + case 223: + case 225: + case 226: + return node; + } } - var scriptKind = getScriptKind(fileName, host); - return ts.forEach(scriptKinds, function (k) { return k === scriptKind; }); } - ts.scriptKindIs = scriptKindIs; - function getScriptKind(fileName, host) { - var scriptKind; - if (host && host.getScriptKind) { - scriptKind = host.getScriptKind(fileName); + ts.getContainerNode = getContainerNode; + function getNodeKind(node) { + switch (node.kind) { + case 256: + return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; + case 226: + return ts.ScriptElementKind.moduleElement; + case 222: + case 193: + return ts.ScriptElementKind.classElement; + case 223: return ts.ScriptElementKind.interfaceElement; + case 224: return ts.ScriptElementKind.typeElement; + case 225: return ts.ScriptElementKind.enumElement; + case 219: + return getKindOfVariableDeclaration(node); + case 170: + return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 181: + case 221: + case 180: + return ts.ScriptElementKind.functionElement; + case 150: return ts.ScriptElementKind.memberGetAccessorElement; + case 151: return ts.ScriptElementKind.memberSetAccessorElement; + case 148: + case 147: + return ts.ScriptElementKind.memberFunctionElement; + case 146: + case 145: + return ts.ScriptElementKind.memberVariableElement; + case 154: return ts.ScriptElementKind.indexSignatureElement; + case 153: return ts.ScriptElementKind.constructSignatureElement; + case 152: return ts.ScriptElementKind.callSignatureElement; + case 149: return ts.ScriptElementKind.constructorImplementationElement; + case 142: return ts.ScriptElementKind.typeParameterElement; + case 255: return ts.ScriptElementKind.enumMemberElement; + case 143: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230: + case 235: + case 232: + case 239: + case 233: + return ts.ScriptElementKind.alias; + case 279: + return ts.ScriptElementKind.typeElement; + default: + return ts.ScriptElementKind.unknown; } - if (!scriptKind) { - scriptKind = ts.getScriptKindFromFileName(fileName); + function getKindOfVariableDeclaration(v) { + return ts.isConst(v) + ? ts.ScriptElementKind.constElement + : ts.isLet(v) + ? ts.ScriptElementKind.letElement + : ts.ScriptElementKind.variableElement; } - return ts.ensureScriptKind(fileName, scriptKind); } - ts.getScriptKind = getScriptKind; - function sanitizeConfigFile(configFileName, content) { - var options = { - fileName: "config.js", - compilerOptions: { - target: 2, - removeComments: true - }, - reportDiagnostics: true - }; - var _a = ts.transpileModule("(" + content + ")", options), outputText = _a.outputText, diagnostics = _a.diagnostics; - var trimmedOutput = outputText.trim(); - for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { - var diagnostic = diagnostics_2[_i]; - diagnostic.start = diagnostic.start - 1; + ts.getNodeKind = getNodeKind; + function getStringLiteralTypeForNode(node, typeChecker) { + var searchNode = node.parent.kind === 167 ? node.parent : node; + var type = typeChecker.getTypeAtLocation(searchNode); + if (type && type.flags & 32) { + return type; } - var _b = ts.parseConfigFileTextToJson(configFileName, trimmedOutput.substring(1, trimmedOutput.length - 2), false), config = _b.config, error = _b.error; - return { - configJsonObject: config || {}, - diagnostics: error ? ts.concatenate(diagnostics, [error]) : diagnostics - }; + return undefined; } - ts.sanitizeConfigFile = sanitizeConfigFile; -})(ts || (ts = {})); -var ts; -(function (ts) { - var BreakpointResolver; - (function (BreakpointResolver) { - function spanInSourceFileAtLocation(sourceFile, position) { - if (sourceFile.isDeclarationFile) { - return undefined; - } - var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); - var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { - return undefined; - } - } - if (ts.isInAmbientContext(tokenAtLocation)) { - return undefined; - } - return spanInNode(tokenAtLocation); - function textSpan(startNode, endNode) { - var start = startNode.decorators ? - ts.skipTrivia(sourceFile.text, startNode.decorators.end) : - startNode.getStart(sourceFile); - return ts.createTextSpanFromBounds(start, (endNode || startNode).getEnd()); - } - function textSpanEndingAtNextToken(startNode, previousTokenToFindNextEndToken) { - return textSpan(startNode, ts.findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent)); - } - function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { - if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) { - return spanInNode(node); - } - return spanInNode(otherwiseOnNode); - } - function spanInNodeArray(nodeArray) { - return ts.createTextSpanFromBounds(ts.skipTrivia(sourceFile.text, nodeArray.pos), nodeArray.end); - } - function spanInPreviousNode(node) { - return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); - } - function spanInNextNode(node) { - return spanInNode(ts.findNextToken(node, node.parent)); - } - function spanInNode(node) { - if (node) { - switch (node.kind) { - case 200: - return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218: - case 145: - case 144: - return spanInVariableDeclaration(node); - case 142: - return spanInParameterDeclaration(node); - case 220: - case 147: - case 146: - case 149: - case 150: - case 148: - case 179: - case 180: - return spanInFunctionDeclaration(node); - case 199: - if (ts.isFunctionBlock(node)) { - return spanInFunctionBlock(node); - } - case 226: - return spanInBlock(node); - case 252: - return spanInBlock(node.block); - case 202: - return textSpan(node.expression); - case 211: - return textSpan(node.getChildAt(0), node.expression); - case 205: - return textSpanEndingAtNextToken(node, node.expression); - case 204: - return spanInNode(node.statement); - case 217: - return textSpan(node.getChildAt(0)); - case 203: - return textSpanEndingAtNextToken(node, node.expression); - case 214: - return spanInNode(node.statement); - case 210: - case 209: - return textSpan(node.getChildAt(0), node.label); - case 206: - return spanInForStatement(node); - case 207: - return textSpanEndingAtNextToken(node, node.expression); - case 208: - return spanInInitializerOfForLike(node); - case 213: - return textSpanEndingAtNextToken(node, node.expression); - case 249: - case 250: - return spanInNode(node.statements[0]); - case 216: - return spanInBlock(node.tryBlock); - case 215: - return textSpan(node, node.expression); - case 235: - return textSpan(node, node.expression); - case 229: - return textSpan(node, node.moduleReference); - case 230: - return textSpan(node, node.moduleSpecifier); - case 236: - return textSpan(node, node.moduleSpecifier); - case 225: - if (ts.getModuleInstanceState(node) !== 1) { - return undefined; - } - case 221: - case 224: - case 255: - case 169: - return textSpan(node); - case 212: - return spanInNode(node.statement); - case 143: - return spanInNodeArray(node.parent.decorators); - case 167: - case 168: - return spanInBindingPattern(node); - case 222: - case 223: - return undefined; - case 23: - case 1: - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24: - return spanInPreviousNode(node); - case 15: - return spanInOpenBraceToken(node); - case 16: - return spanInCloseBraceToken(node); - case 20: - return spanInCloseBracketToken(node); - case 17: - return spanInOpenParenToken(node); - case 18: - return spanInCloseParenToken(node); - case 54: - return spanInColonToken(node); - case 27: - case 25: - return spanInGreaterThanOrLessThanToken(node); - case 104: - return spanInWhileKeyword(node); - case 80: - case 72: - case 85: - return spanInNextNode(node); - case 138: - return spanInOfKeyword(node); - default: - if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { - return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); - } - if ((node.kind === 69 || - node.kind == 191 || - node.kind === 253 || - node.kind === 254) && - ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { - return textSpan(node); - } - if (node.kind === 187) { - var binaryExpression = node; - if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { - return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); - } - if (binaryExpression.operatorToken.kind === 56 && - ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { - return textSpan(node); - } - if (binaryExpression.operatorToken.kind === 24) { - return spanInNode(binaryExpression.left); - } - } - if (ts.isPartOfExpression(node)) { - switch (node.parent.kind) { - case 204: - return spanInPreviousNode(node); - case 143: - return spanInNode(node.parent); - case 206: - case 208: - return textSpan(node); - case 187: - if (node.parent.operatorToken.kind === 24) { - return textSpan(node); - } - break; - case 180: - if (node.parent.body === node) { - return textSpan(node); - } - break; - } - } - if (node.parent.kind === 253 && - node.parent.name === node && - !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { - return spanInNode(node.parent.initializer); - } - if (node.parent.kind === 177 && node.parent.type === node) { - return spanInNextNode(node.parent.type); - } - if (ts.isFunctionLike(node.parent) && node.parent.type === node) { - return spanInPreviousNode(node); - } - if ((node.parent.kind === 218 || - node.parent.kind === 142)) { - var paramOrVarDecl = node.parent; - if (paramOrVarDecl.initializer === node || - paramOrVarDecl.type === node || - ts.isAssignmentOperator(node.kind)) { - return spanInPreviousNode(node); - } - } - if (node.parent.kind === 187) { - var binaryExpression = node.parent; - if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && - (binaryExpression.right === node || - binaryExpression.operatorToken === node)) { - return spanInPreviousNode(node); - } - } - return spanInNode(node.parent); - } + ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; + function isThis(node) { + switch (node.kind) { + case 98: + return true; + case 70: + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143; + default: + return false; + } + } + ts.isThis = isThis; + var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= range.end; + } + ts.startEndContainsRange = startEndContainsRange; + function rangeContainsStartEnd(range, start, end) { + return range.pos <= start && range.end >= end; + } + ts.rangeContainsStartEnd = rangeContainsStartEnd; + function rangeOverlapsWithStartEnd(r1, start, end) { + return startEndOverlapsWithStartEnd(r1.pos, r1.end, start, end); + } + ts.rangeOverlapsWithStartEnd = rangeOverlapsWithStartEnd; + function startEndOverlapsWithStartEnd(start1, end1, start2, end2) { + var start = Math.max(start1, start2); + var end = Math.min(end1, end2); + return start < end; + } + ts.startEndOverlapsWithStartEnd = startEndOverlapsWithStartEnd; + function positionBelongsToNode(candidate, position, sourceFile) { + return candidate.end > position || !isCompletedNode(candidate, sourceFile); + } + ts.positionBelongsToNode = positionBelongsToNode; + function isCompletedNode(n, sourceFile) { + if (ts.nodeIsMissing(n)) { + return false; + } + switch (n.kind) { + case 222: + case 223: + case 225: + case 172: + case 168: + case 160: + case 200: + case 227: + case 228: + case 234: + case 238: + return nodeEndsWith(n, 17, sourceFile); + case 252: + return isCompletedNode(n.block, sourceFile); + case 176: + if (!n.arguments) { + return true; } - function textSpanFromVariableDeclaration(variableDeclaration) { - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] === variableDeclaration) { - return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); - } - else { - return textSpan(variableDeclaration); - } + case 175: + case 179: + case 165: + return nodeEndsWith(n, 19, sourceFile); + case 157: + case 158: + return isCompletedNode(n.type, sourceFile); + case 149: + case 150: + case 151: + case 221: + case 180: + case 148: + case 147: + case 153: + case 152: + case 181: + if (n.body) { + return isCompletedNode(n.body, sourceFile); } - function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 207) { - return spanInNode(variableDeclaration.parent.parent); - } - if (ts.isBindingPattern(variableDeclaration.name)) { - return spanInBindingPattern(variableDeclaration.name); - } - if (variableDeclaration.initializer || - ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 208) { - return textSpanFromVariableDeclaration(variableDeclaration); - } - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] !== variableDeclaration) { - return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent)); - } + if (n.type) { + return isCompletedNode(n.type, sourceFile); } - function canHaveSpanInParameterDeclaration(parameter) { - return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasModifier(parameter, 4 | 8); + return hasChildOfKind(n, 19, sourceFile); + case 226: + return n.body && isCompletedNode(n.body, sourceFile); + case 204: + if (n.elseStatement) { + return isCompletedNode(n.elseStatement, sourceFile); } - function spanInParameterDeclaration(parameter) { - if (ts.isBindingPattern(parameter.name)) { - return spanInBindingPattern(parameter.name); - } - else if (canHaveSpanInParameterDeclaration(parameter)) { - return textSpan(parameter); - } - else { - var functionDeclaration = parameter.parent; - var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); - if (indexOfParameter) { - return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); + return isCompletedNode(n.thenStatement, sourceFile); + case 203: + return isCompletedNode(n.expression, sourceFile) || + hasChildOfKind(n, 24); + case 171: + case 169: + case 174: + case 141: + case 162: + return nodeEndsWith(n, 21, sourceFile); + case 154: + if (n.type) { + return isCompletedNode(n.type, sourceFile); + } + return hasChildOfKind(n, 21, sourceFile); + case 249: + case 250: + return false; + case 207: + case 208: + case 209: + case 206: + return isCompletedNode(n.statement, sourceFile); + case 205: + var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); + if (hasWhileKeyword) { + return nodeEndsWith(n, 19, sourceFile); + } + return isCompletedNode(n.statement, sourceFile); + case 159: + return isCompletedNode(n.exprName, sourceFile); + case 183: + case 182: + case 184: + case 191: + case 192: + var unaryWordExpression = n; + return isCompletedNode(unaryWordExpression.expression, sourceFile); + case 177: + return isCompletedNode(n.template, sourceFile); + case 190: + var lastSpan = ts.lastOrUndefined(n.templateSpans); + return isCompletedNode(lastSpan, sourceFile); + case 198: + return ts.nodeIsPresent(n.literal); + case 237: + case 231: + return ts.nodeIsPresent(n.moduleSpecifier); + case 186: + return isCompletedNode(n.operand, sourceFile); + case 188: + return isCompletedNode(n.right, sourceFile); + case 189: + return isCompletedNode(n.whenFalse, sourceFile); + default: + return true; + } + } + ts.isCompletedNode = isCompletedNode; + function nodeEndsWith(n, expectedLastToken, sourceFile) { + var children = n.getChildren(sourceFile); + if (children.length) { + var last = ts.lastOrUndefined(children); + if (last.kind === expectedLastToken) { + return true; + } + else if (last.kind === 24 && children.length !== 1) { + return children[children.length - 2].kind === expectedLastToken; + } + } + return false; + } + function findListItemInfo(node) { + var list = findContainingList(node); + if (!list) { + return undefined; + } + var children = list.getChildren(); + var listItemIndex = ts.indexOf(children, node); + return { + listItemIndex: listItemIndex, + list: list + }; + } + ts.findListItemInfo = findListItemInfo; + function hasChildOfKind(n, kind, sourceFile) { + return !!findChildOfKind(n, kind, sourceFile); + } + ts.hasChildOfKind = hasChildOfKind; + function findChildOfKind(n, kind, sourceFile) { + return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); + } + ts.findChildOfKind = findChildOfKind; + function findContainingList(node) { + var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { + if (c.kind === 286 && c.pos <= node.pos && c.end >= node.end) { + return c; + } + }); + ts.Debug.assert(!syntaxList || ts.contains(syntaxList.getChildren(), node)); + return syntaxList; + } + ts.findContainingList = findContainingList; + function getTouchingWord(sourceFile, position, includeJsDocComment) { + if (includeJsDocComment === void 0) { includeJsDocComment = false; } + return getTouchingToken(sourceFile, position, function (n) { return isWord(n.kind); }, includeJsDocComment); + } + ts.getTouchingWord = getTouchingWord; + function getTouchingPropertyName(sourceFile, position, includeJsDocComment) { + if (includeJsDocComment === void 0) { includeJsDocComment = false; } + return getTouchingToken(sourceFile, position, function (n) { return isPropertyName(n.kind); }, includeJsDocComment); + } + ts.getTouchingPropertyName = getTouchingPropertyName; + function getTouchingToken(sourceFile, position, includeItemAtEndPosition, includeJsDocComment) { + if (includeJsDocComment === void 0) { includeJsDocComment = false; } + return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition, includeJsDocComment); + } + ts.getTouchingToken = getTouchingToken; + function getTokenAtPosition(sourceFile, position, includeJsDocComment) { + if (includeJsDocComment === void 0) { includeJsDocComment = false; } + return getTokenAtPositionWorker(sourceFile, position, true, undefined, includeJsDocComment); + } + ts.getTokenAtPosition = getTokenAtPosition; + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition, includeJsDocComment) { + if (includeJsDocComment === void 0) { includeJsDocComment = false; } + var current = sourceFile; + outer: while (true) { + if (isToken(current)) { + return current; + } + if (includeJsDocComment) { + var jsDocChildren = ts.filter(current.getChildren(), ts.isJSDocNode); + for (var _i = 0, jsDocChildren_1 = jsDocChildren; _i < jsDocChildren_1.length; _i++) { + var jsDocChild = jsDocChildren_1[_i]; + var start = allowPositionInLeadingTrivia ? jsDocChild.getFullStart() : jsDocChild.getStart(sourceFile, includeJsDocComment); + if (start <= position) { + var end = jsDocChild.getEnd(); + if (position < end || (position === end && jsDocChild.kind === 1)) { + current = jsDocChild; + continue outer; } - else { - return spanInNode(functionDeclaration.body); + else if (includeItemAtEndPosition && end === position) { + var previousToken = findPrecedingToken(position, sourceFile, jsDocChild); + if (previousToken && includeItemAtEndPosition(previousToken)) { + return previousToken; + } } } } - function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 221 && functionDeclaration.kind !== 148); + } + for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { + var child = current.getChildAt(i); + if (ts.isJSDocNode(child)) { + continue; } - function spanInFunctionDeclaration(functionDeclaration) { - if (!functionDeclaration.body) { - return undefined; - } - if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { - return textSpan(functionDeclaration); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); + if (start <= position) { + var end = child.getEnd(); + if (position < end || (position === end && child.kind === 1)) { + current = child; + continue outer; } - return spanInNode(functionDeclaration.body); - } - function spanInFunctionBlock(block) { - var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); - if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { - return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); + else if (includeItemAtEndPosition && end === position) { + var previousToken = findPrecedingToken(position, sourceFile, child); + if (previousToken && includeItemAtEndPosition(previousToken)) { + return previousToken; + } } - return spanInNode(nodeForSpanInBlock); } - function spanInBlock(block) { - switch (block.parent.kind) { - case 225: - if (ts.getModuleInstanceState(block.parent) !== 1) { - return undefined; - } - case 205: - case 203: - case 207: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 206: - case 208: - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); - } - return spanInNode(block.statements[0]); + } + return current; + } + } + function findTokenOnLeftOfPosition(file, position) { + var tokenAtPosition = getTokenAtPosition(file, position); + if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + return tokenAtPosition; + } + return findPrecedingToken(position, file); + } + ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; + function findNextToken(previousToken, parent) { + return find(parent); + function find(n) { + if (isToken(n) && n.pos === previousToken.end) { + return n; + } + var children = n.getChildren(); + for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { + var child = children_2[_i]; + var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || + (child.pos === previousToken.end); + if (shouldDiveInChildNode && nodeHasTokens(child)) { + return find(child); } - function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 219) { - var variableDeclarationList = forLikeStatement.initializer; - if (variableDeclarationList.declarations.length > 0) { - return spanInNode(variableDeclarationList.declarations[0]); - } + } + return undefined; + } + } + ts.findNextToken = findNextToken; + function findPrecedingToken(position, sourceFile, startNode) { + return find(startNode || sourceFile); + function findRightmostToken(n) { + if (isToken(n)) { + return n; + } + var children = n.getChildren(); + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); + } + function find(n) { + if (isToken(n)) { + return n; + } + var children = n.getChildren(); + for (var i = 0, len = children.length; i < len; i++) { + var child = children[i]; + if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { + var start = child.getStart(sourceFile); + var lookInPreviousChild = (start >= position) || + (child.kind === 10 && start === child.end); + if (lookInPreviousChild) { + var candidate = findRightmostChildNodeWithTokens(children, i); + return candidate && findRightmostToken(candidate); } else { - return spanInNode(forLikeStatement.initializer); + return find(child); } } - function spanInForStatement(forStatement) { - if (forStatement.initializer) { - return spanInInitializerOfForLike(forStatement); - } - if (forStatement.condition) { - return textSpan(forStatement.condition); - } - if (forStatement.incrementor) { - return textSpan(forStatement.incrementor); - } - } - function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 ? element : undefined; }); - if (firstBindingElement) { - return spanInNode(firstBindingElement); - } - if (bindingPattern.parent.kind === 169) { - return textSpan(bindingPattern.parent); - } - return textSpanFromVariableDeclaration(bindingPattern.parent); - } - function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 && node.kind !== 167); - var elements = node.kind === 170 ? - node.elements : - node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 ? element : undefined; }); - if (firstBindingElement) { - return spanInNode(firstBindingElement); - } - return textSpan(node.parent.kind === 187 ? node.parent : node); - } - function spanInOpenBraceToken(node) { - switch (node.parent.kind) { - case 224: - var enumDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221: - var classDeclaration = node.parent; - return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227: - return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); - } - return spanInNode(node.parent); - } - function spanInCloseBraceToken(node) { - switch (node.parent.kind) { - case 226: - if (ts.getModuleInstanceState(node.parent.parent) !== 1) { - return undefined; - } - case 224: - case 221: - return textSpan(node); - case 199: - if (ts.isFunctionBlock(node.parent)) { - return textSpan(node); - } - case 252: - return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227: - var caseBlock = node.parent; - var lastClause = ts.lastOrUndefined(caseBlock.clauses); - if (lastClause) { - return spanInNode(ts.lastOrUndefined(lastClause.statements)); - } - return undefined; - case 167: - var bindingPattern = node.parent; - return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); - default: - if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { - var objectLiteral = node.parent; - return textSpan(ts.lastOrUndefined(objectLiteral.properties) || objectLiteral); - } - return spanInNode(node.parent); - } - } - function spanInCloseBracketToken(node) { - switch (node.parent.kind) { - case 168: - var bindingPattern = node.parent; - return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); - default: - if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { - var arrayLiteral = node.parent; - return textSpan(ts.lastOrUndefined(arrayLiteral.elements) || arrayLiteral); - } - return spanInNode(node.parent); - } - } - function spanInOpenParenToken(node) { - if (node.parent.kind === 204 || - node.parent.kind === 174 || - node.parent.kind === 175) { - return spanInPreviousNode(node); - } - if (node.parent.kind === 178) { - return spanInNextNode(node); - } - return spanInNode(node.parent); - } - function spanInCloseParenToken(node) { - switch (node.parent.kind) { - case 179: - case 220: - case 180: - case 147: - case 146: - case 149: - case 150: - case 148: - case 205: - case 204: - case 206: - case 208: - case 174: - case 175: - case 178: - return spanInPreviousNode(node); - default: - return spanInNode(node.parent); - } - } - function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || - node.parent.kind === 253 || - node.parent.kind === 142) { - return spanInPreviousNode(node); - } - return spanInNode(node.parent); - } - function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177) { - return spanInNextNode(node); - } - return spanInNode(node.parent); - } - function spanInWhileKeyword(node) { - if (node.parent.kind === 204) { - return textSpanEndingAtNextToken(node, node.parent.expression); - } - return spanInNode(node.parent); - } - function spanInOfKeyword(node) { - if (node.parent.kind === 208) { - return spanInNextNode(node); - } - return spanInNode(node.parent); - } + } + ts.Debug.assert(startNode !== undefined || n.kind === 256); + if (children.length) { + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); } } - BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; - })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - function createClassifier() { - var scanner = ts.createScanner(2, false); - var noRegexTable = []; - noRegexTable[69] = true; - noRegexTable[9] = true; - noRegexTable[8] = true; - noRegexTable[10] = true; - noRegexTable[97] = true; - noRegexTable[41] = true; - noRegexTable[42] = true; - noRegexTable[18] = true; - noRegexTable[20] = true; - noRegexTable[16] = true; - noRegexTable[99] = true; - noRegexTable[84] = true; - var templateStack = []; - function canFollow(keyword1, keyword2) { - if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 123 || - keyword2 === 131 || - keyword2 === 121 || - keyword2 === 113) { - return true; + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { + for (var i = exclusiveStartPosition - 1; i >= 0; i--) { + if (nodeHasTokens(children[i])) { + return children[i]; } - return false; } - return true; } - function convertClassifications(classifications, text) { - var entries = []; - var dense = classifications.spans; - var lastEnd = 0; - for (var i = 0, n = dense.length; i < n; i += 3) { - var start = dense[i]; - var length_4 = dense[i + 1]; - var type = dense[i + 2]; - if (lastEnd >= 0) { - var whitespaceLength_1 = start - lastEnd; - if (whitespaceLength_1 > 0) { - entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); - } - } - entries.push({ length: length_4, classification: convertClassification(type) }); - lastEnd = start + length_4; + } + ts.findPrecedingToken = findPrecedingToken; + function isInString(sourceFile, position) { + var previousToken = findPrecedingToken(position, sourceFile); + if (previousToken && previousToken.kind === 9) { + var start = previousToken.getStart(); + var end = previousToken.getEnd(); + if (start < position && position < end) { + return true; } - var whitespaceLength = text.length - lastEnd; - if (whitespaceLength > 0) { - entries.push({ length: whitespaceLength, classification: ts.TokenClass.Whitespace }); + if (position === end) { + return !!previousToken.isUnterminated; } - return { entries: entries, finalLexState: classifications.endOfLineState }; } - function convertClassification(type) { - switch (type) { - case 1: return ts.TokenClass.Comment; - case 3: return ts.TokenClass.Keyword; - case 4: return ts.TokenClass.NumberLiteral; - case 5: return ts.TokenClass.Operator; - case 6: return ts.TokenClass.StringLiteral; - case 8: return ts.TokenClass.Whitespace; - case 10: return ts.TokenClass.Punctuation; - case 2: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 9: - case 17: - default: - return ts.TokenClass.Identifier; - } + return false; + } + ts.isInString = isInString; + function isInComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, undefined); + } + ts.isInComment = isInComment; + function isInsideJsxElementOrAttribute(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + if (!token) { + return false; } - function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { - return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); + if (token.kind === 10) { + return true; } - function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var offset = 0; - var token = 0; - var lastNonTriviaToken = 0; - while (templateStack.length > 0) { - templateStack.pop(); - } - switch (lexState) { - case 3: - text = "\"\\\n" + text; - offset = 3; - break; - case 2: - text = "'\\\n" + text; - offset = 3; - break; - case 1: - text = "/*\n" + text; - offset = 3; - break; - case 4: - text = "`\n" + text; - offset = 2; + if (token.kind === 26 && token.parent.kind === 10) { + return true; + } + if (token.kind === 26 && token.parent.kind === 248) { + return true; + } + if (token && token.kind === 17 && token.parent.kind === 248) { + return true; + } + if (token.kind === 26 && token.parent.kind === 245) { + return true; + } + return false; + } + ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; + function isInTemplateString(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + return ts.isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile); + } + ts.isInTemplateString = isInTemplateString; + function isInCommentHelper(sourceFile, position, predicate) { + var token = getTokenAtPosition(sourceFile, position); + if (token && position <= token.getStart(sourceFile)) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return predicate ? + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end) && + predicate(c); }) : + ts.forEach(commentRanges, function (c) { return c.pos < position && + (c.kind == 2 ? position <= c.end : position < c.end); }); + } + return false; + } + ts.isInCommentHelper = isInCommentHelper; + function hasDocComment(sourceFile, position) { + var token = getTokenAtPosition(sourceFile, position); + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, jsDocPrefix); + function jsDocPrefix(c) { + var text = sourceFile.text; + return text.length >= c.pos + 3 && text[c.pos] === "/" && text[c.pos + 1] === "*" && text[c.pos + 2] === "*"; + } + } + ts.hasDocComment = hasDocComment; + function getJsDocTagAtPosition(sourceFile, position) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (isToken(node)) { + switch (node.kind) { + case 103: + case 109: + case 75: + node = node.parent === undefined ? undefined : node.parent.parent; break; - case 5: - text = "}\n" + text; - offset = 2; - case 6: - templateStack.push(12); + default: + node = node.parent; break; } - scanner.setText(text); - var result = { - endOfLineState: 0, - spans: [] - }; - var angleBracketStack = 0; - do { - token = scanner.scan(); - if (!ts.isTrivia(token)) { - if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10) { - token = 10; - } - } - else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 69; - } - else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 69; - } - else if (lastNonTriviaToken === 69 && - token === 25) { - angleBracketStack++; - } - else if (token === 27 && angleBracketStack > 0) { - angleBracketStack--; - } - else if (token === 117 || - token === 132 || - token === 130 || - token === 120 || - token === 133) { - if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 69; - } - } - else if (token === 12) { - templateStack.push(token); - } - else if (token === 15) { - if (templateStack.length > 0) { - templateStack.push(token); - } - } - else if (token === 16) { - if (templateStack.length > 0) { - var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12) { - token = scanner.reScanTemplateToken(); - if (token === 14) { - templateStack.pop(); - } - else { - ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); - } - } - else { - ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); - templateStack.pop(); - } - } - } - lastNonTriviaToken = token; - } - processToken(); - } while (token !== 1); - return result; - function processToken() { - var start = scanner.getTokenPos(); - var end = scanner.getTextPos(); - addResult(start, end, classFromKind(token)); - if (end >= text.length) { - if (token === 9) { - var tokenText = scanner.getTokenText(); - if (scanner.isUnterminated()) { - var lastCharIndex = tokenText.length - 1; - var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92) { - numBackslashes++; - } - if (numBackslashes & 1) { - var quoteChar = tokenText.charCodeAt(0); - result.endOfLineState = quoteChar === 34 - ? 3 - : 2; - } - } - } - else if (token === 3) { - if (scanner.isUnterminated()) { - result.endOfLineState = 1; - } - } - else if (ts.isTemplateLiteralKind(token)) { - if (scanner.isUnterminated()) { - if (token === 14) { - result.endOfLineState = 5; - } - else if (token === 11) { - result.endOfLineState = 4; - } - else { - ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); + } + if (node) { + if (node.jsDocComments) { + for (var _i = 0, _a = node.jsDocComments; _i < _a.length; _i++) { + var jsDocComment = _a[_i]; + if (jsDocComment.tags) { + for (var _b = 0, _c = jsDocComment.tags; _b < _c.length; _b++) { + var tag = _c[_b]; + if (tag.pos <= position && position <= tag.end) { + return tag; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { - result.endOfLineState = 6; - } - } - } - function addResult(start, end, classification) { - if (classification === 8) { - return; - } - if (start === 0 && offset > 0) { - start += offset; - } - start -= offset; - end -= offset; - var length = end - start; - if (length > 0) { - result.spans.push(start); - result.spans.push(length); - result.spans.push(classification); } } } - function isBinaryExpressionOperatorToken(token) { - switch (token) { - case 37: - case 39: - case 40: - case 35: - case 36: - case 43: - case 44: - case 45: - case 25: - case 27: - case 28: - case 29: - case 91: - case 90: - case 116: - case 30: - case 31: - case 32: - case 33: - case 46: - case 48: - case 47: - case 51: - case 52: - case 67: - case 66: - case 68: - case 63: - case 64: - case 65: - case 57: - case 58: - case 59: - case 61: - case 62: - case 56: - case 24: - return true; - default: - return false; - } + return undefined; + } + ts.getJsDocTagAtPosition = getJsDocTagAtPosition; + function nodeHasTokens(n) { + return n.getWidth() !== 0; + } + function getNodeModifiers(node) { + var flags = ts.getCombinedModifierFlags(node); + var result = []; + if (flags & 8) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 16) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 4) + result.push(ts.ScriptElementKindModifier.publicMemberModifier); + if (flags & 32) + result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 128) + result.push(ts.ScriptElementKindModifier.abstractModifier); + if (flags & 1) + result.push(ts.ScriptElementKindModifier.exportedModifier); + if (ts.isInAmbientContext(node)) + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(",") : ts.ScriptElementKindModifier.none; + } + ts.getNodeModifiers = getNodeModifiers; + function getTypeArgumentOrTypeParameterList(node) { + if (node.kind === 156 || node.kind === 175) { + return node.typeArguments; } - function isPrefixUnaryExpressionOperatorToken(token) { - switch (token) { - case 35: - case 36: - case 50: - case 49: - case 41: - case 42: - return true; - default: - return false; - } + if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { + return node.typeParameters; } - function isKeyword(token) { - return token >= 70 && token <= 138; + return undefined; + } + ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; + function isToken(n) { + return n.kind >= 0 && n.kind <= 139; + } + ts.isToken = isToken; + function isWord(kind) { + return kind === 70 || ts.isKeyword(kind); + } + ts.isWord = isWord; + function isPropertyName(kind) { + return kind === 9 || kind === 8 || isWord(kind); + } + function isComment(kind) { + return kind === 2 || kind === 3; + } + ts.isComment = isComment; + function isStringOrRegularExpressionOrTemplateLiteral(kind) { + if (kind === 9 + || kind === 11 + || ts.isTemplateLiteralKind(kind)) { + return true; } - function classFromKind(token) { - if (isKeyword(token)) { - return 3; - } - else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5; - } - else if (token >= 15 && token <= 68) { - return 10; - } - switch (token) { - case 8: - return 4; - case 9: - return 6; - case 10: - return 7; - case 7: - case 3: - case 2: - return 1; - case 5: - case 4: - return 8; - case 69: - default: - if (ts.isTemplateLiteralKind(token)) { - return 6; - } - return 2; - } - } - return { - getClassificationsForLine: getClassificationsForLine, - getEncodedLexicalClassifications: getEncodedLexicalClassifications - }; + return false; } - ts.createClassifier = createClassifier; - function getSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span) { - return convertClassifications(getEncodedSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span)); + ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; + function isPunctuation(kind) { + return 16 <= kind && kind <= 69; } - ts.getSemanticClassifications = getSemanticClassifications; - function checkForClassificationCancellation(cancellationToken, kind) { + ts.isPunctuation = isPunctuation; + function isInsideTemplateLiteral(node, position) { + return ts.isTemplateLiteralKind(node.kind) + && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + } + ts.isInsideTemplateLiteral = isInsideTemplateLiteral; + function isAccessibilityModifier(kind) { switch (kind) { - case 225: - case 221: - case 222: - case 220: - cancellationToken.throwIfCancellationRequested(); + case 113: + case 111: + case 112: + return true; } + return false; } - function getEncodedSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span) { - var result = []; - processNode(sourceFile); - return { spans: result, endOfLineState: 0 }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifySymbol(symbol, meaningAtPosition) { - var flags = symbol.getFlags(); - if ((flags & 788448) === 0) { - return; - } - if (flags & 32) { - return 11; - } - else if (flags & 384) { - return 12; - } - else if (flags & 524288) { - return 16; - } - else if (meaningAtPosition & 2) { - if (flags & 64) { - return 13; - } - else if (flags & 262144) { - return 15; + ts.isAccessibilityModifier = isAccessibilityModifier; + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) { + return false; } } - else if (flags & 1536) { - if (meaningAtPosition & 4 || - (meaningAtPosition & 1 && hasValueSideModule(symbol))) { - return 14; + else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) { + return false; } } - return undefined; - function hasValueSideModule(symbol) { - return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 && - ts.getModuleInstanceState(declaration) === 1; - }); - } } - function processNode(node) { - if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - var kind = node.kind; - checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 && !ts.nodeIsMissing(node)) { - var identifier = node; - if (classifiableNames[identifier.text]) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); - if (type) { - pushClassification(node.getStart(), node.getWidth(), type); - } - } - } - } - ts.forEachChild(node, processNode); + return true; + } + ts.compareDataObjects = compareDataObjects; + function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { + if (node.kind === 171 || + node.kind === 172) { + if (node.parent.kind === 188 && + node.parent.left === node && + node.parent.operatorToken.kind === 57) { + return true; + } + if (node.parent.kind === 209 && + node.parent.initializer === node) { + return true; + } + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 ? node.parent.parent : node.parent)) { + return true; } } + return false; } - ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; - function getClassificationTypeName(type) { - switch (type) { - case 1: return ts.ClassificationTypeNames.comment; - case 2: return ts.ClassificationTypeNames.identifier; - case 3: return ts.ClassificationTypeNames.keyword; - case 4: return ts.ClassificationTypeNames.numericLiteral; - case 5: return ts.ClassificationTypeNames.operator; - case 6: return ts.ClassificationTypeNames.stringLiteral; - case 8: return ts.ClassificationTypeNames.whiteSpace; - case 9: return ts.ClassificationTypeNames.text; - case 10: return ts.ClassificationTypeNames.punctuation; - case 11: return ts.ClassificationTypeNames.className; - case 12: return ts.ClassificationTypeNames.enumName; - case 13: return ts.ClassificationTypeNames.interfaceName; - case 14: return ts.ClassificationTypeNames.moduleName; - case 15: return ts.ClassificationTypeNames.typeParameterName; - case 16: return ts.ClassificationTypeNames.typeAliasName; - case 17: return ts.ClassificationTypeNames.parameterName; - case 18: return ts.ClassificationTypeNames.docCommentTagName; - case 19: return ts.ClassificationTypeNames.jsxOpenTagName; - case 20: return ts.ClassificationTypeNames.jsxCloseTagName; - case 21: return ts.ClassificationTypeNames.jsxSelfClosingTagName; - case 22: return ts.ClassificationTypeNames.jsxAttribute; - case 23: return ts.ClassificationTypeNames.jsxText; - case 24: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; + ts.isArrayLiteralOrObjectLiteralDestructuringPattern = isArrayLiteralOrObjectLiteralDestructuringPattern; + function hasTrailingDirectorySeparator(path) { + var lastCharacter = path.charAt(path.length - 1); + return lastCharacter === "/" || lastCharacter === "\\"; + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + function isInReferenceComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, isReferenceComment); + function isReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return tripleSlashDirectivePrefixRegex.test(commentText); } } - function convertClassifications(classifications) { - 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) { - result.push({ - textSpan: ts.createTextSpan(dense[i], dense[i + 1]), - classificationType: getClassificationTypeName(dense[i + 2]) - }); + ts.isInReferenceComment = isInReferenceComment; + function isInNonReferenceComment(sourceFile, position) { + return isInCommentHelper(sourceFile, position, isNonReferenceComment); + function isNonReferenceComment(c) { + var commentText = sourceFile.text.substring(c.pos, c.end); + return !tripleSlashDirectivePrefixRegex.test(commentText); } - return result; } - function getSyntacticClassifications(cancellationToken, sourceFile, span) { - return convertClassifications(getEncodedSyntacticClassifications(cancellationToken, sourceFile, span)); + ts.isInNonReferenceComment = isInNonReferenceComment; +})(ts || (ts = {})); +(function (ts) { + function isFirstDeclarationOfSymbolParameter(symbol) { + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143; } - ts.getSyntacticClassifications = getSyntacticClassifications; - function getEncodedSyntacticClassifications(cancellationToken, sourceFile, span) { - var spanStart = span.start; - var spanLength = span.length; - var triviaScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); - var result = []; - processElement(sourceFile); - return { spans: result, endOfLineState: 0 }; - function pushClassification(start, length, type) { - result.push(start); - result.push(length); - result.push(type); - } - function classifyLeadingTriviaAndGetTokenStart(token) { - triviaScanner.setTextPos(token.pos); - while (true) { - var start = triviaScanner.getTextPos(); - if (!ts.couldStartTrivia(sourceFile.text, start)) { - return start; - } - var kind = triviaScanner.scan(); - var end = triviaScanner.getTextPos(); - var width = end - start; - if (!ts.isTrivia(kind)) { - return start; - } - if (kind === 4 || kind === 5) { - continue; - } - if (ts.isComment(kind)) { - classifyComment(token, kind, start, width); - triviaScanner.setTextPos(end); - continue; - } - if (kind === 7) { - var text = sourceFile.text; - var ch = text.charCodeAt(start); - if (ch === 60 || ch === 62) { - pushClassification(start, width, 1); - continue; - } - ts.Debug.assert(ch === 61); - classifyDisabledMergeCode(text, start, end); - } - } - } - function classifyComment(token, kind, start, width) { - if (kind === 3) { - var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); - if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { - docCommentAndDiagnostics.jsDoc.parent = token; - classifyJSDocComment(docCommentAndDiagnostics.jsDoc); - return; + ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; + var displayPartWriter = getDisplayPartWriter(); + function getDisplayPartWriter() { + var displayParts; + var lineStart; + var indent; + resetWriter(); + return { + displayParts: function () { return displayParts; }, + writeKeyword: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.keyword); }, + writeOperator: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.operator); }, + writePunctuation: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.punctuation); }, + writeSpace: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.space); }, + writeStringLiteral: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.stringLiteral); }, + writeParameter: function (text) { return writeKind(text, ts.SymbolDisplayPartKind.parameterName); }, + writeSymbol: writeSymbol, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + clear: resetWriter, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + function writeIndent() { + if (lineStart) { + var indentString = ts.getIndentString(indent); + if (indentString) { + displayParts.push(displayPart(indentString, ts.SymbolDisplayPartKind.space)); } + lineStart = false; } - pushCommentRange(start, width); } - function pushCommentRange(start, width) { - pushClassification(start, width, 1); - } - function classifyJSDocComment(docComment) { - var pos = docComment.pos; - if (docComment.tags) { - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - if (tag.pos !== pos) { - pushCommentRange(pos, tag.pos - pos); - } - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10); - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); - pos = tag.tagName.end; - switch (tag.kind) { - case 275: - processJSDocParameterTag(tag); - break; - case 278: - processJSDocTemplateTag(tag); - break; - case 277: - processElement(tag.typeExpression); - break; - case 276: - processElement(tag.typeExpression); - break; - } - pos = tag.end; - } - } - if (pos !== docComment.end) { - pushCommentRange(pos, docComment.end - pos); - } - return; - function processJSDocParameterTag(tag) { - if (tag.preParameterName) { - pushCommentRange(pos, tag.preParameterName.pos - pos); - pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17); - pos = tag.preParameterName.end; - } - if (tag.typeExpression) { - pushCommentRange(pos, tag.typeExpression.pos - pos); - processElement(tag.typeExpression); - pos = tag.typeExpression.end; - } - if (tag.postParameterName) { - pushCommentRange(pos, tag.postParameterName.pos - pos); - pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17); - pos = tag.postParameterName.end; - } - } + function writeKind(text, kind) { + writeIndent(); + displayParts.push(displayPart(text, kind)); } - function processJSDocTemplateTag(tag) { - for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { - var child = _a[_i]; - processElement(child); - } + function writeSymbol(text, symbol) { + writeIndent(); + displayParts.push(symbolPart(text, symbol)); } - function classifyDisabledMergeCode(text, start, end) { - var i; - for (i = start; i < end; i++) { - if (ts.isLineBreak(text.charCodeAt(i))) { - break; - } - } - pushClassification(start, i - start, 1); - mergeConflictScanner.setTextPos(i); - while (mergeConflictScanner.getTextPos() < end) { - classifyDisabledCodeToken(); - } + function writeLine() { + displayParts.push(lineBreakPart()); + lineStart = true; } - function classifyDisabledCodeToken() { - var start = mergeConflictScanner.getTextPos(); - var tokenKind = mergeConflictScanner.scan(); - var end = mergeConflictScanner.getTextPos(); - var type = classifyTokenType(tokenKind); - if (type) { - pushClassification(start, end - start, type); - } + function resetWriter() { + displayParts = []; + lineStart = true; + indent = 0; } - function tryClassifyNode(node) { - if (ts.isJSDocTag(node)) { - return true; - } - if (ts.nodeIsMissing(node)) { - return true; - } - var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 && classifiedElementName === undefined) { - return false; + } + function symbolPart(text, symbol) { + return displayPart(text, displayPartKind(symbol)); + function displayPartKind(symbol) { + var flags = symbol.flags; + if (flags & 3) { + return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - var tokenStart = node.kind === 244 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); - var tokenWidth = node.end - tokenStart; - ts.Debug.assert(tokenWidth >= 0); - if (tokenWidth > 0) { - var type = classifiedElementName || classifyTokenType(node.kind, node); - if (type) { - pushClassification(tokenStart, tokenWidth, type); - } + else if (flags & 4) { + return ts.SymbolDisplayPartKind.propertyName; } - return true; - } - function tryClassifyJsxElementName(token) { - switch (token.parent && token.parent.kind) { - case 243: - if (token.parent.tagName === token) { - return 19; - } - break; - case 245: - if (token.parent.tagName === token) { - return 20; - } - break; - case 242: - if (token.parent.tagName === token) { - return 21; - } - break; - case 246: - if (token.parent.name === token) { - return 22; - } - break; + else if (flags & 32768) { + return ts.SymbolDisplayPartKind.propertyName; } - return undefined; - } - function classifyTokenType(tokenKind, token) { - if (ts.isKeyword(tokenKind)) { - return 3; + else if (flags & 65536) { + return ts.SymbolDisplayPartKind.propertyName; } - if (tokenKind === 25 || tokenKind === 27) { - if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10; - } + else if (flags & 8) { + return ts.SymbolDisplayPartKind.enumMemberName; } - if (ts.isPunctuation(tokenKind)) { - if (token) { - if (tokenKind === 56) { - if (token.parent.kind === 218 || - token.parent.kind === 145 || - token.parent.kind === 142 || - token.parent.kind === 246) { - return 5; - } - } - if (token.parent.kind === 187 || - token.parent.kind === 185 || - token.parent.kind === 186 || - token.parent.kind === 188) { - return 5; - } - } - return 10; + else if (flags & 16) { + return ts.SymbolDisplayPartKind.functionName; } - else if (tokenKind === 8) { - return 4; + else if (flags & 32) { + return ts.SymbolDisplayPartKind.className; } - else if (tokenKind === 9) { - return token.parent.kind === 246 ? 24 : 6; + else if (flags & 64) { + return ts.SymbolDisplayPartKind.interfaceName; } - else if (tokenKind === 10) { - return 6; + else if (flags & 384) { + return ts.SymbolDisplayPartKind.enumName; } - else if (ts.isTemplateLiteralKind(tokenKind)) { - return 6; + else if (flags & 1536) { + return ts.SymbolDisplayPartKind.moduleName; } - else if (tokenKind === 244) { - return 23; + else if (flags & 8192) { + return ts.SymbolDisplayPartKind.methodName; } - else if (tokenKind === 69) { - if (token) { - switch (token.parent.kind) { - case 221: - if (token.parent.name === token) { - return 11; - } - return; - case 141: - if (token.parent.name === token) { - return 15; - } - return; - case 222: - if (token.parent.name === token) { - return 13; - } - return; - case 224: - if (token.parent.name === token) { - return 12; - } - return; - case 225: - if (token.parent.name === token) { - return 14; - } - return; - case 142: - if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 : 17; - } - return; - } - } - return 2; + else if (flags & 262144) { + return ts.SymbolDisplayPartKind.typeParameterName; } - } - function processElement(element) { - if (!element) { - return; + else if (flags & 524288) { + return ts.SymbolDisplayPartKind.aliasName; } - 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]; - if (!tryClassifyNode(child)) { - processElement(child); - } - } + else if (flags & 8388608) { + return ts.SymbolDisplayPartKind.aliasName; } + return ts.SymbolDisplayPartKind.text; } } - ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; -})(ts || (ts = {})); + ts.symbolPart = symbolPart; + function displayPart(text, kind) { + return { + text: text, + kind: ts.SymbolDisplayPartKind[kind] + }; + } + ts.displayPart = displayPart; + function spacePart() { + return displayPart(" ", ts.SymbolDisplayPartKind.space); + } + ts.spacePart = spacePart; + function keywordPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.keyword); + } + ts.keywordPart = keywordPart; + function punctuationPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.punctuation); + } + ts.punctuationPart = punctuationPart; + function operatorPart(kind) { + return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); + } + ts.operatorPart = operatorPart; + function textOrKeywordPart(text) { + var kind = ts.stringToToken(text); + return kind === undefined + ? textPart(text) + : keywordPart(kind); + } + ts.textOrKeywordPart = textOrKeywordPart; + function textPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.text); + } + ts.textPart = textPart; + var carriageReturnLineFeed = "\r\n"; + function getNewLineOrDefaultFromHost(host) { + return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + } + ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; + function lineBreakPart() { + return displayPart("\n", ts.SymbolDisplayPartKind.lineBreak); + } + ts.lineBreakPart = lineBreakPart; + function mapToDisplayParts(writeDisplayParts) { + writeDisplayParts(displayPartWriter); + var result = displayPartWriter.displayParts(); + displayPartWriter.clear(); + return result; + } + ts.mapToDisplayParts = mapToDisplayParts; + function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); + }); + } + ts.typeToDisplayParts = typeToDisplayParts; + function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + return mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags); + }); + } + ts.symbolToDisplayParts = symbolToDisplayParts; + function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags); + }); + } + ts.signatureToDisplayParts = signatureToDisplayParts; + function getDeclaredName(typeChecker, symbol, location) { + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + else if (ts.isStringOrNumericLiteral(location.kind) && + location.parent.kind === 141) { + return location.text; + } + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + return name; + } + ts.getDeclaredName = getDeclaredName; + function isImportOrExportSpecifierName(location) { + return location.parent && + (location.parent.kind === 235 || location.parent.kind === 239) && + location.parent.propertyName === location; + } + ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; + function stripQuotes(name) { + var length = name.length; + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === 34 || name.charCodeAt(0) === 39)) { + return name.substring(1, length - 1); + } + ; + return name; + } + ts.stripQuotes = stripQuotes; + function scriptKindIs(fileName, host) { + var scriptKinds = []; + for (var _i = 2; _i < arguments.length; _i++) { + scriptKinds[_i - 2] = arguments[_i]; + } + var scriptKind = getScriptKind(fileName, host); + return ts.forEach(scriptKinds, function (k) { return k === scriptKind; }); + } + ts.scriptKindIs = scriptKindIs; + function getScriptKind(fileName, host) { + var scriptKind; + if (host && host.getScriptKind) { + scriptKind = host.getScriptKind(fileName); + } + if (!scriptKind) { + scriptKind = ts.getScriptKindFromFileName(fileName); + } + return ts.ensureScriptKind(fileName, scriptKind); + } + ts.getScriptKind = getScriptKind; + function sanitizeConfigFile(configFileName, content) { + var options = { + fileName: "config.js", + compilerOptions: { + target: 2, + removeComments: true + }, + reportDiagnostics: true + }; + var _a = ts.transpileModule("(" + content + ")", options), outputText = _a.outputText, diagnostics = _a.diagnostics; + var trimmedOutput = outputText.trim(); + for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { + var diagnostic = diagnostics_2[_i]; + diagnostic.start = diagnostic.start - 1; + } + var _b = ts.parseConfigFileTextToJson(configFileName, trimmedOutput.substring(1, trimmedOutput.length - 2), false), config = _b.config, error = _b.error; + return { + configJsonObject: config || {}, + diagnostics: error ? ts.concatenate(diagnostics, [error]) : diagnostics + }; + } + ts.sanitizeConfigFile = sanitizeConfigFile; +})(ts || (ts = {})); var ts; (function (ts) { - var Completions; - (function (Completions) { - function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { - if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); + var BreakpointResolver; + (function (BreakpointResolver) { + function spanInSourceFileAtLocation(sourceFile, position) { + if (sourceFile.isDeclarationFile) { + return undefined; } - if (ts.isInString(sourceFile, position)) { - return getStringLiteralCompletionEntries(sourceFile, position); + var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); + var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { + tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + return undefined; + } } - var completionData = getCompletionData(typeChecker, log, sourceFile, position); - if (!completionData) { + if (ts.isInAmbientContext(tokenAtLocation)) { return undefined; } - var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; - if (isJsDocTagName) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; + return spanInNode(tokenAtLocation); + function textSpan(startNode, endNode) { + var start = startNode.decorators ? + ts.skipTrivia(sourceFile.text, startNode.decorators.end) : + startNode.getStart(sourceFile); + return ts.createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } - var entries = []; - if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); - ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + function textSpanEndingAtNextToken(startNode, previousTokenToFindNextEndToken) { + return textSpan(startNode, ts.findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent)); } - else { - if (!symbols || symbols.length === 0) { - if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 245) { - var tagName = location.parent.parent.openingElement.tagName; - entries.push({ - name: tagName.text, - kind: undefined, - kindModifiers: undefined, - sortText: "0" - }); - } - else { - return undefined; - } + function spanInNodeIfStartsOnSameLine(node, otherwiseOnNode) { + if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) { + return spanInNode(node); } - getCompletionEntriesFromSymbols(symbols, entries, location, true); + return spanInNode(otherwiseOnNode); } - if (!isMemberCompletion && !isJsDocTagName) { - ts.addRange(entries, keywordCompletions); + function spanInNodeArray(nodeArray) { + return ts.createTextSpanFromBounds(ts.skipTrivia(sourceFile.text, nodeArray.pos), nodeArray.end); } - return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; - function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { - var entries = []; - var nameTable = ts.getNameTable(sourceFile); - for (var name_47 in nameTable) { - if (nameTable[name_47] === position) { - continue; - } - if (!uniqueNames[name_47]) { - uniqueNames[name_47] = name_47; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), compilerOptions.target, true); - if (displayName) { - var entry = { - name: displayName, - kind: ts.ScriptElementKind.warning, - kindModifiers: "", - sortText: "1" - }; - entries.push(entry); - } - } - } - return entries; + function spanInPreviousNode(node) { + return spanInNode(ts.findPrecedingToken(node.pos, sourceFile)); } - function createCompletionEntry(symbol, location, performCharacterChecks) { - var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); - if (!displayName) { - return undefined; - } - return { - name: displayName, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" - }; + function spanInNextNode(node) { + return spanInNode(ts.findNextToken(node, node.parent)); } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { - var start = ts.timestamp(); - var uniqueNames = ts.createMap(); - if (symbols) { - for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { - var symbol = symbols_4[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks); - if (entry) { - var id = ts.escapeIdentifier(entry.name); - if (!uniqueNames[id]) { - entries.push(entry); - uniqueNames[id] = id; + function spanInNode(node) { + if (node) { + switch (node.kind) { + case 201: + return spanInVariableDeclaration(node.declarationList.declarations[0]); + case 219: + case 146: + case 145: + return spanInVariableDeclaration(node); + case 143: + return spanInParameterDeclaration(node); + case 221: + case 148: + case 147: + case 150: + case 151: + case 149: + case 180: + case 181: + return spanInFunctionDeclaration(node); + case 200: + if (ts.isFunctionBlock(node)) { + return spanInFunctionBlock(node); } - } + case 227: + return spanInBlock(node); + case 252: + return spanInBlock(node.block); + case 203: + return textSpan(node.expression); + case 212: + return textSpan(node.getChildAt(0), node.expression); + case 206: + return textSpanEndingAtNextToken(node, node.expression); + case 205: + return spanInNode(node.statement); + case 218: + return textSpan(node.getChildAt(0)); + case 204: + return textSpanEndingAtNextToken(node, node.expression); + case 215: + return spanInNode(node.statement); + case 211: + case 210: + return textSpan(node.getChildAt(0), node.label); + case 207: + return spanInForStatement(node); + case 208: + return textSpanEndingAtNextToken(node, node.expression); + case 209: + return spanInInitializerOfForLike(node); + case 214: + return textSpanEndingAtNextToken(node, node.expression); + case 249: + case 250: + return spanInNode(node.statements[0]); + case 217: + return spanInBlock(node.tryBlock); + case 216: + return textSpan(node, node.expression); + case 236: + return textSpan(node, node.expression); + case 230: + return textSpan(node, node.moduleReference); + case 231: + return textSpan(node, node.moduleSpecifier); + case 237: + return textSpan(node, node.moduleSpecifier); + case 226: + if (ts.getModuleInstanceState(node) !== 1) { + return undefined; + } + case 222: + case 225: + case 255: + case 170: + return textSpan(node); + case 213: + return spanInNode(node.statement); + case 144: + return spanInNodeArray(node.parent.decorators); + case 168: + case 169: + return spanInBindingPattern(node); + case 223: + case 224: + return undefined; + case 24: + case 1: + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); + case 25: + return spanInPreviousNode(node); + case 16: + return spanInOpenBraceToken(node); + case 17: + return spanInCloseBraceToken(node); + case 21: + return spanInCloseBracketToken(node); + case 18: + return spanInOpenParenToken(node); + case 19: + return spanInCloseParenToken(node); + case 55: + return spanInColonToken(node); + case 28: + case 26: + return spanInGreaterThanOrLessThanToken(node); + case 105: + return spanInWhileKeyword(node); + case 81: + case 73: + case 86: + return spanInNextNode(node); + case 139: + return spanInOfKeyword(node); + default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); + } + if ((node.kind === 70 || + node.kind == 192 || + node.kind === 253 || + node.kind === 254) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + return textSpan(node); + } + if (node.kind === 188) { + var binaryExpression = node; + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { + return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); + } + if (binaryExpression.operatorToken.kind === 57 && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { + return textSpan(node); + } + if (binaryExpression.operatorToken.kind === 25) { + return spanInNode(binaryExpression.left); + } + } + if (ts.isPartOfExpression(node)) { + switch (node.parent.kind) { + case 205: + return spanInPreviousNode(node); + case 144: + return spanInNode(node.parent); + case 207: + case 209: + return textSpan(node); + case 188: + if (node.parent.operatorToken.kind === 25) { + return textSpan(node); + } + break; + case 181: + if (node.parent.body === node) { + return textSpan(node); + } + break; + } + } + if (node.parent.kind === 253 && + node.parent.name === node && + !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { + return spanInNode(node.parent.initializer); + } + if (node.parent.kind === 178 && node.parent.type === node) { + return spanInNextNode(node.parent.type); + } + if (ts.isFunctionLike(node.parent) && node.parent.type === node) { + return spanInPreviousNode(node); + } + if ((node.parent.kind === 219 || + node.parent.kind === 143)) { + var paramOrVarDecl = node.parent; + if (paramOrVarDecl.initializer === node || + paramOrVarDecl.type === node || + ts.isAssignmentOperator(node.kind)) { + return spanInPreviousNode(node); + } + } + if (node.parent.kind === 188) { + var binaryExpression = node.parent; + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && + (binaryExpression.right === node || + binaryExpression.operatorToken === node)) { + return spanInPreviousNode(node); + } + } + return spanInNode(node.parent); } } - log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniqueNames; - } - function getStringLiteralCompletionEntries(sourceFile, position) { - var node = ts.findPrecedingToken(position, sourceFile); - if (!node || node.kind !== 9) { - return undefined; - } - if (node.parent.kind === 253 && - node.parent.parent.kind === 171 && - node.parent.name === node) { - return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); + function textSpanFromVariableDeclaration(variableDeclaration) { + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] === variableDeclaration) { + return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); + } + else { + return textSpan(variableDeclaration); + } } - else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { - return getStringLiteralCompletionEntriesFromElementAccess(node.parent); + function spanInVariableDeclaration(variableDeclaration) { + if (variableDeclaration.parent.parent.kind === 208) { + return spanInNode(variableDeclaration.parent.parent); + } + if (ts.isBindingPattern(variableDeclaration.name)) { + return spanInBindingPattern(variableDeclaration.name); + } + if (variableDeclaration.initializer || + ts.hasModifier(variableDeclaration, 1) || + variableDeclaration.parent.parent.kind === 209) { + return textSpanFromVariableDeclaration(variableDeclaration); + } + var declarations = variableDeclaration.parent.declarations; + if (declarations && declarations[0] !== variableDeclaration) { + return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent)); + } } - else if (node.parent.kind === 230 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { - return getStringLiteralCompletionEntriesFromModuleNames(node); + function canHaveSpanInParameterDeclaration(parameter) { + return !!parameter.initializer || parameter.dotDotDotToken !== undefined || + ts.hasModifier(parameter, 4 | 8); } - else { - var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); - if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + function spanInParameterDeclaration(parameter) { + if (ts.isBindingPattern(parameter.name)) { + return spanInBindingPattern(parameter.name); } - return getStringLiteralCompletionEntriesFromContextualType(node); - } - } - function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { - var type = typeChecker.getContextualType(element.parent); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + else if (canHaveSpanInParameterDeclaration(parameter)) { + return textSpan(parameter); } - } - } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { - var candidates = []; - var entries = []; - typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); - for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { - var candidate = candidates_3[_i]; - if (candidate.parameters.length > argumentInfo.argumentIndex) { - var parameter = candidate.parameters[argumentInfo.argumentIndex]; - addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); + else { + var functionDeclaration = parameter.parent; + var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter); + if (indexOfParameter) { + return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]); + } + else { + return spanInNode(functionDeclaration.body); + } } } - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { + return ts.hasModifier(functionDeclaration, 1) || + (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); } - return undefined; - } - function getStringLiteralCompletionEntriesFromElementAccess(node) { - var type = typeChecker.getTypeAtLocation(node.expression); - var entries = []; - if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); - if (entries.length) { - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + function spanInFunctionDeclaration(functionDeclaration) { + if (!functionDeclaration.body) { + return undefined; } - } - return undefined; - } - function getStringLiteralCompletionEntriesFromContextualType(node) { - var type = typeChecker.getContextualType(node); - if (type) { - var entries_2 = []; - addStringLiteralCompletionsFromType(type, entries_2); - if (entries_2.length) { - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; + if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) { + return textSpan(functionDeclaration); } + return spanInNode(functionDeclaration.body); } - return undefined; - } - function addStringLiteralCompletionsFromType(type, result) { - if (!type) { - return; - } - if (type.flags & 524288) { - ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + function spanInFunctionBlock(block) { + var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken(); + if (canFunctionHaveSpanInWholeDeclaration(block.parent)) { + return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock); + } + return spanInNode(nodeForSpanInBlock); } - else { - if (type.flags & 32) { - result.push({ - name: type.text, - kindModifiers: ts.ScriptElementKindModifier.none, - kind: ts.ScriptElementKind.variableElement, - sortText: "0" - }); + function spanInBlock(block) { + switch (block.parent.kind) { + case 226: + if (ts.getModuleInstanceState(block.parent) !== 1) { + return undefined; + } + case 206: + case 204: + case 208: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 207: + case 209: + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } + return spanInNode(block.statements[0]); } - } - function getStringLiteralCompletionEntriesFromModuleNames(node) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); + function spanInInitializerOfForLike(forLikeStatement) { + if (forLikeStatement.initializer.kind === 220) { + var variableDeclarationList = forLikeStatement.initializer; + if (variableDeclarationList.declarations.length > 0) { + return spanInNode(variableDeclarationList.declarations[0]); + } } else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); + return spanInNode(forLikeStatement.initializer); } } - else { - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; + function spanInForStatement(forStatement) { + if (forStatement.initializer) { + return spanInInitializerOfForLike(forStatement); } - } - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); - } - return result; - } - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); - if (files) { - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles[foundFileName]) { - foundFiles[foundFileName] = true; - } - } - for (var foundFile in foundFiles) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - } + if (forStatement.condition) { + return textSpan(forStatement.condition); } - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } + if (forStatement.incrementor) { + return textSpan(forStatement.incrementor); } } - return result; - } - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } + function spanInBindingPattern(bindingPattern) { + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); } + if (bindingPattern.parent.kind === 170) { + return textSpan(bindingPattern.parent); + } + return textSpanFromVariableDeclaration(bindingPattern.parent); } - else { - result = []; + function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { + ts.Debug.assert(node.kind !== 169 && node.kind !== 168); + var elements = node.kind === 171 ? + node.elements : + node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 ? element : undefined; }); + if (firstBindingElement) { + return spanInNode(firstBindingElement); + } + return textSpan(node.parent.kind === 188 ? node.parent : node); } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + function spanInOpenBraceToken(node) { + switch (node.parent.kind) { + case 225: + var enumDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); + case 222: + var classDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); + case 228: + return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); + } + return spanInNode(node.parent); } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + function spanInCloseBraceToken(node) { + switch (node.parent.kind) { + case 227: + if (ts.getModuleInstanceState(node.parent.parent) !== 1) { + return undefined; } - return result; - } + case 225: + case 222: + return textSpan(node); + case 200: + if (ts.isFunctionBlock(node.parent)) { + return textSpan(node); + } + case 252: + return spanInNode(ts.lastOrUndefined(node.parent.statements)); + case 228: + var caseBlock = node.parent; + var lastClause = ts.lastOrUndefined(caseBlock.clauses); + if (lastClause) { + return spanInNode(ts.lastOrUndefined(lastClause.statements)); + } + return undefined; + case 168: + var bindingPattern = node.parent; + return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); + default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + var objectLiteral = node.parent; + return textSpan(ts.lastOrUndefined(objectLiteral.properties) || objectLiteral); + } + return spanInNode(node.parent); } } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } + function spanInCloseBracketToken(node) { + switch (node.parent.kind) { + case 169: + var bindingPattern = node.parent; + return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); + default: + if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + var arrayLiteral = node.parent; + return textSpan(ts.lastOrUndefined(arrayLiteral.elements) || arrayLiteral); } - } + return spanInNode(node.parent); } } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { - return undefined; - } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); + function spanInOpenParenToken(node) { + if (node.parent.kind === 205 || + node.parent.kind === 175 || + node.parent.kind === 176) { + return spanInPreviousNode(node); } - else { - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + if (node.parent.kind === 179) { + return spanInNextNode(node); } + return spanInNode(node.parent); } - return completionInfo; - } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + function spanInCloseParenToken(node) { + switch (node.parent.kind) { + case 180: + case 221: + case 181: + case 148: + case 147: + case 150: + case 151: + case 149: + case 206: + case 205: + case 207: + case 209: + case 175: + case 176: + case 179: + return spanInPreviousNode(node); + default: + return spanInNode(node.parent); } } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); - } + function spanInColonToken(node) { + if (ts.isFunctionLike(node.parent) || + node.parent.kind === 253 || + node.parent.kind === 143) { + return spanInPreviousNode(node); } + return spanInNode(node.parent); } - if (host.getDirectories) { - for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + function spanInGreaterThanOrLessThanToken(node) { + if (node.parent.kind === 178) { + return spanInNextNode(node); } + return spanInNode(node.parent); } - return result; - } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } + function spanInWhileKeyword(node) { + if (node.parent.kind === 205) { + return textSpanEndingAtNextToken(node, node.parent.expression); } + return spanInNode(node.parent); } - } - function findPackageJsons(currentDir) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { - break; - } - currentDir = parent_16; - } - else { - break; + function spanInOfKeyword(node) { + if (node.parent.kind === 209) { + return spanInNextNode(node); } + return spanInNode(node.parent); } - return paths; } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } + } + BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; + })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function createClassifier() { + var scanner = ts.createScanner(4, false); + var noRegexTable = []; + noRegexTable[70] = true; + noRegexTable[9] = true; + noRegexTable[8] = true; + noRegexTable[11] = true; + noRegexTable[98] = true; + noRegexTable[42] = true; + noRegexTable[43] = true; + noRegexTable[19] = true; + noRegexTable[21] = true; + noRegexTable[17] = true; + noRegexTable[100] = true; + noRegexTable[85] = true; + var templateStack = []; + function canFollow(keyword1, keyword2) { + if (ts.isAccessibilityModifier(keyword1)) { + if (keyword2 === 124 || + keyword2 === 132 || + keyword2 === 122 || + keyword2 === 114) { + return true; } + return false; } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 || slashCharCode === 92; + return true; + } + function convertClassifications(classifications, text) { + var entries = []; + var dense = classifications.spans; + var lastEnd = 0; + for (var i = 0, n = dense.length; i < n; i += 3) { + var start = dense[i]; + var length_4 = dense[i + 1]; + var type = dense[i + 2]; + if (lastEnd >= 0) { + var whitespaceLength_1 = start - lastEnd; + if (whitespaceLength_1 > 0) { + entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); + } } - return false; + entries.push({ length: length_4, classification: convertClassification(type) }); + lastEnd = start + length_4; } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + var whitespaceLength = text.length - lastEnd; + if (whitespaceLength > 0) { + entries.push({ length: whitespaceLength, classification: ts.TokenClass.Whitespace }); } + return { entries: entries, finalLexState: classifications.endOfLineState }; } - Completions.getCompletionsAtPosition = getCompletionsAtPosition; - function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { - var completionData = getCompletionData(typeChecker, log, sourceFile, position); - if (completionData) { - var symbols = completionData.symbols, location_2 = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_2) === entryName ? s : undefined; }); - if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_2, location_2, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; - return { - name: entryName, - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - kind: symbolKind, - displayParts: displayParts, - documentation: documentation - }; - } - } - var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); - if (keywordCompletion) { - return { - name: entryName, - kind: ts.ScriptElementKind.keyword, - kindModifiers: ts.ScriptElementKindModifier.none, - displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined - }; + function convertClassification(type) { + switch (type) { + case 1: return ts.TokenClass.Comment; + case 3: return ts.TokenClass.Keyword; + case 4: return ts.TokenClass.NumberLiteral; + case 5: return ts.TokenClass.Operator; + case 6: return ts.TokenClass.StringLiteral; + case 8: return ts.TokenClass.Whitespace; + case 10: return ts.TokenClass.Punctuation; + case 2: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 9: + case 17: + default: + return ts.TokenClass.Identifier; } - return undefined; } - Completions.getCompletionEntryDetails = getCompletionEntryDetails; - function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { - var completionData = getCompletionData(typeChecker, log, sourceFile, position); - if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); - } - return undefined; + function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { + return convertClassifications(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } - Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; - function getCompletionData(typeChecker, log, sourceFile, position) { - var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); - var isJsDocTagName = false; - var start = ts.timestamp(); - var currentToken = ts.getTokenAtPosition(sourceFile, position); - log("getCompletionData: Get current token: " + (ts.timestamp() - start)); - start = ts.timestamp(); - var insideComment = ts.isInsideComment(sourceFile, currentToken, position); - log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); - if (insideComment) { - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { - isJsDocTagName = true; - } - var insideJsDocTagExpression = false; - var tag = ts.getJsDocTagAtPosition(sourceFile, position); - if (tag) { - if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; - } - switch (tag.kind) { - case 277: - case 275: - case 276: - var tagWithExpression = tag; - if (tagWithExpression.typeExpression) { - insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; - } - break; - } - } - if (isJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; - } - if (!insideJsDocTagExpression) { - log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); - return undefined; - } + function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { + var offset = 0; + var token = 0; + var lastNonTriviaToken = 0; + while (templateStack.length > 0) { + templateStack.pop(); } - start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile); - log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); - var contextToken = previousToken; - if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { - var start_2 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); - log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_2)); + switch (lexState) { + case 3: + text = "\"\\\n" + text; + offset = 3; + break; + case 2: + text = "'\\\n" + text; + offset = 3; + break; + case 1: + text = "/*\n" + text; + offset = 3; + break; + case 4: + text = "`\n" + text; + offset = 2; + break; + case 5: + text = "}\n" + text; + offset = 2; + case 6: + templateStack.push(13); + break; } - var node = currentToken; - var isRightOfDot = false; - var isRightOfOpenTag = false; - var isStartingCloseTag = false; - var location = ts.getTouchingPropertyName(sourceFile, position); - if (contextToken) { - if (isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21) { - if (parent_17.kind === 172) { - node = contextToken.parent.expression; - isRightOfDot = true; + scanner.setText(text); + var result = { + endOfLineState: 0, + spans: [] + }; + var angleBracketStack = 0; + do { + token = scanner.scan(); + if (!ts.isTrivia(token)) { + if ((token === 40 || token === 62) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11) { + token = 11; + } } - else if (parent_17.kind === 139) { - node = contextToken.parent.left; - isRightOfDot = true; + else if (lastNonTriviaToken === 22 && isKeyword(token)) { + token = 70; } - else { - return undefined; + else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { + token = 70; } - } - else if (sourceFile.languageVariant === 1) { - if (kind === 25) { - isRightOfOpenTag = true; - location = contextToken; + else if (lastNonTriviaToken === 70 && + token === 26) { + angleBracketStack++; } - else if (kind === 39 && contextToken.parent.kind === 245) { - isStartingCloseTag = true; - location = contextToken; + else if (token === 28 && angleBracketStack > 0) { + angleBracketStack--; } - } - } - var semanticStart = ts.timestamp(); - var isGlobalCompletion = false; - var isMemberCompletion; - var isNewIdentifierLocation; - var symbols = []; - if (isRightOfDot) { - getTypeScriptMemberSymbols(); - } - else if (isRightOfOpenTag) { - var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); - if (tryGetGlobalSymbols()) { - symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & (107455 | 8388608)); })); - } - else { - symbols = tagSymbols; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else if (isStartingCloseTag) { - var tagName = contextToken.parent.parent.openingElement.tagName; - var tagSymbol = typeChecker.getSymbolAtLocation(tagName); - if (!typeChecker.isUnknownSymbol(tagSymbol)) { - symbols = [tagSymbol]; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - } - else { - if (!tryGetGlobalSymbols()) { - return undefined; - } - isGlobalCompletion = true; - } - log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; - function getTypeScriptMemberSymbols() { - isGlobalCompletion = false; - isMemberCompletion = true; - isNewIdentifierLocation = false; - if (node.kind === 69 || node.kind === 139 || node.kind === 172) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol && symbol.flags & 8388608) { - symbol = typeChecker.getAliasedSymbol(symbol); + else if (token === 118 || + token === 133 || + token === 131 || + token === 121 || + token === 134) { + if (angleBracketStack > 0 && !syntacticClassifierAbsent) { + token = 70; + } } - if (symbol && symbol.flags & 1952) { - var exportedSymbols = typeChecker.getExportsOfModule(symbol); - ts.forEach(exportedSymbols, function (symbol) { - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); - } - }); + else if (token === 13) { + templateStack.push(token); } - } - var type = typeChecker.getTypeAtLocation(node); - addTypeProperties(type); - } - function addTypeProperties(type) { - if (type) { - for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { - var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { - symbols.push(symbol); + else if (token === 16) { + if (templateStack.length > 0) { + templateStack.push(token); } } - if (isJavaScriptFile && type.flags & 524288) { - var unionType = type; - for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { - var elementType = _c[_b]; - addTypeProperties(elementType); + else if (token === 17) { + if (templateStack.length > 0) { + var lastTemplateStackToken = ts.lastOrUndefined(templateStack); + if (lastTemplateStackToken === 13) { + token = scanner.reScanTemplateToken(); + if (token === 15) { + templateStack.pop(); + } + else { + ts.Debug.assert(token === 14, "Should have been a template middle. Was " + token); + } + } + else { + ts.Debug.assert(lastTemplateStackToken === 16, "Should have been an open brace. Was: " + token); + templateStack.pop(); + } } } + lastNonTriviaToken = token; } - } - function tryGetGlobalSymbols() { - var objectLikeContainer; - var namedImportsOrExports; - var jsxContainer; - if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { - return tryGetObjectLikeCompletionSymbols(objectLikeContainer); - } - if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { - return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); - } - if (jsxContainer = tryGetContainingJsxElement(contextToken)) { - var attrsType = void 0; - if ((jsxContainer.kind === 242) || (jsxContainer.kind === 243)) { - attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; - if (attrsType) { - symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); - isMemberCompletion = true; - isNewIdentifierLocation = false; - return true; + processToken(); + } while (token !== 1); + return result; + function processToken() { + var start = scanner.getTokenPos(); + var end = scanner.getTextPos(); + addResult(start, end, classFromKind(token)); + if (end >= text.length) { + if (token === 9) { + var tokenText = scanner.getTokenText(); + if (scanner.isUnterminated()) { + var lastCharIndex = tokenText.length - 1; + var numBackslashes = 0; + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92) { + numBackslashes++; + } + if (numBackslashes & 1) { + var quoteChar = tokenText.charCodeAt(0); + result.endOfLineState = quoteChar === 34 + ? 3 + : 2; + } } } - } - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - var adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - var symbolMeanings = 793064 | 107455 | 1920 | 8388608; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); - return true; - } - function getScopeNode(initialToken, position, sourceFile) { - var scope = initialToken; - while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { - scope = scope.parent; - } - return scope; - } - function isCompletionListBlocker(contextToken) { - var start = ts.timestamp(); - var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || - isSolelyIdentifierDefinitionLocation(contextToken) || - isDotOfNumericLiteral(contextToken) || - isInJsxText(contextToken); - log("getCompletionsAtPosition: isCompletionListBlocker: " + (ts.timestamp() - start)); - return result; - } - function isInJsxText(contextToken) { - if (contextToken.kind === 244) { - return true; - } - if (contextToken.kind === 27 && contextToken.parent) { - if (contextToken.parent.kind === 243) { - return true; - } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 242) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241; - } - } - return false; - } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case 24: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 170 - || containingNodeKind === 187 - || containingNodeKind === 156; - case 17: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 178 - || containingNodeKind === 164; - case 19: - return containingNodeKind === 170 - || containingNodeKind === 153 - || containingNodeKind === 140; - case 125: - case 126: - return true; - case 21: - return containingNodeKind === 225; - case 15: - return containingNodeKind === 221; - case 56: - return containingNodeKind === 218 - || containingNodeKind === 187; - case 12: - return containingNodeKind === 189; - case 13: - return containingNodeKind === 197; - case 112: - case 110: - case 111: - return containingNodeKind === 145; - } - switch (previousToken.getText()) { - case "public": - case "protected": - case "private": - return true; - } - } - return false; - } - function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 - || contextToken.kind === 10 - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_3 = contextToken.getStart(); - var end = contextToken.getEnd(); - if (start_3 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 10; + else if (token === 3) { + if (scanner.isUnterminated()) { + result.endOfLineState = 1; + } } - } - return false; - } - function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { - isMemberCompletion = true; - var typeForObject; - var existingMembers; - if (objectLikeContainer.kind === 171) { - isNewIdentifierLocation = true; - typeForObject = typeChecker.getContextualType(objectLikeContainer); - typeForObject = typeForObject && typeForObject.getNonNullableType(); - existingMembers = objectLikeContainer.properties; - } - else if (objectLikeContainer.kind === 167) { - isNewIdentifierLocation = false; - var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); - if (ts.isVariableLike(rootDeclaration)) { - var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142) { - if (ts.isExpression(rootDeclaration.parent)) { - canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); + else if (ts.isTemplateLiteralKind(token)) { + if (scanner.isUnterminated()) { + if (token === 15) { + result.endOfLineState = 5; } - else if (rootDeclaration.parent.kind === 147 || rootDeclaration.parent.kind === 150) { - canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); + else if (token === 12) { + result.endOfLineState = 4; + } + else { + ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } - } - if (canGetType) { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); - existingMembers = objectLikeContainer.elements; } } - else { - ts.Debug.fail("Root declaration is not variable-like."); + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13) { + result.endOfLineState = 6; } } - else { - ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + function addResult(start, end, classification) { + if (classification === 8) { + return; } - if (!typeForObject) { - return false; + if (start === 0 && offset > 0) { + start += offset; } - var typeMembers = typeChecker.getPropertiesOfType(typeForObject); - if (typeMembers && typeMembers.length > 0) { - symbols = filterObjectMembersList(typeMembers, existingMembers); + start -= offset; + end -= offset; + var length = end - start; + if (length > 0) { + result.spans.push(start); + result.spans.push(length); + result.spans.push(classification); } - return true; } - function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 ? - 230 : - 236; - var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); - var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; - if (!moduleSpecifier) { + } + function isBinaryExpressionOperatorToken(token) { + switch (token) { + case 38: + case 40: + case 41: + case 36: + case 37: + case 44: + case 45: + case 46: + case 26: + case 28: + case 29: + case 30: + case 92: + case 91: + case 117: + case 31: + case 32: + case 33: + case 34: + case 47: + case 49: + case 48: + case 52: + case 53: + case 68: + case 67: + case 69: + case 64: + case 65: + case 66: + case 58: + case 59: + case 60: + case 62: + case 63: + case 57: + case 25: + return true; + default: return false; - } - isMemberCompletion = true; - isNewIdentifierLocation = false; - var exports; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } - symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; - return true; } - function tryGetObjectLikeCompletionContainer(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15: - case 24: - var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 || parent_18.kind === 167)) { - return parent_18; - } - break; - } - } - return undefined; + } + function isPrefixUnaryExpressionOperatorToken(token) { + switch (token) { + case 36: + case 37: + case 51: + case 50: + case 42: + case 43: + return true; + default: + return false; } - function tryGetNamedImportsOrExportsForCompletion(contextToken) { - if (contextToken) { - switch (contextToken.kind) { - case 15: - case 24: - switch (contextToken.parent.kind) { - case 233: - case 237: - return contextToken.parent; - } - } - } - return undefined; + } + function isKeyword(token) { + return token >= 71 && token <= 139; + } + function classFromKind(token) { + if (isKeyword(token)) { + return 3; } - function tryGetContainingJsxElement(contextToken) { - if (contextToken) { - var parent_19 = contextToken.parent; - switch (contextToken.kind) { - case 26: - case 39: - case 69: - case 246: - case 247: - if (parent_19 && (parent_19.kind === 242 || parent_19.kind === 243)) { - return parent_19; - } - else if (parent_19.kind === 246) { - return parent_19.parent; - } - break; - case 9: - if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { - return parent_19.parent; - } - break; - case 16: - if (parent_19 && - parent_19.kind === 248 && - parent_19.parent && - (parent_19.parent.kind === 246)) { - return parent_19.parent.parent; - } - if (parent_19 && parent_19.kind === 247) { - return parent_19.parent; - } - break; + else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { + return 5; + } + else if (token >= 16 && token <= 69) { + return 10; + } + switch (token) { + case 8: + return 4; + case 9: + return 6; + case 11: + return 7; + case 7: + case 3: + case 2: + return 1; + case 5: + case 4: + return 8; + case 70: + default: + if (ts.isTemplateLiteralKind(token)) { + return 6; } - } - return undefined; + return 2; } - function isFunction(kind) { - switch (kind) { - case 179: - case 180: - case 220: - case 147: - case 146: - case 149: - case 150: - case 151: - case 152: - case 153: - return true; - } - return false; + } + return { + getClassificationsForLine: getClassificationsForLine, + getEncodedLexicalClassifications: getEncodedLexicalClassifications + }; + } + ts.createClassifier = createClassifier; + function getSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span) { + return convertClassifications(getEncodedSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span)); + } + ts.getSemanticClassifications = getSemanticClassifications; + function checkForClassificationCancellation(cancellationToken, kind) { + switch (kind) { + case 226: + case 222: + case 223: + case 221: + cancellationToken.throwIfCancellationRequested(); + } + } + function getEncodedSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span) { + var result = []; + processNode(sourceFile); + return { spans: result, endOfLineState: 0 }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifySymbol(symbol, meaningAtPosition) { + var flags = symbol.getFlags(); + if ((flags & 788448) === 0) { + return; } - function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; - switch (contextToken.kind) { - case 24: - return containingNodeKind === 218 || - containingNodeKind === 219 || - containingNodeKind === 200 || - containingNodeKind === 224 || - isFunction(containingNodeKind) || - containingNodeKind === 221 || - containingNodeKind === 192 || - containingNodeKind === 222 || - containingNodeKind === 168 || - containingNodeKind === 223; - case 21: - return containingNodeKind === 168; - case 54: - return containingNodeKind === 169; - case 19: - return containingNodeKind === 168; - case 17: - return containingNodeKind === 252 || - isFunction(containingNodeKind); - case 15: - return containingNodeKind === 224 || - containingNodeKind === 222 || - containingNodeKind === 159; - case 23: - return containingNodeKind === 144 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 || - contextToken.parent.parent.kind === 159); - case 25: - return containingNodeKind === 221 || - containingNodeKind === 192 || - containingNodeKind === 222 || - containingNodeKind === 223 || - isFunction(containingNodeKind); - case 113: - return containingNodeKind === 145; - case 22: - return containingNodeKind === 142 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168); - case 112: - case 110: - case 111: - return containingNodeKind === 142; - case 116: - return containingNodeKind === 234 || - containingNodeKind === 238 || - containingNodeKind === 232; - case 73: - case 81: - case 107: - case 87: - case 102: - case 123: - case 131: - case 89: - case 108: - case 74: - case 114: - case 134: - return true; - } - switch (contextToken.getText()) { - case "abstract": - case "async": - case "class": - case "const": - case "declare": - case "enum": - case "function": - case "interface": - case "let": - case "private": - case "protected": - case "public": - case "static": - case "var": - case "yield": - return true; - } - return false; + if (flags & 32) { + return 11; } - function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8) { - var text = contextToken.getFullText(); - return text.charAt(text.length - 1) === "."; - } - return false; + else if (flags & 384) { + return 12; } - function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { - var existingImportsOrExports = ts.createMap(); - for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { - var element = namedImportsOrExports_1[_i]; - if (element.getStart() <= position && position <= element.getEnd()) { - continue; - } - var name_48 = element.propertyName || element.name; - existingImportsOrExports[name_48.text] = true; + else if (flags & 524288) { + return 16; + } + else if (meaningAtPosition & 2) { + if (flags & 64) { + return 13; } - if (!ts.someProperties(existingImportsOrExports)) { - return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); + else if (flags & 262144) { + return 15; } - return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); } - function filterObjectMembersList(contextualMemberSymbols, existingMembers) { - if (!existingMembers || existingMembers.length === 0) { - return contextualMemberSymbols; + else if (flags & 1536) { + if (meaningAtPosition & 4 || + (meaningAtPosition & 1 && hasValueSideModule(symbol))) { + return 14; } - var existingMemberNames = ts.createMap(); - for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { - var m = existingMembers_1[_i]; - if (m.kind !== 253 && - m.kind !== 254 && - m.kind !== 169 && - m.kind !== 147) { - continue; - } - if (m.getStart() <= position && position <= m.getEnd()) { - continue; - } - var existingName = void 0; - if (m.kind === 169 && m.propertyName) { - if (m.propertyName.kind === 69) { - existingName = m.propertyName.text; + } + return undefined; + function hasValueSideModule(symbol) { + return ts.forEach(symbol.declarations, function (declaration) { + return declaration.kind === 226 && + ts.getModuleInstanceState(declaration) === 1; + }); + } + } + function processNode(node) { + if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { + var kind = node.kind; + checkForClassificationCancellation(cancellationToken, kind); + if (kind === 70 && !ts.nodeIsMissing(node)) { + var identifier = node; + if (classifiableNames[identifier.text]) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var type = classifySymbol(symbol, ts.getMeaningFromLocation(node)); + if (type) { + pushClassification(node.getStart(), node.getWidth(), type); + } } } - else { - existingName = m.name.text; - } - existingMemberNames[existingName] = true; } - return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); + ts.forEachChild(node, processNode); } - function filterJsxAttributes(symbols, attributes) { - var seenNames = ts.createMap(); - for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { - var attr = attributes_1[_i]; - if (attr.getStart() <= position && position <= attr.getEnd()) { + } + } + ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; + function getClassificationTypeName(type) { + switch (type) { + case 1: return ts.ClassificationTypeNames.comment; + case 2: return ts.ClassificationTypeNames.identifier; + case 3: return ts.ClassificationTypeNames.keyword; + case 4: return ts.ClassificationTypeNames.numericLiteral; + case 5: return ts.ClassificationTypeNames.operator; + case 6: return ts.ClassificationTypeNames.stringLiteral; + case 8: return ts.ClassificationTypeNames.whiteSpace; + case 9: return ts.ClassificationTypeNames.text; + case 10: return ts.ClassificationTypeNames.punctuation; + case 11: return ts.ClassificationTypeNames.className; + case 12: return ts.ClassificationTypeNames.enumName; + case 13: return ts.ClassificationTypeNames.interfaceName; + case 14: return ts.ClassificationTypeNames.moduleName; + case 15: return ts.ClassificationTypeNames.typeParameterName; + case 16: return ts.ClassificationTypeNames.typeAliasName; + case 17: return ts.ClassificationTypeNames.parameterName; + case 18: return ts.ClassificationTypeNames.docCommentTagName; + case 19: return ts.ClassificationTypeNames.jsxOpenTagName; + case 20: return ts.ClassificationTypeNames.jsxCloseTagName; + case 21: return ts.ClassificationTypeNames.jsxSelfClosingTagName; + case 22: return ts.ClassificationTypeNames.jsxAttribute; + case 23: return ts.ClassificationTypeNames.jsxText; + case 24: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; + } + } + function convertClassifications(classifications) { + 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) { + result.push({ + textSpan: ts.createTextSpan(dense[i], dense[i + 1]), + classificationType: getClassificationTypeName(dense[i + 2]) + }); + } + return result; + } + function getSyntacticClassifications(cancellationToken, sourceFile, span) { + return convertClassifications(getEncodedSyntacticClassifications(cancellationToken, sourceFile, span)); + } + ts.getSyntacticClassifications = getSyntacticClassifications; + function getEncodedSyntacticClassifications(cancellationToken, sourceFile, span) { + var spanStart = span.start; + var spanLength = span.length; + var triviaScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); + var result = []; + processElement(sourceFile); + return { spans: result, endOfLineState: 0 }; + function pushClassification(start, length, type) { + result.push(start); + result.push(length); + result.push(type); + } + function classifyLeadingTriviaAndGetTokenStart(token) { + triviaScanner.setTextPos(token.pos); + while (true) { + var start = triviaScanner.getTextPos(); + if (!ts.couldStartTrivia(sourceFile.text, start)) { + return start; + } + var kind = triviaScanner.scan(); + var end = triviaScanner.getTextPos(); + var width = end - start; + if (!ts.isTrivia(kind)) { + return start; + } + if (kind === 4 || kind === 5) { + continue; + } + if (ts.isComment(kind)) { + classifyComment(token, kind, start, width); + triviaScanner.setTextPos(end); + continue; + } + if (kind === 7) { + var text = sourceFile.text; + var ch = text.charCodeAt(start); + if (ch === 60 || ch === 62) { + pushClassification(start, width, 1); continue; } - if (attr.kind === 246) { - seenNames[attr.name.text] = true; - } + ts.Debug.assert(ch === 61); + classifyDisabledMergeCode(text, start, end); } - return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); } } - function getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location) { - var displayName = ts.getDeclaredName(typeChecker, symbol, location); - if (displayName) { - var firstCharCode = displayName.charCodeAt(0); - if ((symbol.flags & 1920) && (firstCharCode === 39 || firstCharCode === 34)) { - return undefined; + function classifyComment(token, kind, start, width) { + if (kind === 3) { + var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); + if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { + docCommentAndDiagnostics.jsDoc.parent = token; + classifyJSDocComment(docCommentAndDiagnostics.jsDoc); + return; } } - return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); + pushCommentRange(start, width); } - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { - if (!name) { - return undefined; + function pushCommentRange(start, width) { + pushClassification(start, width, 1); + } + function classifyJSDocComment(docComment) { + var pos = docComment.pos; + if (docComment.tags) { + for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { + var tag = _a[_i]; + if (tag.pos !== pos) { + pushCommentRange(pos, tag.pos - pos); + } + pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, 10); + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); + pos = tag.tagName.end; + switch (tag.kind) { + case 275: + processJSDocParameterTag(tag); + break; + case 278: + processJSDocTemplateTag(tag); + break; + case 277: + processElement(tag.typeExpression); + break; + case 276: + processElement(tag.typeExpression); + break; + } + pos = tag.end; + } } - name = ts.stripQuotes(name); - if (!name) { - return undefined; + if (pos !== docComment.end) { + pushCommentRange(pos, docComment.end - pos); } - if (performCharacterChecks) { - if (!ts.isIdentifierText(name, target)) { - return undefined; + return; + function processJSDocParameterTag(tag) { + if (tag.preParameterName) { + pushCommentRange(pos, tag.preParameterName.pos - pos); + pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, 17); + pos = tag.preParameterName.end; + } + if (tag.typeExpression) { + pushCommentRange(pos, tag.typeExpression.pos - pos); + processElement(tag.typeExpression); + pos = tag.typeExpression.end; + } + if (tag.postParameterName) { + pushCommentRange(pos, tag.postParameterName.pos - pos); + pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, 17); + pos = tag.postParameterName.end; } } - return name; - } - var keywordCompletions = []; - for (var i = 70; i <= 138; i++) { - keywordCompletions.push({ - name: ts.tokenToString(i), - kind: ts.ScriptElementKind.keyword, - kindModifiers: ts.ScriptElementKindModifier.none, - sortText: "0" - }); - } - var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*= 0); + if (tokenWidth > 0) { + var type = classifiedElementName || classifyTokenType(node.kind, node); + if (type) { + pushClassification(tokenStart, tokenWidth, type); } - return undefined; - function convertReferencedSymbols(referencedSymbols) { - if (!referencedSymbols) { - return undefined; + } + return true; + } + function tryClassifyJsxElementName(token) { + switch (token.parent && token.parent.kind) { + case 244: + if (token.parent.tagName === token) { + return 19; } - var fileNameToDocumentHighlights = ts.createMap(); - var result = []; - for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { - var referencedSymbol = referencedSymbols_1[_i]; - for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { - var referenceEntry = _b[_a]; - var fileName = referenceEntry.fileName; - var documentHighlights = fileNameToDocumentHighlights[fileName]; - if (!documentHighlights) { - documentHighlights = { fileName: fileName, highlightSpans: [] }; - fileNameToDocumentHighlights[fileName] = documentHighlights; - result.push(documentHighlights); - } - documentHighlights.highlightSpans.push({ - textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference - }); - } + break; + case 245: + if (token.parent.tagName === token) { + return 20; } - return result; - } + break; + case 243: + if (token.parent.tagName === token) { + return 21; + } + break; + case 246: + if (token.parent.name === token) { + return 22; + } + break; } - function getSyntacticDocumentHighlights(node) { - var fileName = sourceFile.fileName; - var highlightSpans = getHighlightSpans(node); - if (!highlightSpans || highlightSpans.length === 0) { - return undefined; - } - return [{ fileName: fileName, highlightSpans: highlightSpans }]; - function hasKind(node, kind) { - return node !== undefined && node.kind === kind; - } - function parent(node) { - return node && node.parent; + return undefined; + } + function classifyTokenType(tokenKind, token) { + if (ts.isKeyword(tokenKind)) { + return 3; + } + if (tokenKind === 26 || tokenKind === 28) { + if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { + return 10; } - function getHighlightSpans(node) { - if (node) { - switch (node.kind) { - case 88: - case 80: - if (hasKind(node.parent, 203)) { - return getIfElseOccurrences(node.parent); - } - break; - case 94: - if (hasKind(node.parent, 211)) { - return getReturnOccurrences(node.parent); - } - break; - case 98: - if (hasKind(node.parent, 215)) { - return getThrowOccurrences(node.parent); - } - break; - case 72: - if (hasKind(parent(parent(node)), 216)) { - return getTryCatchFinallyOccurrences(node.parent.parent); - } - break; - case 100: - case 85: - if (hasKind(parent(node), 216)) { - return getTryCatchFinallyOccurrences(node.parent); - } - break; - case 96: - if (hasKind(node.parent, 213)) { - return getSwitchCaseDefaultOccurrences(node.parent); - } - break; - case 71: - case 77: - if (hasKind(parent(parent(parent(node))), 213)) { - return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); - } - break; - case 70: - case 75: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { - return getBreakOrContinueStatementOccurrences(node.parent); - } - break; - case 86: - if (hasKind(node.parent, 206) || - hasKind(node.parent, 207) || - hasKind(node.parent, 208)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 104: - case 79: - if (hasKind(node.parent, 205) || hasKind(node.parent, 204)) { - return getLoopBreakContinueOccurrences(node.parent); - } - break; - case 121: - if (hasKind(node.parent, 148)) { - return getConstructorOccurrences(node.parent); - } - break; - case 123: - case 131: - if (hasKind(node.parent, 149) || hasKind(node.parent, 150)) { - return getGetAndSetOccurrences(node.parent); - } - break; - default: - if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200)) { - return getModifierOccurrences(node.kind, node.parent); - } + } + if (ts.isPunctuation(tokenKind)) { + if (token) { + if (tokenKind === 57) { + if (token.parent.kind === 219 || + token.parent.kind === 146 || + token.parent.kind === 143 || + token.parent.kind === 246) { + return 5; } } - return undefined; + if (token.parent.kind === 188 || + token.parent.kind === 186 || + token.parent.kind === 187 || + token.parent.kind === 189) { + return 5; + } } - function aggregateOwnedThrowStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 215) { - statementAccumulator.push(node); - } - else if (node.kind === 216) { - var tryStatement = node; - if (tryStatement.catchClause) { - aggregate(tryStatement.catchClause); + return 10; + } + else if (tokenKind === 8) { + return 4; + } + else if (tokenKind === 9) { + return token.parent.kind === 246 ? 24 : 6; + } + else if (tokenKind === 11) { + return 6; + } + else if (ts.isTemplateLiteralKind(tokenKind)) { + return 6; + } + else if (tokenKind === 10) { + return 23; + } + else if (tokenKind === 70) { + if (token) { + switch (token.parent.kind) { + case 222: + if (token.parent.name === token) { + return 11; } - else { - aggregate(tryStatement.tryBlock); + return; + case 142: + if (token.parent.name === token) { + return 15; } - if (tryStatement.finallyBlock) { - aggregate(tryStatement.finallyBlock); + return; + case 223: + if (token.parent.name === token) { + return 13; } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } - } - } - function getThrowStatementOwner(throwStatement) { - var child = throwStatement; - while (child.parent) { - var parent_20 = child.parent; - if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { - return parent_20; - } - if (parent_20.kind === 216) { - var tryStatement = parent_20; - if (tryStatement.tryBlock === child && tryStatement.catchClause) { - return child; + return; + case 225: + if (token.parent.name === token) { + return 12; } - } - child = parent_20; - } - return undefined; - } - function aggregateAllBreakAndContinueStatements(node) { - var statementAccumulator = []; - aggregate(node); - return statementAccumulator; - function aggregate(node) { - if (node.kind === 210 || node.kind === 209) { - statementAccumulator.push(node); - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, aggregate); - } + return; + case 226: + if (token.parent.name === token) { + return 14; + } + return; + case 143: + if (token.parent.name === token) { + return ts.isThisIdentifier(token) ? 3 : 17; + } + return; } } - function ownsBreakOrContinueStatement(owner, statement) { - var actualOwner = getBreakOrContinueOwner(statement); - 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 213: - if (statement.kind === 209) { - continue; - } - case 206: - case 207: - case 208: - case 205: - case 204: - if (!statement.label || isLabeledBy(node_1, statement.label.text)) { - return node_1; - } - break; - default: - if (ts.isFunctionLike(node_1)) { - return undefined; - } - break; - } + return 2; + } + } + function processElement(element) { + if (!element) { + return; + } + 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]; + if (!tryClassifyNode(child)) { + processElement(child); } - return undefined; } - function getModifierOccurrences(modifier, declaration) { - var container = declaration.parent; - if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 221 || - container.kind === 192 || - (declaration.kind === 142 && hasKind(container, 148)))) { - return undefined; - } - } - else if (modifier === 113) { - if (!(container.kind === 221 || container.kind === 192)) { - return undefined; - } - } - else if (modifier === 82 || modifier === 122) { - if (!(container.kind === 226 || container.kind === 256)) { - return undefined; - } - } - else if (modifier === 115) { - if (!(container.kind === 221 || declaration.kind === 221)) { - return undefined; - } + } + } + } + ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; +})(ts || (ts = {})); +var ts; +(function (ts) { + var Completions; + (function (Completions) { + function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { + if (ts.isInReferenceComment(sourceFile, position)) { + return getTripleSlashReferenceCompletion(sourceFile, position); + } + if (ts.isInString(sourceFile, position)) { + return getStringLiteralCompletionEntries(sourceFile, position); + } + var completionData = getCompletionData(typeChecker, log, sourceFile, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; + if (isJsDocTagName) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; + } + var entries = []; + if (ts.isSourceFileJavaScript(sourceFile)) { + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); + ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); + } + else { + if (!symbols || symbols.length === 0) { + if (sourceFile.languageVariant === 1 && + location.parent && location.parent.kind === 245) { + var tagName = location.parent.parent.openingElement.tagName; + entries.push({ + name: tagName.text, + kind: undefined, + kindModifiers: undefined, + sortText: "0", + }); } else { return undefined; } - var keywords = []; - var modifierFlag = getFlagFromModifier(modifier); - var nodes; - switch (container.kind) { - case 226: - case 256: - if (modifierFlag & 128) { - nodes = declaration.members.concat(declaration); - } - else { - nodes = container.statements; - } - break; - case 148: - nodes = container.parameters.concat(container.parent.members); - break; - case 221: - case 192: - nodes = container.members; - if (modifierFlag & 28) { - var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 && member; - }); - if (constructor) { - nodes = nodes.concat(constructor.parameters); - } - } - else if (modifierFlag & 128) { - nodes = nodes.concat(container); - } - break; - default: - ts.Debug.fail("Invalid container kind."); - } - ts.forEach(nodes, function (node) { - if (ts.getModifierFlags(node) & modifierFlag) { - ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); - } - }); - return ts.map(keywords, getHighlightSpanForNode); - function getFlagFromModifier(modifier) { - switch (modifier) { - case 112: - return 4; - case 110: - return 8; - case 111: - return 16; - case 113: - return 32; - case 82: - return 1; - case 122: - return 2; - case 115: - return 128; - default: - ts.Debug.fail(); - } - } } - function pushKeywordIf(keywordList, token) { - var expected = []; - for (var _i = 2; _i < arguments.length; _i++) { - expected[_i - 2] = arguments[_i]; - } - if (token && ts.contains(expected, token.kind)) { - keywordList.push(token); - return true; + getCompletionEntriesFromSymbols(symbols, entries, location, true); + } + if (!isMemberCompletion && !isJsDocTagName) { + ts.addRange(entries, keywordCompletions); + } + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; + function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { + var entries = []; + var nameTable = ts.getNameTable(sourceFile); + for (var name_46 in nameTable) { + if (nameTable[name_46] === position) { + continue; } - return false; - } - function getGetAndSetOccurrences(accessorDeclaration) { - var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149); - tryPushAccessorKeyword(accessorDeclaration.symbol, 150); - return ts.map(keywords, getHighlightSpanForNode); - function tryPushAccessorKeyword(accessorSymbol, accessorKind) { - var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); - if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 131); }); + 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, + kind: ts.ScriptElementKind.warning, + kindModifiers: "", + sortText: "1" + }; + entries.push(entry); } } } - function getConstructorOccurrences(constructorDeclaration) { - var declarations = constructorDeclaration.symbol.getDeclarations(); - var keywords = []; - ts.forEach(declarations, function (declaration) { - ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121); - }); - }); - return ts.map(keywords, getHighlightSpanForNode); + return entries; + } + function createCompletionEntry(symbol, location, performCharacterChecks) { + var displayName = getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, compilerOptions.target, performCharacterChecks, location); + if (!displayName) { + return undefined; } - function getLoopBreakContinueOccurrences(loopNode) { - var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { - if (loopNode.kind === 204) { - var loopTokens = loopNode.getChildren(); - for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104)) { - break; - } + return { + name: displayName, + kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + sortText: "0", + }; + } + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { + var start = ts.timestamp(); + var uniqueNames = ts.createMap(); + if (symbols) { + for (var _i = 0, symbols_4 = symbols; _i < symbols_4.length; _i++) { + var symbol = symbols_4[_i]; + var entry = createCompletionEntry(symbol, location, performCharacterChecks); + if (entry) { + var id = ts.escapeIdentifier(entry.name); + if (!uniqueNames[id]) { + entries.push(entry); + uniqueNames[id] = id; } } } - var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); - } - }); - return ts.map(keywords, getHighlightSpanForNode); } - function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { - var owner = getBreakOrContinueOwner(breakOrContinueStatement); - if (owner) { - switch (owner.kind) { - case 206: - case 207: - case 208: - case 204: - case 205: - return getLoopBreakContinueOccurrences(owner); - case 213: - return getSwitchCaseDefaultOccurrences(owner); - } - } + log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); + return uniqueNames; + } + function getStringLiteralCompletionEntries(sourceFile, position) { + var node = ts.findPrecedingToken(position, sourceFile); + if (!node || node.kind !== 9) { return undefined; } - function getSwitchCaseDefaultOccurrences(switchStatement) { - var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); - ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); - var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); - ts.forEach(breaksAndContinues, function (statement) { - if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70); - } - }); - }); - return ts.map(keywords, getHighlightSpanForNode); + if (node.parent.kind === 253 && + node.parent.parent.kind === 172 && + node.parent.name === node) { + return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } - function getTryCatchFinallyOccurrences(tryStatement) { - var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); - if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); - } - if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85); - } - return ts.map(keywords, getHighlightSpanForNode); + else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { + return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - function getThrowOccurrences(throwStatement) { - var owner = getThrowStatementOwner(throwStatement); - if (!owner) { - return undefined; - } - var keywords = []; - ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); - }); - if (ts.isFunctionBlock(owner)) { - ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); - }); + else if (node.parent.kind === 231 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + return getStringLiteralCompletionEntriesFromModuleNames(node); + } + else { + var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); + if (argumentInfo) { + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } - return ts.map(keywords, getHighlightSpanForNode); + return getStringLiteralCompletionEntriesFromContextualType(node); } - function getReturnOccurrences(returnStatement) { - var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 199))) { - return undefined; + } + function getStringLiteralCompletionEntriesFromPropertyAssignment(element) { + var type = typeChecker.getContextualType(element.parent); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } - var keywords = []; - ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); - }); - ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); - }); - return ts.map(keywords, getHighlightSpanForNode); } - function getIfElseOccurrences(ifStatement) { - var keywords = []; - while (hasKind(ifStatement.parent, 203) && ifStatement.parent.elseStatement === ifStatement) { - ifStatement = ifStatement.parent; + } + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { + var candidates = []; + var entries = []; + typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); + for (var _i = 0, candidates_3 = candidates; _i < candidates_3.length; _i++) { + var candidate = candidates_3[_i]; + if (candidate.parameters.length > argumentInfo.argumentIndex) { + var parameter = candidate.parameters[argumentInfo.argumentIndex]; + addStringLiteralCompletionsFromType(typeChecker.getTypeAtLocation(parameter.valueDeclaration), entries); } - while (ifStatement) { - var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88); - for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80)) { - break; - } - } - if (!hasKind(ifStatement.elseStatement, 203)) { - break; - } - ifStatement = ifStatement.elseStatement; - } - var result = []; - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 80 && i < keywords.length - 1) { - var elseKeyword = keywords[i]; - var ifKeyword = keywords[i + 1]; - var shouldCombindElseAndIf = true; - for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { - if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { - shouldCombindElseAndIf = false; - break; - } - } - if (shouldCombindElseAndIf) { - result.push({ - fileName: fileName, - textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: ts.HighlightSpanKind.reference - }); - i++; - continue; - } - } - result.push(getHighlightSpanForNode(keywords[i])); - } - return result; } - } - } - DocumentHighlights.getDocumentHighlights = getDocumentHighlights; - function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214; owner = owner.parent) { - if (owner.label.text === labelName) { - return true; + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; } + return undefined; } - return false; - } - })(DocumentHighlights = ts.DocumentHighlights || (ts.DocumentHighlights = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - var buckets = ts.createMap(); - var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); - function getKeyForCompilationSettings(settings) { - return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); - } - function getBucketForCompilationSettings(key, createIfMissing) { - var bucket = buckets[key]; - if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(); - } - return bucket; - } - function reportStats() { - var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { - var entries = buckets[name]; - var sourceFiles = []; - entries.forEachValue(function (key, entry) { - sourceFiles.push({ - name: key, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) - }); - }); - sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); - return { - bucket: name, - sourceFiles: sourceFiles - }; - }); - return JSON.stringify(bucketInfoArray, undefined, 2); - } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { - var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var key = getKeyForCompilationSettings(compilationSettings); - return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); - } - function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, true, scriptKind); - } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { - var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var key = getKeyForCompilationSettings(compilationSettings); - return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); - } - function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, false, scriptKind); - } - function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = getBucketForCompilationSettings(key, true); - var entry = bucket.get(path); - if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); - var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false, scriptKind); - entry = { - sourceFile: sourceFile, - languageServiceRefCount: 0, - owners: [] - }; - bucket.set(path, entry); - } - else { - if (entry.sourceFile.version !== version) { - entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + function getStringLiteralCompletionEntriesFromElementAccess(node) { + var type = typeChecker.getTypeAtLocation(node.expression); + var entries = []; + if (type) { + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); + if (entries.length) { + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + } } + return undefined; } - if (acquiring) { - entry.languageServiceRefCount++; - } - return entry.sourceFile; - } - function releaseDocument(fileName, compilationSettings) { - var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key); - } - function releaseDocumentWithKey(path, key) { - var bucket = getBucketForCompilationSettings(key, false); - ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(path); - entry.languageServiceRefCount--; - ts.Debug.assert(entry.languageServiceRefCount >= 0); - if (entry.languageServiceRefCount === 0) { - bucket.remove(path); - } - } - return { - acquireDocument: acquireDocument, - acquireDocumentWithKey: acquireDocumentWithKey, - updateDocument: updateDocument, - updateDocumentWithKey: updateDocumentWithKey, - releaseDocument: releaseDocument, - releaseDocumentWithKey: releaseDocumentWithKey, - reportStats: reportStats, - getKeyForCompilationSettings: getKeyForCompilationSettings - }; - } - ts.createDocumentRegistry = createDocumentRegistry; -})(ts || (ts = {})); -var ts; -(function (ts) { - var FindAllReferences; - (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { - var node = ts.getTouchingPropertyName(sourceFile, position, true); - if (node === sourceFile) { + function getStringLiteralCompletionEntriesFromContextualType(node) { + var type = typeChecker.getContextualType(node); + if (type) { + var entries_2 = []; + addStringLiteralCompletionsFromType(type, entries_2); + if (entries_2.length) { + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; + } + } return undefined; } - switch (node.kind) { - case 8: - if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - break; + function addStringLiteralCompletionsFromType(type, result) { + if (!type) { + return; + } + if (type.flags & 524288) { + ts.forEach(type.types, function (t) { return addStringLiteralCompletionsFromType(t, result); }); + } + else { + if (type.flags & 32) { + result.push({ + name: type.text, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, + sortText: "0" + }); } - case 69: - case 97: - case 121: - case 9: - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); + } } - return undefined; - } - FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { - if (!implementations) { - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + function getStringLiteralCompletionEntriesFromModuleNames(node) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); } else { - return getLabelReferencesInNode(node.parent, node); + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, ts.getSupportedExtensions(compilerOptions), false, span, scriptPath); } } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - if (node.kind === 95) { - return getReferencesForSuperKeyword(node); + else { + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!implementations && !symbol && node.kind === 9) { - return getReferencesForStringLiteral(node, sourceFiles); - } - if (!symbol) { - return undefined; - } - var declarations = symbol.declarations; - if (!declarations || !declarations.length) { - return undefined; - } - var result; - var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var scope = getSymbolScope(symbol); - var symbolToIndex = []; - if (scope) { - result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); - } - else { - var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; - cancellationToken.throwIfCancellationRequested(); - var nameTable = ts.getNameTable(sourceFile); - if (nameTable[internedName] !== undefined) { - result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; } } + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); } - return result; - function getDefinition(symbol) { - var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node); - var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); } - return { - containerKind: "", - containerName: "", - name: name, - kind: info.symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), - displayParts: info.displayParts - }; + return result; } - function getAliasSymbolForPropertyNameSymbol(symbol, location) { - if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 231); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); + if (files) { + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles[foundFileName]) { + foundFiles[foundFileName] = true; + } + } + for (var foundFile in foundFiles) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + } } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 || - declaration.kind === 238) ? declaration : undefined; }); - if (importOrExportSpecifier && - (!importOrExportSpecifier.propertyName || - importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 234 ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } } } - return undefined; - } - function followAliasIfNecessary(symbol, location) { - return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); - return bindingElement && - bindingElement.parent.kind === 167 && - !bindingElement.propertyName; + return result; } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + } } - return undefined; + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; } - function getInternedName(symbol, location, declarations) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.getText(); + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_5 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); + } + return result; + } + } } - var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - symbol = localExportDefaultSymbol || symbol; - return ts.stripQuotes(symbol.name); + return undefined; } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 179 || valueDeclaration.kind === 192)) { - return valueDeclaration; + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options) { + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); } - 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, 221); + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } } } - if (symbol.flags & 8388608) { + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { return undefined; } - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { return undefined; } - if (symbol.parent || (symbol.flags & 268435456)) { + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { return undefined; } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 256 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); + } + else { + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } } - return scope; + return completionInfo; } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - if (position > end) - break; - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2))) { - positions.push(position); + else if (host.getDirectories) { + var typeRoots = void 0; + try { + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); + } } - position = text.indexOf(symbolName, position + symbolNameLength + 1); } - return positions; - } - function getLabelReferencesInNode(container, targetLabel) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; + if (host.getDirectories) { + for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); + } } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; + } } - function isValidReferencePosition(node, searchSymbolName) { - if (node) { - switch (node.kind) { - case 69: - return node.getWidth() === searchSymbolName.length; - case 9: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - isNameOfExternalModuleImportOrDeclaration(node)) { - return node.getWidth() === searchSymbolName.length + 2; - } - break; - case 8: - if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - return node.getWidth() === searchSymbolName.length; - } + function findPackageJsons(currentDir) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent_16 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_16) { break; + } + currentDir = parent_16; + } + else { + break; } } - return false; + return paths; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); - var parents = getParentSymbolsOfPropertyAccess(); - var inheritsFromCache = ts.createMap(); - if (possiblePositions.length) { - var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { return; } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - return; + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 121, parents, inheritsFromCache); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 121) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName: moduleName, + moduleDir: moduleDir + }); } - }); + } } - return; - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 1572864) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; + } + catch (e) { + return undefined; + } + } + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); } } } } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 || slashCharCode === 92; } - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - addReferences(findOwnConstructorCalls(searchSymbol)); - } - else { - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } + } + Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { + var completionData = getCompletionData(typeChecker, log, sourceFile, position); + if (completionData) { + var symbols = completionData.symbols, location_2 = completionData.location; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_2) === entryName ? s : undefined; }); + if (symbol) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_2, location_2, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + return { + name: entryName, + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + kind: symbolKind, + displayParts: displayParts, + documentation: documentation + }; } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } + } + var keywordCompletion = ts.forEach(keywordCompletions, function (c) { return c.name === entryName; }); + if (keywordCompletion) { + return { + name: entryName, + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, + displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], + documentation: undefined + }; + } + return undefined; + } + Completions.getCompletionEntryDetails = getCompletionEntryDetails; + function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { + var completionData = getCompletionData(typeChecker, log, sourceFile, position); + if (completionData) { + var symbols = completionData.symbols, location_3 = completionData.location; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); + } + return undefined; + } + Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; + function getCompletionData(typeChecker, log, sourceFile, position) { + var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); + var isJsDocTagName = false; + var start = ts.timestamp(); + var currentToken = ts.getTokenAtPosition(sourceFile, position); + log("getCompletionData: Get current token: " + (ts.timestamp() - start)); + start = ts.timestamp(); + var insideComment = ts.isInsideComment(sourceFile, currentToken, position); + log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); + if (insideComment) { + if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { + isJsDocTagName = true; } - function findOwnConstructorCalls(classSymbol) { - var result = []; - for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); - var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121); - result.push(ctrKeyword); + var insideJsDocTagExpression = false; + var tag = ts.getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (tag.tagName.pos <= position && position <= tag.tagName.end) { + isJsDocTagName = true; } - ts.forEachProperty(classSymbol.exports, function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 147) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 97, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); + switch (tag.kind) { + case 277: + case 275: + case 276: + var tagWithExpression = tag; + if (tagWithExpression.typeExpression) { + insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; } - } - }); - return result; - } - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members["__constructor"]; - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 95, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } + break; } - ; - return result; } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol), - references: [] - }); - } - return result[index]; + if (isJsDocTagName) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references); - } - else { - references.push(getReferenceEntryFromNode(node)); - } + if (!insideJsDocTagExpression) { + log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); + return undefined; } } - function getImplementationReferenceEntryForNode(refNode, result) { - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); + start = ts.timestamp(); + var previousToken = ts.findPrecedingToken(position, sourceFile); + log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); + var contextToken = previousToken; + if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) { + var start_2 = ts.timestamp(); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); + log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_2)); + } + var node = currentToken; + var isRightOfDot = false; + var isRightOfOpenTag = false; + var isStartingCloseTag = false; + var location = ts.getTouchingPropertyName(sourceFile, position); + if (contextToken) { + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; } - else if (refNode.kind === 69) { - if (refNode.parent.kind === 254) { - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + var parent_17 = contextToken.parent, kind = contextToken.kind; + if (kind === 22) { + if (parent_17.kind === 173) { + node = contextToken.parent.expression; + isRightOfDot = true; } - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; + else if (parent_17.kind === 140) { + node = contextToken.parent.left; + isRightOfDot = true; } - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent_21 = containingTypeReference.parent; - if (ts.isVariableLike(parent_21) && parent_21.type === containingTypeReference && parent_21.initializer && isImplementationExpression(parent_21.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); - } - else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199) { - ts.forEachReturnStatement(parent_21.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent_21.body)) { - maybeAdd(getReferenceEntryFromNode(parent_21.body)); - } - } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); - } + else { + return undefined; } } - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); + else if (sourceFile.languageVariant === 1) { + if (kind === 26) { + isRightOfOpenTag = true; + location = contextToken; + } + else if (kind === 40 && contextToken.parent.kind === 245) { + isStartingCloseTag = true; + location = contextToken; } } } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 1572864) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } + var semanticStart = ts.timestamp(); + var isGlobalCompletion = false; + var isMemberCompletion; + var isNewIdentifierLocation; + var symbols = []; + if (isRightOfDot) { + getTypeScriptMemberSymbols(); + } + else if (isRightOfOpenTag) { + var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & (107455 | 8388608)); })); } - return result; + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; + else if (isStartingCloseTag) { + var tagName = contextToken.parent.parent.openingElement.tagName; + var tagSymbol = typeChecker.getSymbolAtLocation(tagName); + if (!typeChecker.isUnknownSymbol(tagSymbol)) { + symbols = [tagSymbol]; } - return topLevelTypeReference; + isMemberCompletion = true; + isNewIdentifierLocation = false; } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 194 - && node.parent.kind === 251 - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; + else { + if (!tryGetGlobalSymbols()) { + return undefined; + } + } + log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + function getTypeScriptMemberSymbols() { + isGlobalCompletion = false; + isMemberCompletion = true; + isNewIdentifierLocation = false; + if (node.kind === 70 || node.kind === 140 || node.kind === 173) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol && symbol.flags & 8388608) { + symbol = typeChecker.getAliasedSymbol(symbol); } - else if (node.kind === 69 || node.kind === 172) { - return getContainingClassIfInHeritageClause(node.parent); + if (symbol && symbol.flags & 1952) { + var exportedSymbols = typeChecker.getExportsOfModule(symbol); + ts.forEach(exportedSymbols, function (symbol) { + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + }); } } - return undefined; + var type = typeChecker.getTypeAtLocation(node); + addTypeProperties(type); } - function isImplementationExpression(node) { - if (node.kind === 178) { - return isImplementationExpression(node.expression); + function addTypeProperties(type) { + if (type) { + for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { + var symbol = _a[_i]; + if (typeChecker.isValidPropertyAccess((node.parent), symbol.name)) { + symbols.push(symbol); + } + } + if (isJavaScriptFile && type.flags & 524288) { + var unionType = type; + for (var _b = 0, _c = unionType.types; _b < _c.length; _b++) { + var elementType = _c[_b]; + addTypeProperties(elementType); + } + } } - return node.kind === 180 || - node.kind === 179 || - node.kind === 171 || - node.kind === 192 || - node.kind === 170; } - function explicitlyInheritsFrom(child, parent, cachedResults) { - var parentIsInterface = parent.getFlags() & 64; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - if (key in cachedResults) { - return cachedResults[key]; - } - cachedResults[key] = false; - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 222) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults[key] = inherits; - return inherits; + function tryGetGlobalSymbols() { + var objectLikeContainer; + var namedImportsOrExports; + var jsxContainer; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); + if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) { + return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + var attrsType = void 0; + if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if (attrsType) { + symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; } } - return false; } - } - function getReferencesForSuperKeyword(superKeyword) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { - return undefined; + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 145: - case 144: - case 147: - case 146: - case 148: - case 149: - case 150: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - default: - return undefined; + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 || + scopeNode.kind === 190 || + scopeNode.kind === 248 || + ts.isStatement(scopeNode); } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { - return; - } - var container = ts.getSuperContainer(node, false); - if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = getDefinition(searchSpaceNode.symbol); - return [{ definition: definition, references: references }]; + var symbolMeanings = 793064 | 107455 | 1920 | 8388608; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + return true; } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 147: - case 146: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; - } - case 145: - case 144: - case 148: - case 149: - case 150: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - case 256: - if (ts.isExternalModule(searchSpaceNode)) { - return undefined; - } - case 220: - case 179: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 256) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 179: - case 220: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 147: - case 146: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 192: - case 221: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 256: - if (container.kind === 256 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); + function getScopeNode(initialToken, position, sourceFile) { + var scope = initialToken; + while (scope && !ts.positionBelongsToNode(scope, position, sourceFile)) { + scope = scope.parent; } + return scope; } - function getReferencesForStringLiteral(node, sourceFiles) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { - var sourceFile = sourceFiles_9[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + function isCompletionListBlocker(contextToken) { + var start = ts.timestamp(); + var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isSolelyIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken) || + isInJsxText(contextToken); + log("getCompletionsAtPosition: isCompletionListBlocker: " + (ts.timestamp() - start)); + return result; + } + function isInJsxText(contextToken) { + if (contextToken.kind === 10) { + return true; } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - 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) { - return; - } - var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_1 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); - } + if (contextToken.kind === 28 && contextToken.parent) { + if (contextToken.parent.kind === 244) { + return true; + } + if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242; } } + return false; } - function populateSearchSymbolSet(symbol, location) { - var result = [symbol]; - var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); - if (propertySymbol) { - result.push(propertySymbol); + function isNewIdentifierDefinitionLocation(previousToken) { + if (previousToken) { + var containingNodeKind = previousToken.parent.kind; + switch (previousToken.kind) { + case 25: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 171 + || containingNodeKind === 188 + || containingNodeKind === 157; + case 18: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 179 + || containingNodeKind === 165; + case 20: + return containingNodeKind === 171 + || containingNodeKind === 154 + || containingNodeKind === 141; + case 126: + case 127: + return true; + case 22: + return containingNodeKind === 226; + case 16: + return containingNodeKind === 222; + case 57: + return containingNodeKind === 219 + || containingNodeKind === 188; + case 13: + return containingNodeKind === 190; + case 14: + return containingNodeKind === 198; + case 113: + case 111: + case 112: + return containingNodeKind === 146; } - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); - if (aliasSymbol) { - result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); - } - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); + switch (previousToken.getText()) { + case "public": + case "protected": + case "private": + return true; } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 142 && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - if (rootSymbol !== symbol) { - result.push(rootSymbol); + return false; + } + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { + if (contextToken.kind === 9 + || contextToken.kind === 11 + || ts.isTemplateLiteralKind(contextToken.kind)) { + var start_3 = contextToken.getStart(); + var end = contextToken.getEnd(); + if (start_3 < position && position < end) { + return true; } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap()); + if (position === end) { + return !!contextToken.isUnterminated + || contextToken.kind === 11; } - }); - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { - if (!symbol) { - return; - } - if (symbol.name in previousIterationSymbolsCache) { - return; } - if (symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 222) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); + return false; + } + function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { + isMemberCompletion = true; + var typeForObject; + var existingMembers; + if (objectLikeContainer.kind === 172) { + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); + typeForObject = typeForObject && typeForObject.getNonNullableType(); + existingMembers = objectLikeContainer.properties; } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); + else if (objectLikeContainer.kind === 168) { + isNewIdentifierLocation = false; + var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); + if (ts.isVariableLike(rootDeclaration)) { + var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); + if (!canGetType && rootDeclaration.kind === 143) { + if (ts.isExpression(rootDeclaration.parent)) { + canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - previousIterationSymbolsCache[symbol.name] = symbol; - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); + else if (rootDeclaration.parent.kind === 148 || rootDeclaration.parent.kind === 151) { + canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); + } + } + if (canGetType) { + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; } } + else { + ts.Debug.fail("Root declaration is not variable-like."); + } } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { - if (ts.contains(searchSymbols, referenceSymbol)) { - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; + else { + ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); + if (!typeForObject) { + return false; } - var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { - return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); - if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { - return propertySymbol; - } + var typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + symbols = filterObjectMembersList(typeMembers, existingMembers); } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); - if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { - return bindingElementPropertySymbol; + return true; + } + function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { + var declarationKind = namedImportsOrExports.kind === 234 ? + 231 : + 237; + var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); + var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; + if (!moduleSpecifier) { + return false; } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (searchSymbols.indexOf(rootSymbol) >= 0) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { - return undefined; - } - } - var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, ts.createMap()); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); - } - return undefined; - }); + isMemberCompletion = true; + isNewIdentifierLocation = false; + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : ts.emptyArray; + return true; } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140) { - var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression.kind)) { - return nameExpression.text; + function tryGetObjectLikeCompletionContainer(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 16: + case 25: + var parent_18 = contextToken.parent; + if (parent_18 && (parent_18.kind === 172 || parent_18.kind === 168)) { + return parent_18; + } + break; } - return undefined; } - return node.name.text; + return undefined; } - function getPropertySymbolsFromContextualType(node) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_4 = []; - var symbol_2 = contextualType.getProperty(name); - if (symbol_2) { - result_4.push(symbol_2); - } - if (contextualType.flags & 524288) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_4.push(symbol); + function tryGetNamedImportsOrExportsForCompletion(contextToken) { + if (contextToken) { + switch (contextToken.kind) { + case 16: + case 25: + switch (contextToken.parent.kind) { + case 234: + case 238: + return contextToken.parent; } - }); } - return result_4; } return undefined; } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - lastIterationMeaning = meaning; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; + function tryGetContainingJsxElement(contextToken) { + if (contextToken) { + var parent_19 = contextToken.parent; + switch (contextToken.kind) { + case 27: + case 40: + case 70: + case 246: + case 247: + if (parent_19 && (parent_19.kind === 243 || parent_19.kind === 244)) { + return parent_19; } - } - } while (meaning !== lastIterationMeaning); + else if (parent_19.kind === 246) { + return parent_19.parent; + } + break; + case 9: + if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { + return parent_19.parent; + } + break; + case 17: + if (parent_19 && + parent_19.kind === 248 && + parent_19.parent && + (parent_19.parent.kind === 246)) { + return parent_19.parent.parent; + } + if (parent_19 && parent_19.kind === 247) { + return parent_19.parent; + } + break; + } } - return meaning; - } - } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function convertReferences(referenceSymbols) { - if (!referenceSymbols) { return undefined; } - var referenceEntries = []; - for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { - var referenceSymbol = referenceSymbols_1[_i]; - ts.addRange(referenceEntries, referenceSymbol.references); - } - return referenceEntries; - } - FindAllReferences.convertReferences = convertReferences; - function isImplementation(node) { - if (!node) { - return false; - } - else if (ts.isVariableLike(node)) { - if (node.initializer) { - return true; + function isFunction(kind) { + switch (kind) { + case 180: + case 181: + case 221: + case 148: + case 147: + case 150: + case 151: + case 152: + case 153: + case 154: + return true; } - else if (node.kind === 218) { - var parentStatement = getParentStatementOfVariableDeclaration(node); - return parentStatement && ts.hasModifier(parentStatement, 2); + return false; + } + function isSolelyIdentifierDefinitionLocation(contextToken) { + var containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { + case 25: + return containingNodeKind === 219 || + containingNodeKind === 220 || + containingNodeKind === 201 || + containingNodeKind === 225 || + isFunction(containingNodeKind) || + containingNodeKind === 222 || + containingNodeKind === 193 || + containingNodeKind === 223 || + containingNodeKind === 169 || + containingNodeKind === 224; + case 22: + return containingNodeKind === 169; + case 55: + return containingNodeKind === 170; + case 20: + return containingNodeKind === 169; + case 18: + return containingNodeKind === 252 || + isFunction(containingNodeKind); + case 16: + return containingNodeKind === 225 || + containingNodeKind === 223 || + containingNodeKind === 160; + case 24: + return containingNodeKind === 145 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 223 || + contextToken.parent.parent.kind === 160); + case 26: + return containingNodeKind === 222 || + containingNodeKind === 193 || + containingNodeKind === 223 || + containingNodeKind === 224 || + isFunction(containingNodeKind); + case 114: + return containingNodeKind === 146; + case 23: + return containingNodeKind === 143 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 169); + case 113: + case 111: + case 112: + return containingNodeKind === 143; + case 117: + return containingNodeKind === 235 || + containingNodeKind === 239 || + containingNodeKind === 233; + case 74: + case 82: + case 108: + case 88: + case 103: + case 124: + case 132: + case 90: + case 109: + case 75: + case 115: + case 135: + return true; + } + switch (contextToken.getText()) { + case "abstract": + case "async": + case "class": + case "const": + case "declare": + case "enum": + case "function": + case "interface": + case "let": + case "private": + case "protected": + case "public": + case "static": + case "var": + case "yield": + return true; } + return false; } - else if (ts.isFunctionLike(node)) { - return !!node.body || ts.hasModifier(node, 2); + function isDotOfNumericLiteral(contextToken) { + if (contextToken.kind === 8) { + var text = contextToken.getFullText(); + return text.charAt(text.length - 1) === "."; + } + return false; } - else { - switch (node.kind) { - case 221: - case 192: - case 224: - case 225: - return true; + function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { + var existingImportsOrExports = ts.createMap(); + for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { + var element = namedImportsOrExports_1[_i]; + if (element.getStart() <= position && position <= element.getEnd()) { + continue; + } + 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"; }); + } + return ts.filter(exportsOfModule, function (e) { return e.name !== "default" && !existingImportsOrExports[e.name]; }); } - return false; - } - function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200) { - ts.Debug.assert(node.parent.kind === 219); - return node.parent.parent; + function filterObjectMembersList(contextualMemberSymbols, existingMembers) { + if (!existingMembers || existingMembers.length === 0) { + return contextualMemberSymbols; + } + var existingMemberNames = ts.createMap(); + for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { + var m = existingMembers_1[_i]; + if (m.kind !== 253 && + m.kind !== 254 && + m.kind !== 170 && + m.kind !== 148) { + continue; + } + if (m.getStart() <= position && position <= m.getEnd()) { + continue; + } + var existingName = void 0; + if (m.kind === 170 && m.propertyName) { + if (m.propertyName.kind === 70) { + existingName = m.propertyName.text; + } + } + else { + existingName = m.name.text; + } + existingMemberNames[existingName] = true; + } + return ts.filter(contextualMemberSymbols, function (m) { return !existingMemberNames[m.name]; }); } - } - function getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result) { - var refSymbol = typeChecker.getSymbolAtLocation(node); - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); - if (shorthandSymbol) { - for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1) { - result.push(getReferenceEntryFromNode(declaration)); + function filterJsxAttributes(symbols, attributes) { + var seenNames = ts.createMap(); + for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { + var attr = attributes_1[_i]; + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + if (attr.kind === 246) { + seenNames[attr.name.text] = true; } } + return ts.filter(symbols, function (a) { return !seenNames[a.name]; }); } } - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; - function getReferenceEntryFromNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - if (node.kind === 9) { - start += 1; - end -= 1; + function getCompletionEntryDisplayNameForSymbol(typeChecker, symbol, target, performCharacterChecks, location) { + var displayName = ts.getDeclaredName(typeChecker, symbol, location); + if (displayName) { + var firstCharCode = displayName.charCodeAt(0); + if ((symbol.flags & 1920) && (firstCharCode === 39 || firstCharCode === 34)) { + return undefined; + } } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - }; + return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); } - FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; - function isWriteAccess(node) { - if (node.kind === 69 && ts.isDeclarationName(node)) { - return true; + function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + if (!name) { + return undefined; } - var parent = node.parent; - if (parent) { - if (parent.kind === 186 || parent.kind === 185) { - return true; - } - else if (parent.kind === 187 && parent.left === node) { - var operator = parent.operatorToken.kind; - return 56 <= operator && operator <= 68; + name = ts.stripQuotes(name); + if (!name) { + return undefined; + } + if (performCharacterChecks) { + if (!ts.isIdentifierText(name, target)) { + return undefined; } } - return false; + return name; } - function forEachDescendantOfKind(node, kind, action) { - ts.forEachChild(node, function (child) { - if (child.kind === kind) { - action(child); - } - forEachDescendantOfKind(child, kind, action); + var keywordCompletions = []; + for (var i = 71; i <= 139; i++) { + keywordCompletions.push({ + name: ts.tokenToString(i), + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, + sortText: "0" }); } - function getContainingObjectLiteralElement(node) { - switch (node.kind) { - case 9: - case 8: - if (node.parent.kind === 140) { - return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; - } - case 69: - return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; + var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s* 0 ? result : undefined; - } - else if (node.kind === 95 || ts.isSuperProperty(node.parent)) { - var symbol = typeChecker.getSymbolAtLocation(node); - return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; - } - else { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, true); - var result = ts.flatMap(referencedSymbols, function (symbol) { - return ts.map(symbol.references, function (_a) { - var textSpan = _a.textSpan, fileName = _a.fileName; - return ({ textSpan: textSpan, fileName: fileName }); - }); - }); - return result && result.length > 0 ? result : undefined; - } - } - GoToImplementation.getImplementationAtPosition = getImplementationAtPosition; - })(GoToImplementation = ts.GoToImplementation || (ts.GoToImplementation = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var JsDoc; - (function (JsDoc) { - var jsDocTagNames = [ - "augments", - "author", - "argument", - "borrows", - "class", - "constant", - "constructor", - "constructs", - "default", - "deprecated", - "description", - "event", - "example", - "extends", - "field", - "fileOverview", - "function", - "ignore", - "inner", - "lends", - "link", - "memberOf", - "name", - "namespace", - "param", - "private", - "property", - "public", - "requires", - "returns", - "see", - "since", - "static", - "throws", - "type", - "typedef", - "property", - "prop", - "version" - ]; - var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { - var documentationComment = []; - forEachUnique(declarations, function (declaration) { - var comments = ts.getJSDocComments(declaration, true); - if (!comments) { - return; - } - for (var _i = 0, comments_3 = comments; _i < comments_3.length; _i++) { - var comment = comments_3[_i]; - if (comment) { - if (documentationComment.length) { - documentationComment.push(ts.lineBreakPart()); + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 216) { + statementAccumulator.push(node); + } + else if (node.kind === 217) { + var tryStatement = node; + if (tryStatement.catchClause) { + aggregate(tryStatement.catchClause); + } + else { + aggregate(tryStatement.tryBlock); + } + if (tryStatement.finallyBlock) { + aggregate(tryStatement.finallyBlock); + } + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); } - documentationComment.push(ts.textPart(comment)); } } - }); - return documentationComment; - } - JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; - function forEachUnique(array, callback) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (ts.indexOf(array, array[i]) === i) { - var result = callback(array[i], i); - if (result) { - return result; + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent_20 = child.parent; + if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { + return parent_20; + } + if (parent_20.kind === 217) { + var tryStatement = parent_20; + if (tryStatement.tryBlock === child && tryStatement.catchClause) { + return child; + } } + child = parent_20; } + return undefined; } - } - return undefined; - } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { - return { - name: tagName, - kind: ts.ScriptElementKind.keyword, - kindModifiers: "", - sortText: "0" - }; - })); - } - JsDoc.getAllJsDocCompletionEntries = getAllJsDocCompletionEntries; - function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { - if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { - return undefined; - } - var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); - var tokenStart = tokenAtPos.getStart(); - if (!tokenAtPos || tokenStart < position) { - return undefined; - } - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 220: - case 147: - case 148: - case 221: - case 200: - break findOwner; - case 256: - return undefined; - case 225: - if (commentOwner.parent.kind === 225) { - return undefined; + function aggregateAllBreakAndContinueStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 211 || node.kind === 210) { + statementAccumulator.push(node); } - break findOwner; + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, aggregate); + } + } } - } - if (!commentOwner || commentOwner.getStart() < position) { - return undefined; - } - var parameters = getParametersForJsDocOwningNode(commentOwner); - var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); - var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); - var docParams = ""; - for (var i = 0, numParams = parameters.length; i < numParams; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 69 ? - currentName.text : - "param" + i; - docParams += indentationStr + " * @param " + paramName + newLine; - } - var preamble = "/**" + newLine + - indentationStr + " * "; - var result = preamble + newLine + - docParams + - indentationStr + " */" + - (tokenStart === position ? newLine + indentationStr : ""); - return { newText: result, caretOffset: preamble.length }; - } - JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 200) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + function ownsBreakOrContinueStatement(owner, statement) { + var actualOwner = getBreakOrContinueOwner(statement); + return actualOwner && actualOwner === owner; } - } - return ts.emptyArray; - } - function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178) { - rightHandSide = rightHandSide.expression; - } - switch (rightHandSide.kind) { - case 179: - case 180: - return rightHandSide.parameters; - case 192: - for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (member.kind === 148) { - return member.parameters; + function getBreakOrContinueOwner(statement) { + for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { + switch (node_1.kind) { + case 214: + if (statement.kind === 210) { + continue; + } + case 207: + case 208: + case 209: + case 206: + case 205: + if (!statement.label || isLabeledBy(node_1, statement.label.text)) { + return node_1; + } + break; + default: + if (ts.isFunctionLike(node_1)) { + return undefined; + } + break; } } - break; - } - return ts.emptyArray; - } - })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var NavigateTo; - (function (NavigateTo) { - function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { - var patternMatcher = ts.createPatternMatcher(searchValue); - var rawItems = []; - var baseSensitivity = { sensitivity: "base" }; - ts.forEach(sourceFiles, function (sourceFile) { - cancellationToken.throwIfCancellationRequested(); - if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { - return; + return undefined; } - var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_49 in nameToDeclarations) { - var declarations = nameToDeclarations[name_49]; - if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_49); - if (!matches) { - continue; + function getModifierOccurrences(modifier, declaration) { + var container = declaration.parent; + if (ts.isAccessibilityModifier(modifier)) { + if (!(container.kind === 222 || + container.kind === 193 || + (declaration.kind === 143 && hasKind(container, 149)))) { + return undefined; } - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return undefined; - } - matches = patternMatcher.getMatches(containers, name_49); - if (!matches) { - continue; + } + else if (modifier === 114) { + if (!(container.kind === 222 || container.kind === 193)) { + return undefined; + } + } + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 227 || container.kind === 256)) { + return undefined; + } + } + else if (modifier === 116) { + if (!(container.kind === 222 || declaration.kind === 222)) { + return undefined; + } + } + else { + return undefined; + } + var keywords = []; + var modifierFlag = getFlagFromModifier(modifier); + var nodes; + switch (container.kind) { + case 227: + case 256: + if (modifierFlag & 128) { + nodes = declaration.members.concat(declaration); + } + else { + nodes = container.statements; + } + break; + case 149: + nodes = container.parameters.concat(container.parent.members); + break; + case 222: + case 193: + nodes = container.members; + if (modifierFlag & 28) { + var constructor = ts.forEach(container.members, function (member) { + return member.kind === 149 && member; + }); + if (constructor) { + nodes = nodes.concat(constructor.parameters); } } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_49, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + else if (modifierFlag & 128) { + nodes = nodes.concat(container); + } + break; + default: + ts.Debug.fail("Invalid container kind."); + } + ts.forEach(nodes, function (node) { + if (ts.getModifierFlags(node) & modifierFlag) { + ts.forEach(node.modifiers, function (child) { return pushKeywordIf(keywords, child, modifier); }); + } + }); + return ts.map(keywords, getHighlightSpanForNode); + function getFlagFromModifier(modifier) { + switch (modifier) { + case 113: + return 4; + case 111: + return 8; + case 112: + return 16; + case 114: + return 32; + case 83: + return 1; + case 123: + return 2; + case 116: + return 128; + default: + ts.Debug.fail(); } } } - }); - rawItems = ts.filter(rawItems, function (item) { - var decl = item.declaration; - if (decl.kind === 231 || decl.kind === 234 || decl.kind === 229) { - var importer = checker.getSymbolAtLocation(decl.name); - var imported = checker.getAliasedSymbol(importer); - return importer.name !== imported.name; - } - else { - return true; - } - }); - rawItems.sort(compareNavigateToItems); - if (maxResultCount !== undefined) { - rawItems = rawItems.slice(0, maxResultCount); - } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { - var match = matches_2[_i]; - if (!match.isCaseSensitive) { - return false; + function pushKeywordIf(keywordList, token) { + var expected = []; + for (var _i = 2; _i < arguments.length; _i++) { + expected[_i - 2] = arguments[_i]; } - } - return true; - } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 || - node.kind === 9 || - node.kind === 8) { - return node.text; + if (token && ts.contains(expected, token.kind)) { + keywordList.push(token); + return true; } + return false; } - return undefined; - } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration && declaration.name) { - var text = getTextOfIdentifierOrLiteral(declaration.name); - if (text !== undefined) { - containers.unshift(text); - } - else if (declaration.name.kind === 140) { - return tryAddComputedPropertyName(declaration.name.expression, containers, true); + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 150); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151); + return ts.map(keywords, getHighlightSpanForNode); + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 132); }); + } } - else { - return false; + } + function getConstructorOccurrences(constructorDeclaration) { + var declarations = constructorDeclaration.symbol.getDeclarations(); + var keywords = []; + ts.forEach(declarations, function (declaration) { + ts.forEach(declaration.getChildren(), function (token) { + return pushKeywordIf(keywords, token, 122); + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getLoopBreakContinueOccurrences(loopNode) { + var keywords = []; + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 205) { + var loopTokens = loopNode.getChildren(); + for (var i = loopTokens.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { + break; + } + } + } } + var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(loopNode, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); + } + }); + return ts.map(keywords, getHighlightSpanForNode); } - return true; - } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); + function getBreakOrContinueStatementOccurrences(breakOrContinueStatement) { + var owner = getBreakOrContinueOwner(breakOrContinueStatement); + if (owner) { + switch (owner.kind) { + case 207: + case 208: + case 209: + case 205: + case 206: + return getLoopBreakContinueOccurrences(owner); + case 214: + return getSwitchCaseDefaultOccurrences(owner); + } } - return true; + return undefined; } - if (expression.kind === 172) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); + function getSwitchCaseDefaultOccurrences(switchStatement) { + var keywords = []; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); + ts.forEach(switchStatement.caseBlock.clauses, function (clause) { + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); + var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); + ts.forEach(breaksAndContinues, function (statement) { + if (ownsBreakOrContinueStatement(switchStatement, statement)) { + pushKeywordIf(keywords, statement.getFirstToken(), 71); + } + }); + }); + return ts.map(keywords, getHighlightSpanForNode); + } + function getTryCatchFinallyOccurrences(tryStatement) { + var keywords = []; + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); + if (tryStatement.catchClause) { + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); + if (tryStatement.finallyBlock) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); + } + return ts.map(keywords, getHighlightSpanForNode); } - return false; - } - function getContainers(declaration) { - var containers = []; - if (declaration.name.kind === 140) { - if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { return undefined; } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + if (ts.isFunctionBlock(owner)) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + } + return ts.map(keywords, getHighlightSpanForNode); } - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { + function getReturnOccurrences(returnStatement) { + var func = ts.getContainingFunction(returnStatement); + if (!(func && hasKind(func.body, 200))) { return undefined; } - declaration = ts.getContainerNode(declaration); + var keywords = []; + ts.forEachReturnStatement(func.body, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + }); + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + }); + return ts.map(keywords, getHighlightSpanForNode); } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { - var match = matches_3[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; + function getIfElseOccurrences(ifStatement) { + var keywords = []; + while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { + ifStatement = ifStatement.parent; + } + while (ifStatement) { + var children = ifStatement.getChildren(); + pushKeywordIf(keywords, children[0], 89); + for (var i = children.length - 1; i >= 0; i--) { + if (pushKeywordIf(keywords, children[i], 81)) { + break; + } + } + if (!hasKind(ifStatement.elseStatement, 204)) { + break; + } + ifStatement = ifStatement.elseStatement; + } + var result = []; + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].kind === 81 && i < keywords.length - 1) { + var elseKeyword = keywords[i]; + var ifKeyword = keywords[i + 1]; + var shouldCombindElseAndIf = true; + for (var j = ifKeyword.getStart() - 1; j >= elseKeyword.end; j--) { + if (!ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(j))) { + shouldCombindElseAndIf = false; + break; + } + } + if (shouldCombindElseAndIf) { + result.push({ + fileName: fileName, + textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), + kind: ts.HighlightSpanKind.reference + }); + i++; + continue; + } + } + result.push(getHighlightSpanForNode(keywords[i])); } + return result; } - return bestMatchKind; - } - function compareNavigateToItems(i1, i2) { - return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), - containerName: container && container.name ? container.name.text : "", - containerKind: container && container.name ? ts.getNodeKind(container) : "" - }; + } + DocumentHighlights.getDocumentHighlights = getDocumentHighlights; + function isLabeledBy(node, labelName) { + for (var owner = node.parent; owner.kind === 215; owner = owner.parent) { + if (owner.label.text === labelName) { + return true; + } } + return false; } - NavigateTo.getNavigateToItems = getNavigateToItems; - })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); + })(DocumentHighlights = ts.DocumentHighlights || (ts.DocumentHighlights = {})); })(ts || (ts = {})); var ts; (function (ts) { - var NavigationBar; - (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { - curSourceFile = sourceFile; - var result = ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); - curSourceFile = undefined; - return result; + function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + var buckets = ts.createMap(); + var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); + function getKeyForCompilationSettings(settings) { + return "_" + settings.target + "|" + settings.module + "|" + settings.noResolve + "|" + settings.jsx + "|" + settings.allowJs + "|" + settings.baseUrl + "|" + JSON.stringify(settings.typeRoots) + "|" + JSON.stringify(settings.rootDirs) + "|" + JSON.stringify(settings.paths); } - NavigationBar.getNavigationBarItems = getNavigationBarItems; - function getNavigationTree(sourceFile) { - curSourceFile = sourceFile; - var result = convertToTree(rootNavigationBarNode(sourceFile)); - curSourceFile = undefined; - return result; + function getBucketForCompilationSettings(key, createIfMissing) { + var bucket = buckets[key]; + if (!bucket && createIfMissing) { + buckets[key] = bucket = ts.createFileMap(); + } + return bucket; } - NavigationBar.getNavigationTree = getNavigationTree; - var curSourceFile; - function nodeText(node) { - return node.getText(curSourceFile); + function reportStats() { + var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { + var entries = buckets[name]; + var sourceFiles = []; + entries.forEachValue(function (key, entry) { + sourceFiles.push({ + name: key, + refCount: entry.languageServiceRefCount, + references: entry.owners.slice(0) + }); + }); + sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); + return { + bucket: name, + sourceFiles: sourceFiles + }; + }); + return JSON.stringify(bucketInfoArray, undefined, 2); } - function navigationBarNodeKind(n) { - return n.node.kind; + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var key = getKeyForCompilationSettings(compilationSettings); + return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); } - function pushChild(parent, child) { - if (parent.children) { - parent.children.push(child); + function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, true, scriptKind); + } + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var key = getKeyForCompilationSettings(compilationSettings); + return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + } + function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { + return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, false, scriptKind); + } + function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { + var bucket = getBucketForCompilationSettings(key, true); + var entry = bucket.get(path); + if (!entry) { + ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); + var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false, scriptKind); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0, + owners: [] + }; + bucket.set(path, entry); } else { - parent.children = [child]; + if (entry.sourceFile.version !== version) { + entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + } } - } - var parentsStack = []; - var parent; - function rootNavigationBarNode(sourceFile) { - ts.Debug.assert(!parentsStack.length); - var root = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; - parent = root; - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - addChildrenRecursively(statement); + if (acquiring) { + entry.languageServiceRefCount++; } - endNode(); - ts.Debug.assert(!parent && !parentsStack.length); - return root; - } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); - } - function emptyNavigationBarNode(node) { - return { - node: node, - additionalNodes: undefined, - parent: parent, - children: undefined, - indent: parent.indent + 1 - }; + return entry.sourceFile; } - function startNode(node) { - var navNode = emptyNavigationBarNode(node); - pushChild(parent, navNode); - parentsStack.push(parent); - parent = navNode; + function releaseDocument(fileName, compilationSettings) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var key = getKeyForCompilationSettings(compilationSettings); + return releaseDocumentWithKey(path, key); } - function endNode() { - if (parent.children) { - mergeChildren(parent.children); - sortChildren(parent.children); + function releaseDocumentWithKey(path, key) { + var bucket = getBucketForCompilationSettings(key, false); + ts.Debug.assert(bucket !== undefined); + var entry = bucket.get(path); + entry.languageServiceRefCount--; + ts.Debug.assert(entry.languageServiceRefCount >= 0); + if (entry.languageServiceRefCount === 0) { + bucket.remove(path); } - parent = parentsStack.pop(); - } - function addNodeWithRecursiveChild(node, child) { - startNode(node); - addChildrenRecursively(child); - endNode(); } - function addChildrenRecursively(node) { - if (!node || ts.isToken(node)) { - return; + return { + acquireDocument: acquireDocument, + acquireDocumentWithKey: acquireDocumentWithKey, + updateDocument: updateDocument, + updateDocumentWithKey: updateDocumentWithKey, + releaseDocument: releaseDocument, + releaseDocumentWithKey: releaseDocumentWithKey, + reportStats: reportStats, + getKeyForCompilationSettings: getKeyForCompilationSettings + }; + } + ts.createDocumentRegistry = createDocumentRegistry; +})(ts || (ts = {})); +var ts; +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments) { + var node = ts.getTouchingPropertyName(sourceFile, position, true); + if (node === sourceFile) { + return undefined; } switch (node.kind) { - case 148: - var ctr = node; - addNodeWithRecursiveChild(ctr, ctr.body); - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { - addLeafNode(param); - } - } - break; - case 147: - case 149: - case 150: - case 146: - if (!ts.hasDynamicName(node)) { - addNodeWithRecursiveChild(node, node.body); - } - break; - case 145: - case 144: - if (!ts.hasDynamicName(node)) { - addLeafNode(node); - } - break; - case 231: - var importClause = node; - if (importClause.name) { - addLeafNode(importClause); - } - var namedBindings = importClause.namedBindings; - if (namedBindings) { - if (namedBindings.kind === 232) { - addLeafNode(namedBindings); - } - else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; - addLeafNode(element); - } - } - } - break; - case 169: - case 218: - var decl = node; - var name_50 = decl.name; - if (ts.isBindingPattern(name_50)) { - addChildrenRecursively(name_50); + case 8: + if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + break; } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - addChildrenRecursively(decl.initializer); + case 70: + case 98: + case 122: + case 9: + return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); + } + return undefined; + } + FindAllReferences.findReferencedSymbols = findReferencedSymbols; + function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, implementations) { + if (!implementations) { + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; } else { - addNodeWithRecursiveChild(decl, decl.initializer); - } - break; - case 180: - case 220: - case 179: - addNodeWithRecursiveChild(node, node.body); - break; - case 224: - startNode(node); - for (var _d = 0, _e = node.members; _d < _e.length; _d++) { - var member = _e[_d]; - if (!isComputedProperty(member)) { - addLeafNode(member); - } - } - endNode(); - break; - case 221: - case 192: - case 222: - startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; - addChildrenRecursively(member); + return getLabelReferencesInNode(node.parent, node); } - endNode(); - break; - case 225: - addNodeWithRecursiveChild(node, getInteriorModule(node).body); - break; - case 238: - case 229: - case 153: - case 151: - case 152: - case 223: - addLeafNode(node); - break; - default: - ts.forEach(node.jsDocComments, function (jsDocComment) { - ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 279) { - addLeafNode(tag); - } - }); - }); - ts.forEachChild(node, addChildrenRecursively); - } - } - function mergeChildren(children) { - var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var decl = child.node; - var name = decl.name && nodeText(decl.name); - if (!name) { - return true; } - var itemsWithSameName = nameToItems[name]; - if (!itemsWithSameName) { - nameToItems[name] = child; - return true; + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles); } - if (itemsWithSameName instanceof Array) { - for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { - var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child)) { - return false; - } - } - itemsWithSameName.push(child); - return true; + if (node.kind === 96) { + return getReferencesForSuperKeyword(node); } - else { - var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child)) { - return false; + } + var symbol = typeChecker.getSymbolAtLocation(node); + if (!implementations && !symbol && node.kind === 9) { + return getReferencesForStringLiteral(node, sourceFiles); + } + if (!symbol) { + return undefined; + } + var declarations = symbol.declarations; + if (!declarations || !declarations.length) { + return undefined; + } + var result; + var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); + var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var scope = getSymbolScope(symbol); + var symbolToIndex = []; + if (scope) { + result = []; + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + } + else { + var internedName = getInternedName(symbol, node); + for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { + var sourceFile = sourceFiles_8[_i]; + cancellationToken.throwIfCancellationRequested(); + var nameTable = ts.getNameTable(sourceFile); + if (nameTable[internedName] !== undefined) { + result = result || []; + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } - nameToItems[name] = [itemWithSameName, child]; - return true; } - function tryMerge(a, b) { - if (shouldReallyMerge(a.node, b.node)) { - merge(a, b); - return true; - } - return false; + } + return result; + function getDefinition(symbol) { + var info = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node); + var name = ts.map(info.displayParts, function (p) { return p.text; }).join(""); + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; } - }); - function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 225 || areSameModule(a, b)); - function areSameModule(a, b) { - if (a.body.kind !== b.body.kind) { - return false; + return { + containerKind: "", + containerName: "", + name: name, + kind: info.symbolKind, + fileName: declarations[0].getSourceFile().fileName, + textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + displayParts: info.displayParts + }; + } + function getAliasSymbolForPropertyNameSymbol(symbol, location) { + if (symbol.flags & 8388608) { + var defaultImport = ts.getDeclarationOfKind(symbol, 232); + if (defaultImport) { + return typeChecker.getAliasedSymbol(symbol); } - if (a.body.kind !== 225) { - return true; + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 || + declaration.kind === 239) ? declaration : undefined; }); + if (importOrExportSpecifier && + (!importOrExportSpecifier.propertyName || + importOrExportSpecifier.propertyName === location)) { + return importOrExportSpecifier.kind === 235 ? + typeChecker.getAliasedSymbol(symbol) : + typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } - return areSameModule(a.body, b.body); } + return undefined; } - function merge(target, source) { - target.additionalNodes = target.additionalNodes || []; - target.additionalNodes.push(source.node); - if (source.additionalNodes) { - (_a = target.additionalNodes).push.apply(_a, source.additionalNodes); - } - target.children = ts.concatenate(target.children, source.children); - if (target.children) { - mergeChildren(target.children); - sortChildren(target.children); - } - var _a; + function followAliasIfNecessary(symbol, location) { + return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; } - } - function sortChildren(children) { - children.sort(compareChildren); - } - function compareChildren(child1, child2) { - var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); - if (name1 && name2) { - var cmp = localeCompareFix(name1, name2); - return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); + function getPropertySymbolOfDestructuringAssignment(location) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + typeChecker.getPropertySymbolOfDestructuringAssignment(location); } - else { - return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 170); + return bindingElement && + bindingElement.parent.kind === 168 && + !bindingElement.propertyName; } - } - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { - for (var i = 0; i < Math.min(a.length, b.length); i++) { - var chA = a.charAt(i), chB = b.charAt(i); - if (chA === "\"" && chB === "'") { - return 1; - } - if (chA === "'" && chB === "\"") { - return -1; - } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); - if (cmp !== 0) { - return cmp; + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } + return undefined; } - return a.length - b.length; - }; - function tryGetName(node) { - if (node.kind === 225) { - return getModuleName(node); + function getInternedName(symbol, location) { + if (ts.isImportOrExportSpecifierName(location)) { + return location.getText(); + } + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + return ts.stripQuotes(symbol.name); } - var decl = node; - if (decl.name) { - return ts.getPropertyNameForPropertyNameNode(decl.name); - } - switch (node.kind) { - case 179: - case 180: - case 192: - return getFunctionOrClassName(node); - case 279: - return getJSDocTypedefTagName(node); - default: - return undefined; - } - } - function getItemName(node) { - if (node.kind === 225) { - return getModuleName(node); - } - var name = node.name; - if (name) { - var text = nodeText(name); - if (text.length > 0) { - return text; + function getSymbolScope(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { + return valueDeclaration; } - } - switch (node.kind) { - case 256: - var sourceFile = node; - return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" - : ""; - case 180: - case 220: - case 179: - case 221: - case 192: - if (ts.getModifierFlags(node) & 512) { - return "default"; - } - return getFunctionOrClassName(node); - case 148: - return "constructor"; - case 152: - return "new()"; - case 151: - return "()"; - case 153: - return "[]"; - case 279: - return getJSDocTypedefTagName(node); - default: - return ""; - } - } - function getJSDocTypedefTagName(node) { - if (node.name) { - return node.name.text; - } - else { - var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200) { - if (parentNode.declarationList.declarations.length > 0) { - var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { - return nameIdentifier.text; - } + 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, 222); } } - return ""; - } - } - function topLevelItems(root) { - var topLevel = []; - function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); - if (item.children) { - for (var _i = 0, _a = item.children; _i < _a.length; _i++) { - var child = _a[_i]; - recur(child); + if (symbol.flags & 8388608) { + return undefined; + } + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + if (symbol.parent || (symbol.flags & 268435456)) { + return undefined; + } + var scope; + var declarations = symbol.getDeclarations(); + if (declarations) { + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; + var container = ts.getContainerNode(declaration); + if (!container) { + return undefined; + } + if (scope && scope !== container) { + return undefined; } + if (container.kind === 256 && !ts.isExternalModule(container)) { + return undefined; + } + scope = container; } } + return scope; } - recur(root); - return topLevel; - function isTopLevel(item) { - switch (navigationBarNodeKind(item)) { - case 221: - case 192: - case 224: - case 222: - case 225: - case 256: - case 223: - case 279: - return true; - case 148: - case 147: - case 149: - case 150: - case 218: - return hasSomeImportantChild(item); - case 180: - case 220: - case 179: - return isTopLevelFunctionDeclaration(item); - default: - return false; + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + if (!symbolName || !symbolName.length) { + return positions; } - function isTopLevelFunctionDeclaration(item) { - if (!item.node.body) { - return false; - } - switch (navigationBarNodeKind(item.parent)) { - case 226: - case 256: - case 147: - case 148: - return true; - default: - return hasSomeImportantChild(item); + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + cancellationToken.throwIfCancellationRequested(); + if (position > end) + break; + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4))) { + positions.push(position); } + position = text.indexOf(symbolName, position + symbolNameLength + 1); } - function hasSomeImportantChild(item) { - return ts.forEach(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 218 && childKind !== 169; - }); - } + return positions; } - } - var emptyChildItemArray = []; - function convertToTree(n) { - return { - text: getItemName(n.node), - kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), - spans: getSpans(n), - childItems: ts.map(n.children, convertToTree) - }; - } - function convertToTopLevelItem(n) { - return { - text: getItemName(n.node), - kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), - spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, - indent: n.indent, - bolded: false, - grayed: false - }; - function convertToChildItem(n) { - return { - text: getItemName(n.node), - kind: ts.getNodeKind(n.node), - kindModifiers: ts.getNodeModifiers(n.node), - spans: getSpans(n), - childItems: emptyChildItemArray, - indent: 0, - bolded: false, - grayed: false + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + return; + } + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(getReferenceEntryFromNode(node)); + } + }); + var definition = { + containerKind: "", + containerName: "", + fileName: targetLabel.getSourceFile().fileName, + kind: ts.ScriptElementKind.label, + name: labelName, + textSpan: ts.createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), + displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] }; + return [{ definition: definition, references: references }]; } - } - function getSpans(n) { - var spans = [getNodeSpan(n.node)]; - if (n.additionalNodes) { - for (var _i = 0, _a = n.additionalNodes; _i < _a.length; _i++) { - var node = _a[_i]; - spans.push(getNodeSpan(node)); - } - } - return spans; - } - function getModuleName(moduleDeclaration) { - if (ts.isAmbientModule(moduleDeclaration)) { - return ts.getTextOfNode(moduleDeclaration.name); - } - var result = []; - result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 225) { - moduleDeclaration = moduleDeclaration.body; - result.push(moduleDeclaration.name.text); - } - return result.join("."); - } - function getInteriorModule(decl) { - return decl.body.kind === 225 ? getInteriorModule(decl.body) : decl; - } - function isComputedProperty(member) { - return !member.name || member.name.kind === 140; - } - function getNodeSpan(node) { - return node.kind === 256 - ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); - } - function getFunctionOrClassName(node) { - if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); - } - else if (node.parent.kind === 218) { - return ts.declarationNameToString(node.parent.name); - } - else if (node.parent.kind === 187 && - node.parent.operatorToken.kind === 56) { - return nodeText(node.parent.left); - } - else if (node.parent.kind === 253 && node.parent.name) { - return nodeText(node.parent.name); - } - else if (ts.getModifierFlags(node) & 512) { - return "default"; - } - else { - return ts.isClassLike(node) ? "" : ""; - } - } - function isFunctionOrClassExpression(node) { - return node.kind === 179 || node.kind === 180 || node.kind === 192; - } - })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var OutliningElementsCollector; - (function (OutliningElementsCollector) { - function collectElements(sourceFile) { - var elements = []; - var collapseText = "..."; - function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { - if (hintSpanNode && startElement && endElement) { - var span_12 = { - textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), - hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span_12); - } - } - function addOutliningSpanComments(commentSpan, autoCollapse) { - if (commentSpan) { - var span_13 = { - textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), - bannerText: collapseText, - autoCollapse: autoCollapse - }; - elements.push(span_13); + function isValidReferencePosition(node, searchSymbolName) { + if (node) { + switch (node.kind) { + case 70: + return node.getWidth() === searchSymbolName.length; + case 9: + if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + isNameOfExternalModuleImportOrDeclaration(node)) { + return node.getWidth() === searchSymbolName.length + 2; + } + break; + case 8: + if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { + return node.getWidth() === searchSymbolName.length; + } + break; + } } + return false; } - function addOutliningForLeadingCommentsForNode(n) { - var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); - if (comments) { - var firstSingleLineCommentStart = -1; - var lastSingleLineCommentEnd = -1; - var isFirstSingleLineComment = true; - var singleLineCommentCount = 0; - for (var _i = 0, comments_4 = comments; _i < comments_4.length; _i++) { - var currentComment = comments_4[_i]; - if (currentComment.kind === 2) { - if (isFirstSingleLineComment) { - firstSingleLineCommentStart = currentComment.pos; + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex) { + var sourceFile = container.getSourceFile(); + var start = findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); + var parents = getParentSymbolsOfPropertyAccess(); + var inheritsFromCache = ts.createMap(); + if (possiblePositions.length) { + var searchSymbols_1 = populateSearchSymbolSet(searchSymbol, searchLocation); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || + (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + result.push({ + definition: undefined, + references: [{ + fileName: sourceFile.fileName, + textSpan: ts.createTextSpan(position, searchText.length), + isWriteAccess: false, + isDefinition: false + }] + }); } - isFirstSingleLineComment = false; - lastSingleLineCommentEnd = currentComment.end; - singleLineCommentCount++; + return; } - else if (currentComment.kind === 3) { - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); - addOutliningSpanComments(currentComment, false); - singleLineCommentCount = 0; - lastSingleLineCommentEnd = -1; - isFirstSingleLineComment = true; + if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { + return; + } + var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); + if (referenceSymbol) { + var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); + var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); + if (relatedSymbol) { + addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + } + else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { + addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + } + else if (searchLocation.kind === 122) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + } + }); + } + return; + function getParentSymbolsOfPropertyAccess() { + if (implementations) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); + if (propertyAccessExpression) { + var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); + if (localParentType) { + if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & 1572864) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } } } - combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); } - } - function combineAndAddMultipleSingleLineComments(count, start, end) { - if (count > 1) { - var multipleSingleLineComments = { - pos: start, - end: end, - kind: 2 - }; - addOutliningSpanComments(multipleSingleLineComments, false); + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; } - } - function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180; - } - var depth = 0; - var maxDepth = 20; - function walk(n) { - if (depth > maxDepth) { - return; + function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { + ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); + var referenceClass = referenceLocation.parent; + if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { + ts.Debug.assert(referenceClass.name === referenceLocation); + addReferences(findOwnConstructorCalls(searchSymbol)); + } + else { + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); + } + } } - if (ts.isDeclaration(n)) { - addOutliningForLeadingCommentsForNode(n); + function addReferences(references) { + if (references.length) { + var referencedSymbol = getReferencedSymbol(searchSymbol); + ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); + } } - switch (n.kind) { - case 199: - if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_22.kind === 204 || - parent_22.kind === 207 || - parent_22.kind === 208 || - parent_22.kind === 206 || - parent_22.kind === 203 || - parent_22.kind === 205 || - parent_22.kind === 212 || - parent_22.kind === 252) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); - break; - } - if (parent_22.kind === 216) { - var tryStatement = parent_22; - if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); - break; - } - else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); - if (finallyKeyword) { - addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); - break; + function findOwnConstructorCalls(classSymbol) { + var result = []; + for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 149); + var ctrKeyword = decl.getChildAt(0); + ts.Debug.assert(ctrKeyword.kind === 122); + result.push(ctrKeyword); + } + ts.forEachProperty(classSymbol.exports, function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 148) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); } - } + }); } - var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); - elements.push({ - textSpan: span_14, - hintSpan: span_14, - bannerText: collapseText, - autoCollapse: autoCollapse(n) - }); - break; } - case 226: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); - break; + }); + return result; + } + function superConstructorAccesses(cls) { + var symbol = cls.symbol; + var ctr = symbol.members["__constructor"]; + if (!ctr) { + return []; } - case 221: - case 222: - case 224: - case 171: - case 227: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); - break; + var result = []; + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 149); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 96, function (node) { + if (ts.isCallExpressionTarget(node)) { + result.push(node); + } + }); + } } - case 170: - var openBracket = ts.findChildOfKind(n, 19, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20, sourceFile); - addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); - break; + ; + return result; } - depth++; - ts.forEachChild(n, walk); - depth--; - } - walk(sourceFile); - return elements; - } - OutliningElementsCollector.collectElements = collectElements; - })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - (function (PatternMatchKind) { - PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; - PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; - PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; - PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; - function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { - return { - kind: kind, - punctuationStripped: punctuationStripped, - isCaseSensitive: isCaseSensitive, - camelCaseWeight: camelCaseWeight - }; - } - function createPatternMatcher(pattern) { - var stringToWordSpans = ts.createMap(); - pattern = pattern.trim(); - var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); - var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); - return { - getMatches: getMatches, - getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, - patternContainsDots: dotSeparatedSegments.length > 1 - }; - function skipMatch(candidate) { - return invalidPattern || !candidate; - } - function getMatchesForLastSegmentOfPattern(candidate) { - if (skipMatch(candidate)) { - return undefined; - } - return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - } - function getMatches(candidateContainers, candidate) { - if (skipMatch(candidate)) { - return undefined; - } - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); - if (!candidateMatch) { - return undefined; - } - candidateContainers = candidateContainers || []; - if (dotSeparatedSegments.length - 1 > candidateContainers.length) { - return undefined; - } - var totalMatch = candidateMatch; - for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i -= 1, j -= 1) { - var segment = dotSeparatedSegments[i]; - var containerName = candidateContainers[j]; - var containerMatch = matchSegment(containerName, segment); - if (!containerMatch) { - return undefined; - } - ts.addRange(totalMatch, containerMatch); - } - return totalMatch; - } - function getWordSpans(word) { - if (!(word in stringToWordSpans)) { - stringToWordSpans[word] = breakIntoWordSpans(word); - } - return stringToWordSpans[word]; - } - function matchTextChunk(candidate, chunk, punctuationStripped) { - var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); - if (index === 0) { - if (chunk.text.length === candidate.length) { - return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + function getReferencedSymbol(symbol) { + var symbolId = ts.getSymbolId(symbol); + var index = symbolToIndex[symbolId]; + if (index === undefined) { + index = result.length; + symbolToIndex[symbolId] = index; + result.push({ + definition: getDefinition(symbol), + references: [] + }); + } + return result[index]; } - else { - return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, ts.startsWith(candidate, chunk.text)); + function addReferenceToRelatedSymbol(node, relatedSymbol) { + var references = getReferencedSymbol(relatedSymbol).references; + if (implementations) { + getImplementationReferenceEntryForNode(node, references); + } + else { + references.push(getReferenceEntryFromNode(node)); + } } } - var isLowercase = chunk.isLowerCase; - if (isLowercase) { - if (index > 0) { - var wordSpans = getWordSpans(candidate); - for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { - var span_15 = wordSpans_1[_i]; - if (partStartsWith(candidate, span_15, chunk.text, true)) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span_15, chunk.text, false)); + function getImplementationReferenceEntryForNode(refNode, result) { + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + result.push(getReferenceEntryFromNode(refNode.parent)); + } + else if (refNode.kind === 70) { + if (refNode.parent.kind === 254) { + getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + } + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + result.push(getReferenceEntryFromNode(containingClass)); + return; + } + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + var parent_21 = containingTypeReference.parent; + if (ts.isVariableLike(parent_21) && parent_21.type === containingTypeReference && parent_21.initializer && isImplementationExpression(parent_21.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); + } + else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { + if (parent_21.body.kind === 200) { + ts.forEachReturnStatement(parent_21.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + } + }); + } + else if (isImplementationExpression(parent_21.body)) { + maybeAdd(getReferenceEntryFromNode(parent_21.body)); + } + } + else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_21.expression)); } } } - } - else { - if (candidate.indexOf(chunk.text) > 0) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + function maybeAdd(a) { + if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { + result.push(a); + } } } - if (!isLowercase) { - if (chunk.characterSpans.length > 0) { - var candidateParts = getWordSpans(candidate); - var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { + result.push(componentType.symbol); } - camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); - if (camelCaseWeight !== undefined) { - return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + if (componentType.getFlags() & 1572864) { + getSymbolsForClassAndInterfaceComponents(componentType, result); } } + return result; } - if (isLowercase) { - if (chunk.text.length < candidate.length) { - if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; } + node = node.parent; } + return topLevelTypeReference; } - return undefined; - } - function containsSpaceOrAsterisk(text) { - for (var i = 0; i < text.length; i++) { - var ch = text.charCodeAt(i); - if (ch === 32 || ch === 42) { - return true; - } - } - return false; - } - function matchSegment(candidate, segment) { - if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { - var match = matchTextChunk(candidate, segment.totalTextChunk, false); - if (match) { - return [match]; + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 195 + && node.parent.kind === 251 + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 70 || node.kind === 173) { + return getContainingClassIfInHeritageClause(node.parent); + } } + return undefined; } - var subWordTextChunks = segment.subWordTextChunks; - var matches = undefined; - for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { - var subWordTextChunk = subWordTextChunks_1[_i]; - var result = matchTextChunk(candidate, subWordTextChunk, true); - if (!result) { - return undefined; + function isImplementationExpression(node) { + if (node.kind === 179) { + return isImplementationExpression(node.expression); } - matches = matches || []; - matches.push(result); - } - return matches; - } - function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { - var patternPartStart = patternSpan ? patternSpan.start : 0; - var patternPartLength = patternSpan ? patternSpan.length : pattern.length; - if (patternPartLength > candidateSpan.length) { - return false; + return node.kind === 181 || + node.kind === 180 || + node.kind === 172 || + node.kind === 193 || + node.kind === 171; } - if (ignoreCase) { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (toLowerCase(ch1) !== toLowerCase(ch2)) { - return false; + function explicitlyInheritsFrom(child, parent, cachedResults) { + var parentIsInterface = parent.getFlags() & 64; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; } - } - } - else { - for (var i = 0; i < patternPartLength; i++) { - var ch1 = pattern.charCodeAt(patternPartStart + i); - var ch2 = candidate.charCodeAt(candidateSpan.start + i); - if (ch1 !== ch2) { + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + if (key in cachedResults) { + return cachedResults[key]; + } + cachedResults[key] = false; + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 223) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } return false; + }); + cachedResults[key] = inherits; + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); + } } + return false; } } - return true; - } - function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { - var chunkCharacterSpans = chunk.characterSpans; - var currentCandidate = 0; - var currentChunkSpan = 0; - var firstMatch = undefined; - var contiguous = undefined; - while (true) { - if (currentChunkSpan === chunkCharacterSpans.length) { - var weight = 0; - if (contiguous) { - weight += 1; + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { + return undefined; + } + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 146: + case 145: + case 148: + case 147: + case 149: + case 150: + case 151: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + default: + return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 96) { + return; } - if (firstMatch === 0) { - weight += 2; + var container = ts.getSuperContainer(node, false); + if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(getReferenceEntryFromNode(node)); } - return weight; + }); + var definition = getDefinition(searchSpaceNode.symbol); + return [{ definition: definition, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 148: + case 147: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + case 146: + case 145: + case 149: + case 150: + case 151: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + case 256: + if (ts.isExternalModule(searchSpaceNode)) { + return undefined; + } + case 221: + case 180: + break; + default: + return undefined; } - else if (currentCandidate === candidateParts.length) { + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 256) { + ts.forEach(sourceFiles, function (sourceFile) { + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: "this", + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + displayParts: displayParts + }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + cancellationToken.throwIfCancellationRequested(); + var node = ts.getTouchingWord(sourceFile, position); + if (!node || !ts.isThis(node)) { + return; + } + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 180: + case 221: + if (searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 148: + case 147: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 193: + case 222: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { + result.push(getReferenceEntryFromNode(node)); + } + break; + case 256: + if (container.kind === 256 && !ts.isExternalModule(container)) { + result.push(getReferenceEntryFromNode(node)); + } + break; + } + }); + } + } + function getReferencesForStringLiteral(node, sourceFiles) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (!type) { return undefined; } - var candidatePart = candidateParts[currentCandidate]; - var gotOneMatchThisCandidate = false; - for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { - var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; - if (gotOneMatchThisCandidate) { - if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || - !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { - break; + var references = []; + for (var _i = 0, sourceFiles_9 = sourceFiles; _i < sourceFiles_9.length; _i++) { + var sourceFile = sourceFiles_9[_i]; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd()); + getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + } + return [{ + definition: { + containerKind: "", + containerName: "", + fileName: node.getSourceFile().fileName, + kind: ts.ScriptElementKind.variableElement, + name: type.text, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] + }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + 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) { + return; + } + var type_1 = ts.getStringLiteralTypeForNode(node_2, typeChecker); + if (type_1 === searchType) { + references.push(getReferenceEntryFromNode(node_2)); } } - if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { - break; + } + } + function populateSearchSymbolSet(symbol, location) { + var result = [symbol]; + var containingObjectLiteralElement = getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); + if (propertySymbol) { + result.push(propertySymbol); } - gotOneMatchThisCandidate = true; - firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; - contiguous = contiguous === undefined ? true : contiguous; - candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); } - if (!gotOneMatchThisCandidate && contiguous !== undefined) { - contiguous = false; + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(symbol, location); + if (aliasSymbol) { + result = result.concat(populateSearchSymbolSet(aliasSymbol, location)); } - currentCandidate++; + if (containingObjectLiteralElement) { + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap()); + } + }); + return result; } - } - } - ts.createPatternMatcher = createPatternMatcher; - function createSegment(text) { - return { - totalTextChunk: createTextChunk(text), - subWordTextChunks: breakPatternIntoTextChunks(text) - }; - } - function segmentIsInvalid(segment) { - return segment.subWordTextChunks.length === 0; - } - function isUpperCaseLetter(ch) { - if (ch >= 65 && ch <= 90) { - return true; - } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { - return false; - } - var str = String.fromCharCode(ch); - return str === str.toUpperCase(); - } - function isLowerCaseLetter(ch) { - if (ch >= 97 && ch <= 122) { - return true; - } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { - return false; - } - var str = String.fromCharCode(ch); - return str === str.toLowerCase(); - } - function indexOfIgnoringCase(string, value) { - for (var i = 0, n = string.length - value.length; i <= n; i++) { - if (startsWithIgnoringCase(string, value, i)) { - return i; - } - } - return -1; - } - function startsWithIgnoringCase(string, value, start) { - for (var i = 0, n = value.length; i < n; i++) { - var ch1 = toLowerCase(string.charCodeAt(i + start)); - var ch2 = value.charCodeAt(i); - if (ch1 !== ch2) { - return false; - } - } - return true; - } - function toLowerCase(ch) { - if (ch >= 65 && ch <= 90) { - return 97 + (ch - 65); - } - if (ch < 127) { - return ch; - } - return String.fromCharCode(ch).toLowerCase().charCodeAt(0); - } - function isDigit(ch) { - return ch >= 48 && ch <= 57; - } - function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 || ch === 36; - } - function breakPatternIntoTextChunks(pattern) { - var result = []; - var wordStart = 0; - var wordLength = 0; - for (var i = 0; i < pattern.length; i++) { - var ch = pattern.charCodeAt(i); - if (isWordChar(ch)) { - if (wordLength === 0) { - wordStart = i; + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache) { + if (!symbol) { + return; } - wordLength++; - } - else { - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - wordLength = 0; + if (symbol.name in previousIterationSymbolsCache) { + return; } - } - } - if (wordLength > 0) { - result.push(createTextChunk(pattern.substr(wordStart, wordLength))); - } - return result; - } - function createTextChunk(text) { - var textLowerCase = text.toLowerCase(); - return { - text: text, - textLowerCase: textLowerCase, - isLowerCase: text === textLowerCase, - characterSpans: breakIntoCharacterSpans(text) - }; - } - function breakIntoCharacterSpans(identifier) { - return breakIntoSpans(identifier, false); - } - ts.breakIntoCharacterSpans = breakIntoCharacterSpans; - function breakIntoWordSpans(identifier) { - return breakIntoSpans(identifier, true); - } - ts.breakIntoWordSpans = breakIntoWordSpans; - function breakIntoSpans(identifier, word) { - var result = []; - var wordStart = 0; - for (var i = 1, n = identifier.length; i < n; i++) { - var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); - var currentIsDigit = isDigit(identifier.charCodeAt(i)); - var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); - var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); - if (charIsPunctuation(identifier.charCodeAt(i - 1)) || - charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit !== currentIsDigit || - hasTransitionFromLowerToUpper || - hasTransitionFromUpperToLower) { - if (!isAllPunctuation(identifier, wordStart, i)) { - result.push(ts.createTextSpan(wordStart, i - wordStart)); + if (symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 223) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); } - wordStart = i; - } - } - if (!isAllPunctuation(identifier, wordStart, identifier.length)) { - result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); - } - return result; - } - function charIsPunctuation(ch) { - switch (ch) { - case 33: - case 34: - case 35: - case 37: - case 38: - case 39: - case 40: - case 41: - case 42: - case 44: - case 45: - case 46: - case 47: - case 58: - case 59: - case 63: - case 64: - case 91: - case 92: - case 93: - case 95: - case 123: - case 125: - return true; - } - return false; - } - function isAllPunctuation(identifier, start, end) { - for (var i = start; i < end; i++) { - var ch = identifier.charCodeAt(i); - if (!charIsPunctuation(ch) || ch === 95 || ch === 36) { - return false; - } - } - return true; - } - function transitionFromUpperToLower(identifier, word, index, wordStart) { - if (word) { - if (index !== wordStart && - index + 1 < identifier.length) { - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); - if (currentIsUpper && nextIsLower) { - for (var i = wordStart; i < index; i++) { - if (!isUpperCaseLetter(identifier.charCodeAt(i))) { - return false; + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = typeChecker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); + } + previousIterationSymbolsCache[symbol.name] = symbol; + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache); } } - return true; } } - } - return false; - } - function transitionFromLowerToUpper(identifier, word, index) { - var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); - var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); - var transition = word - ? (currentIsUpper && !lastIsUpper) - : currentIsUpper; - return transition; - } -})(ts || (ts = {})); -var ts; -(function (ts) { - function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { - if (readImportFiles === void 0) { readImportFiles = true; } - if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } - var referencedFiles = []; - var typeReferenceDirectives = []; - var importedFiles = []; - var ambientExternalModules; - var isNoDefaultLib = false; - var braceNesting = 0; - var externalModule = false; - function nextToken() { - var token = ts.scanner.scan(); - if (token === 15) { - braceNesting++; - } - else if (token === 16) { - braceNesting--; - } - return token; - } - function processTripleSlashDirectives() { - var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); - ts.forEach(commentRanges, function (commentRange) { - var comment = sourceText.substring(commentRange.pos, commentRange.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); - if (referencePathMatchResult) { - isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var fileReference = referencePathMatchResult.fileReference; - if (fileReference) { - var collection = referencePathMatchResult.isTypeReferenceDirective - ? typeReferenceDirectives - : referencedFiles; - collection.push(fileReference); - } + function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache) { + if (ts.contains(searchSymbols, referenceSymbol)) { + return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) && referenceSymbol; } - }); - } - function getFileReference() { - var file = ts.scanner.getTokenValue(); - var pos = ts.scanner.getTokenPos(); - return { - fileName: file, - pos: pos, - end: pos + file.length - }; - } - function recordAmbientExternalModule() { - if (!ambientExternalModules) { - ambientExternalModules = []; - } - ambientExternalModules.push({ ref: getFileReference(), depth: braceNesting }); - } - function recordModuleName() { - importedFiles.push(getFileReference()); - markAsExternalModuleIfTopLevel(); - } - function markAsExternalModuleIfTopLevel() { - if (braceNesting === 0) { - externalModule = true; - } - } - function tryConsumeDeclare() { - var token = ts.scanner.getToken(); - if (token === 122) { - token = nextToken(); - if (token === 125) { - token = nextToken(); - if (token === 9) { - recordAmbientExternalModule(); + var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); + if (aliasSymbol) { + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache); + } + var containingObjectLiteralElement = getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement), function (contextualSymbol) { + return ts.forEach(typeChecker.getRootSymbols(contextualSymbol), function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + }); + if (contextualSymbol) { + return contextualSymbol; + } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation); + if (propertySymbol && searchSymbols.indexOf(propertySymbol) >= 0) { + return propertySymbol; } } - return true; - } - return false; - } - function tryConsumeImport() { - var token = ts.scanner.getToken(); - if (token === 89) { - token = nextToken(); - if (token === 9) { - recordModuleName(); - return true; + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol); + if (bindingElementPropertySymbol && searchSymbols.indexOf(bindingElementPropertySymbol) >= 0) { + return bindingElementPropertySymbol; } - else { - if (token === 69 || ts.isKeyword(token)) { - token = nextToken(); - if (token === 136) { - token = nextToken(); - if (token === 9) { - recordModuleName(); - return true; - } - } - else if (token === 56) { - if (tryConsumeRequireCall(true)) { - return true; - } - } - else if (token === 24) { - token = nextToken(); - } - else { - return true; - } + return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (searchSymbols.indexOf(rootSymbol) >= 0) { + return rootSymbol; } - if (token === 15) { - token = nextToken(); - while (token !== 16 && token !== 1) { - token = nextToken(); - } - if (token === 16) { - token = nextToken(); - if (token === 136) { - token = nextToken(); - if (token === 9) { - recordModuleName(); - } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (parents) { + if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache); })) { + return undefined; } } + var result_3 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, ts.createMap()); + return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } - else if (token === 37) { - token = nextToken(); - if (token === 116) { - token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { - token = nextToken(); - if (token === 136) { - token = nextToken(); - if (token === 9) { - recordModuleName(); - } - } - } - } + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 141) { + var nameExpression = node.name.expression; + if (ts.isStringOrNumericLiteral(nameExpression.kind)) { + return nameExpression.text; } + return undefined; } - return true; + return node.name.text; } - return false; - } - function tryConsumeExport() { - var token = ts.scanner.getToken(); - if (token === 82) { - markAsExternalModuleIfTopLevel(); - token = nextToken(); - if (token === 15) { - token = nextToken(); - while (token !== 16 && token !== 1) { - token = nextToken(); + function getPropertySymbolsFromContextualType(node) { + var objectLiteral = node.parent; + var contextualType = typeChecker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_4 = []; + var symbol_2 = contextualType.getProperty(name); + if (symbol_2) { + result_4.push(symbol_2); } - if (token === 16) { - token = nextToken(); - if (token === 136) { - token = nextToken(); - if (token === 9) { - recordModuleName(); + if (contextualType.flags & 524288) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_4.push(symbol); } - } - } - } - else if (token === 37) { - token = nextToken(); - if (token === 136) { - token = nextToken(); - if (token === 9) { - recordModuleName(); - } + }); } + return result_4; } - else if (token === 89) { - token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { - token = nextToken(); - if (token === 56) { - if (tryConsumeRequireCall(true)) { - return true; + return undefined; + } + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + lastIterationMeaning = meaning; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; } } - } + } while (meaning !== lastIterationMeaning); } - return true; + return meaning; } - return false; } - function tryConsumeRequireCall(skipCurrentToken) { - var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129) { - token = nextToken(); - if (token === 17) { - token = nextToken(); - if (token === 9) { - recordModuleName(); - } - } - return true; + FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + function convertReferences(referenceSymbols) { + if (!referenceSymbols) { + return undefined; } - return false; + var referenceEntries = []; + for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { + var referenceSymbol = referenceSymbols_1[_i]; + ts.addRange(referenceEntries, referenceSymbol.references); + } + return referenceEntries; } - function tryConsumeDefine() { - var token = ts.scanner.getToken(); - if (token === 69 && ts.scanner.getTokenValue() === "define") { - token = nextToken(); - if (token !== 17) { + FindAllReferences.convertReferences = convertReferences; + function isImplementation(node) { + if (!node) { + return false; + } + else if (ts.isVariableLike(node)) { + if (node.initializer) { return true; } - token = nextToken(); - if (token === 9) { - token = nextToken(); - if (token === 24) { - token = nextToken(); - } - else { - return true; - } - } - if (token !== 19) { - return true; + else if (node.kind === 219) { + var parentStatement = getParentStatementOfVariableDeclaration(node); + return parentStatement && ts.hasModifier(parentStatement, 2); } - token = nextToken(); - var i = 0; - while (token !== 20 && token !== 1) { - if (token === 9) { - recordModuleName(); - i++; - } - token = nextToken(); + } + else if (ts.isFunctionLike(node)) { + return !!node.body || ts.hasModifier(node, 2); + } + else { + switch (node.kind) { + case 222: + case 193: + case 225: + case 226: + return true; } - return true; } return false; } - function processImports() { - ts.scanner.setText(sourceText); - nextToken(); - while (true) { - if (ts.scanner.getToken() === 1) { - break; - } - if (tryConsumeDeclare() || - tryConsumeImport() || - tryConsumeExport() || - (detectJavaScriptImports && (tryConsumeRequireCall(false) || tryConsumeDefine()))) { - continue; - } - else { - nextToken(); - } + function getParentStatementOfVariableDeclaration(node) { + if (node.parent && node.parent.parent && node.parent.parent.kind === 201) { + ts.Debug.assert(node.parent.kind === 220); + return node.parent.parent; } - ts.scanner.setText(undefined); - } - if (readImportFiles) { - processImports(); } - processTripleSlashDirectives(); - if (externalModule) { - if (ambientExternalModules) { - for (var _i = 0, ambientExternalModules_1 = ambientExternalModules; _i < ambientExternalModules_1.length; _i++) { - var decl = ambientExternalModules_1[_i]; - importedFiles.push(decl.ref); + function getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result) { + var refSymbol = typeChecker.getSymbolAtLocation(node); + var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); + if (shorthandSymbol) { + for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.getMeaningFromDeclaration(declaration) & 1) { + result.push(getReferenceEntryFromNode(declaration)); + } } } - return { referencedFiles: referencedFiles, typeReferenceDirectives: typeReferenceDirectives, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: undefined }; } - else { - var ambientModuleNames = void 0; - if (ambientExternalModules) { - for (var _a = 0, ambientExternalModules_2 = ambientExternalModules; _a < ambientExternalModules_2.length; _a++) { - var decl = ambientExternalModules_2[_a]; - if (decl.depth === 0) { - if (!ambientModuleNames) { - ambientModuleNames = []; - } - ambientModuleNames.push(decl.ref.fileName); - } - else { - importedFiles.push(decl.ref); - } - } + FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; + function getReferenceEntryFromNode(node) { + var start = node.getStart(); + var end = node.getEnd(); + if (node.kind === 9) { + start += 1; + end -= 1; } - return { referencedFiles: referencedFiles, typeReferenceDirectives: typeReferenceDirectives, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientModuleNames }; + return { + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(start, end), + isWriteAccess: isWriteAccess(node), + isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node) + }; } - } - ts.preProcessFile = preProcessFile; -})(ts || (ts = {})); -var ts; -(function (ts) { - var Rename; - (function (Rename) { - function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { - var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); - var node = ts.getTouchingWord(sourceFile, position, true); - if (node) { - if (node.kind === 69 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node)) { - var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - if (ts.forEach(declarations, isDefinedInLibraryFile)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - if (kind) { - return { - canRename: true, - kind: kind, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: typeChecker.getFullyQualifiedName(symbol), - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - else if (node.kind === 9) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); - } - else { - var displayName = ts.stripQuotes(type.text); - return { - canRename: true, - kind: ts.ScriptElementKind.variableElement, - displayName: displayName, - localizedErrorMessage: undefined, - fullDisplayName: displayName, - kindModifiers: ts.ScriptElementKindModifier.none, - triggerSpan: createTriggerSpanForNode(node, sourceFile) - }; - } - } - } - } - } - return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); - function getRenameInfoError(localizedErrorMessage) { - return { - canRename: false, - localizedErrorMessage: localizedErrorMessage, - displayName: undefined, - fullDisplayName: undefined, - kind: undefined, - kindModifiers: undefined, - triggerSpan: undefined - }; + FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; + function isWriteAccess(node) { + if (node.kind === 70 && ts.isDeclarationName(node)) { + return true; } - function isDefinedInLibraryFile(declaration) { - if (defaultLibFileName) { - var sourceFile_1 = declaration.getSourceFile(); - var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); - if (canonicalName === canonicalDefaultLibName) { - return true; - } + var parent = node.parent; + if (parent) { + if (parent.kind === 187 || parent.kind === 186) { + return true; + } + else if (parent.kind === 188 && parent.left === node) { + var operator = parent.operatorToken.kind; + return 57 <= operator && operator <= 69; } - return false; } - function createTriggerSpanForNode(node, sourceFile) { - var start = node.getStart(sourceFile); - var width = node.getWidth(sourceFile); - if (node.kind === 9) { - start += 1; - width -= 2; + return false; + } + function forEachDescendantOfKind(node, kind, action) { + ts.forEachChild(node, function (child) { + if (child.kind === kind) { + action(child); } - return ts.createTextSpan(start, width); + forEachDescendantOfKind(child, kind, action); + }); + } + function getContainingObjectLiteralElement(node) { + switch (node.kind) { + case 9: + case 8: + if (node.parent.kind === 141) { + return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; + } + case 70: + return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } + return undefined; } - Rename.getRenameInfo = getRenameInfo; - })(Rename = ts.Rename || (ts.Rename = {})); + function isObjectLiteralPropertyDeclaration(node) { + switch (node.kind) { + case 253: + case 254: + case 148: + case 150: + case 151: + return true; + } + return false; + } + function tryGetClassByExtendingIdentifier(node) { + return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9) { + return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); + } + return false; + } + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; (function (ts) { - var SignatureHelp; - (function (SignatureHelp) { - var emptyArray = []; - function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { - var typeChecker = program.getTypeChecker(); - var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); - if (!startingToken) { - return undefined; - } - var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); - cancellationToken.throwIfCancellationRequested(); - if (!argumentInfo) { + var GoToDefinition; + (function (GoToDefinition) { + function getDefinitionAtPosition(program, sourceFile, position) { + var comment = findReferenceInPosition(sourceFile.referencedFiles, position); + if (comment) { + var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment); + if (referenceFile) { + return [getDefinitionInfoForFileReference(comment.fileName, referenceFile.fileName)]; + } return undefined; } - var call = argumentInfo.invocation; - var candidates = []; - var resolvedSignature = typeChecker.getResolvedSignature(call, candidates); - cancellationToken.throwIfCancellationRequested(); - if (!candidates.length) { - if (ts.isSourceFileJavaScript(sourceFile)) { - return createJavaScriptSignatureHelpItems(argumentInfo, program); + var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); + if (typeReferenceDirective) { + var referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; + if (referenceFile && referenceFile.resolvedFileName) { + return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } return undefined; } - return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo, typeChecker); - } - SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174) { + var node = ts.getTouchingPropertyName(sourceFile, position); + if (node === sourceFile) { return undefined; } - var callExpression = argumentInfo.invocation; - var expression = callExpression.expression; - var name = expression.kind === 69 - ? expression - : expression.kind === 172 - ? expression.name - : undefined; - if (!name || !name.text) { - return undefined; + if (ts.isJumpStatementTarget(node)) { + var labelName = node.text; + var label = ts.getTargetLabel(node.parent, node.text); + return label ? [createDefinitionInfo(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; } var typeChecker = program.getTypeChecker(); - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - var nameToDeclarations = sourceFile.getNamedDeclarations(); - var declarations = nameToDeclarations[name.text]; - if (declarations) { - for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { - var declaration = declarations_10[_b]; - var symbol = declaration.symbol; - if (symbol) { - var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); - if (type) { - var callSignatures = type.getCallSignatures(); - if (callSignatures && callSignatures.length) { - return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo, typeChecker); - } - } - } - } - } + var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); + if (calledDeclaration) { + return [createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration)]; } - } - function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 || node.parent.kind === 175) { - var callExpression = node.parent; - if (node.kind === 25 || - node.kind === 17) { - var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - ts.Debug.assert(list !== undefined); - return { - kind: isTypeArgList ? 0 : 1, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list, sourceFile), - argumentIndex: 0, - argumentCount: getArgumentCount(list) - }; + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; + } + if (symbol.flags & 8388608) { + var declaration = symbol.declarations[0]; + if (node.kind === 70 && + (node.parent === declaration || + (declaration.kind === 235 && declaration.parent && declaration.parent.kind === 234))) { + symbol = typeChecker.getAliasedSymbol(symbol); } - var listItemInfo = ts.findListItemInfo(node); - if (listItemInfo) { - var list = listItemInfo.list; - var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; - var argumentIndex = getArgumentIndex(list, node); - var argumentCount = getArgumentCount(list); - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - kind: isTypeArgList ? 0 : 1, - invocation: callExpression, - argumentsSpan: getApplicableSpanForArguments(list, sourceFile), - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; + } + if (node.parent.kind === 254) { + var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); + if (!shorthandSymbol) { + return []; } + var shorthandDeclarations = shorthandSymbol.getDeclarations(); + var shorthandSymbolKind_1 = ts.SymbolDisplay.getSymbolKind(typeChecker, shorthandSymbol, node); + var shorthandSymbolName_1 = typeChecker.symbolToString(shorthandSymbol); + var shorthandContainerName_1 = typeChecker.symbolToString(symbol.parent, node); + return ts.map(shorthandDeclarations, function (declaration) { return createDefinitionInfo(declaration, shorthandSymbolKind_1, shorthandSymbolName_1, shorthandContainerName_1); }); + } + return getDefinitionFromSymbol(typeChecker, symbol, node); + } + GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; + function getTypeDefinitionAtPosition(typeChecker, sourceFile, position) { + var node = ts.getTouchingPropertyName(sourceFile, position); + if (node === sourceFile) { return undefined; } - else if (node.kind === 11 && node.parent.kind === 176) { - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); - } + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) { + return undefined; } - else if (node.kind === 12 && node.parent.parent.kind === 176) { - var templateExpression = node.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; - return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node); + if (!type) { + return undefined; } - else if (node.parent.kind === 197 && node.parent.parent.parent.kind === 176) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); - if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { - return undefined; - } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); - return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); + if (type.flags & 524288 && !(type.flags & 16)) { + var result_5 = []; + ts.forEach(type.types, function (t) { + if (t.symbol) { + ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + } + }); + return result_5; } - return undefined; + if (!type.symbol) { + return undefined; + } + return getDefinitionFromSymbol(typeChecker, type.symbol, node); } - function getArgumentIndex(argumentsList, node) { - var argumentIndex = 0; - var listChildren = argumentsList.getChildren(); - for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { - var child = listChildren_1[_i]; - if (child === node) { - break; - } - if (child.kind !== 24) { - argumentIndex++; + GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; + function getDefinitionFromSymbol(typeChecker, symbol, node) { + var result = []; + var declarations = symbol.getDeclarations(); + var _a = getSymbolInfo(typeChecker, symbol, node), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && + !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { + ts.forEach(declarations, function (declaration) { + result.push(createDefinitionInfo(declaration, symbolKind, symbolName, containerName)); + }); + } + return result; + function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (ts.isNewExpressionTarget(location) || location.kind === 122) { + if (symbol.flags & 32) { + for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isClassLike(declaration)) { + return tryAddSignature(declaration.members, true, symbolKind, symbolName, containerName, result); + } + } + ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + } } + return false; } - return argumentIndex; - } - function getArgumentCount(argumentsList) { - var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24) { - argumentCount++; + function tryAddCallSignature(symbol, location, symbolKind, symbolName, containerName, result) { + if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location) || ts.isNameOfFunctionDeclaration(location)) { + return tryAddSignature(symbol.declarations, false, symbolKind, symbolName, containerName, result); + } + return false; } - return argumentCount; - } - function getArgumentIndexForTemplatePiece(spanIndex, node, position) { - ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { - return 0; + function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + var declarations = []; + var definition; + ts.forEach(signatureDeclarations, function (d) { + if ((selectConstructors && d.kind === 149) || + (!selectConstructors && (d.kind === 221 || d.kind === 148 || d.kind === 147))) { + declarations.push(d); + if (d.body) + definition = d; + } + }); + if (definition) { + result.push(createDefinitionInfo(definition, symbolKind, symbolName, containerName)); + return true; } - return spanIndex + 2; + else if (declarations.length) { + result.push(createDefinitionInfo(ts.lastOrUndefined(declarations), symbolKind, symbolName, containerName)); + return true; + } + return false; } - return spanIndex + 1; } - function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { - var argumentCount = tagExpression.template.kind === 11 - ? 1 - : tagExpression.template.templateSpans.length + 1; - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + function createDefinitionInfo(node, symbolKind, symbolName, containerName) { return { - kind: 2, - invocation: tagExpression, - argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), - argumentIndex: argumentIndex, - argumentCount: argumentCount + fileName: node.getSourceFile().fileName, + textSpan: ts.createTextSpanFromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName }; } - function getApplicableSpanForArguments(argumentsList, sourceFile) { - var applicableSpanStart = argumentsList.getFullStart(); - var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + function getSymbolInfo(typeChecker, symbol, node) { + return { + symbolName: typeChecker.symbolToString(symbol), + symbolKind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node), + containerName: symbol.parent ? typeChecker.symbolToString(symbol.parent, node) : "" + }; } - function getApplicableSpanForTaggedTemplate(taggedTemplate, sourceFile) { - var template = taggedTemplate.template; - var applicableSpanStart = template.getStart(); - var applicableSpanEnd = template.getEnd(); - if (template.kind === 189) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); - if (lastSpan.literal.getFullWidth() === 0) { - applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); - } - } - return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + function createDefinitionFromSignatureDeclaration(typeChecker, decl) { + var _a = getSymbolInfo(typeChecker, decl.symbol, decl), symbolName = _a.symbolName, symbolKind = _a.symbolKind, containerName = _a.containerName; + return createDefinitionInfo(decl, symbolKind, symbolName, containerName); } - function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 256; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } - var argumentInfo = getImmediatelyContainingArgumentInfo(n, position, sourceFile); - if (argumentInfo) { - return argumentInfo; + function findReferenceInPosition(refs, pos) { + for (var _i = 0, refs_1 = refs; _i < refs_1.length; _i++) { + var ref = refs_1[_i]; + if (ref.pos <= pos && pos < ref.end) { + return ref; } } return undefined; } - SignatureHelp.getContainingArgumentInfo = getContainingArgumentInfo; - function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { - var children = parent.getChildren(sourceFile); - var indexOfOpenerToken = children.indexOf(openerToken); - ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); - return children[indexOfOpenerToken + 1]; + function getDefinitionInfoForFileReference(name, targetFileName) { + return { + fileName: targetFileName, + textSpan: ts.createTextSpanFromBounds(0, 0), + kind: ts.ScriptElementKind.scriptElement, + name: name, + containerName: undefined, + containerKind: undefined + }; } - function selectBestInvalidOverloadIndex(candidates, argumentCount) { - var maxParamsSignatureIndex = -1; - var maxParams = -1; - for (var i = 0; i < candidates.length; i++) { - var candidate = candidates[i]; - if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { - return i; - } - if (candidate.parameters.length > maxParams) { - maxParams = candidate.parameters.length; - maxParamsSignatureIndex = i; - } + function getAncestorCallLikeExpression(node) { + var target = climbPastManyPropertyAccesses(node); + var callLike = target.parent; + return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target && callLike; + } + function climbPastManyPropertyAccesses(node) { + return ts.isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node; + } + function tryGetSignatureDeclaration(typeChecker, node) { + var callLike = getAncestorCallLikeExpression(node); + return callLike && typeChecker.getResolvedSignature(callLike).declaration; + } + })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var GoToImplementation; + (function (GoToImplementation) { + function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { + if (node.parent.kind === 254) { + var result = []; + ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); + return result.length > 0 ? result : undefined; + } + else if (node.kind === 96 || ts.isSuperProperty(node.parent)) { + var symbol = typeChecker.getSymbolAtLocation(node); + return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; + } + else { + var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, true); + var result = ts.flatMap(referencedSymbols, function (symbol) { + return ts.map(symbol.references, function (_a) { + var textSpan = _a.textSpan, fileName = _a.fileName; + return ({ textSpan: textSpan, fileName: fileName }); + }); + }); + return result && result.length > 0 ? result : undefined; } - return maxParamsSignatureIndex; } - function createSignatureHelpItems(candidates, bestSignature, argumentListInfo, typeChecker) { - var applicableSpan = argumentListInfo.argumentsSpan; - var isTypeParameterList = argumentListInfo.kind === 0; - var invocation = argumentListInfo.invocation; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); - var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); - var items = ts.map(candidates, function (candidateSignature) { - var signatureHelpParameters; - var prefixDisplayParts = []; - var suffixDisplayParts = []; - if (callTargetDisplayParts) { - ts.addRange(prefixDisplayParts, callTargetDisplayParts); - } - if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25)); - var typeParameters = candidateSignature.typeParameters; - signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27)); - var parameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); - }); - ts.addRange(suffixDisplayParts, parameterParts); + GoToImplementation.getImplementationAtPosition = getImplementationAtPosition; + })(GoToImplementation = ts.GoToImplementation || (ts.GoToImplementation = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var JsDoc; + (function (JsDoc) { + var jsDocTagNames = [ + "augments", + "author", + "argument", + "borrows", + "class", + "constant", + "constructor", + "constructs", + "default", + "deprecated", + "description", + "event", + "example", + "extends", + "field", + "fileOverview", + "function", + "ignore", + "inner", + "lends", + "link", + "memberOf", + "name", + "namespace", + "param", + "private", + "property", + "public", + "requires", + "returns", + "see", + "since", + "static", + "throws", + "type", + "typedef", + "property", + "prop", + "version" + ]; + var jsDocCompletionEntries; + function getJsDocCommentsFromDeclarations(declarations) { + var documentationComment = []; + forEachUnique(declarations, function (declaration) { + var comments = ts.getJSDocComments(declaration, true); + if (!comments) { + return; } - else { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); - }); - ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17)); - var parameters = candidateSignature.parameters; - signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18)); + for (var _i = 0, comments_3 = comments; _i < comments_3.length; _i++) { + var comment = comments_3[_i]; + if (comment) { + if (documentationComment.length) { + documentationComment.push(ts.lineBreakPart()); + } + documentationComment.push(ts.textPart(comment)); + } } - var returnTypeParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); - }); - ts.addRange(suffixDisplayParts, returnTypeParts); - return { - isVariadic: candidateSignature.hasRestParameter, - prefixDisplayParts: prefixDisplayParts, - suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], - parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() - }; }); - var argumentIndex = argumentListInfo.argumentIndex; - var argumentCount = argumentListInfo.argumentCount; - var selectedItemIndex = candidates.indexOf(bestSignature); - if (selectedItemIndex < 0) { - selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); + return documentationComment; + } + JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function forEachUnique(array, callback) { + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + if (ts.indexOf(array, array[i]) === i) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } } - ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); - return { - items: items, - applicableSpan: applicableSpan, - selectedItemIndex: selectedItemIndex, - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - function createSignatureHelpParameterForParameter(parameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); - }); + return undefined; + } + function getAllJsDocCompletionEntries() { + return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: parameter.name, - documentation: parameter.getDocumentationComment(), - displayParts: displayParts, - isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) + name: tagName, + kind: ts.ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0", }; + })); + } + JsDoc.getAllJsDocCompletionEntries = getAllJsDocCompletionEntries; + function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { + return undefined; } - function createSignatureHelpParameterForTypeParameter(typeParameter) { - var displayParts = ts.mapToDisplayParts(function (writer) { - return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); - }); - return { - name: typeParameter.symbol.name, - documentation: emptyArray, - displayParts: displayParts, - isOptional: false - }; + var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); + var tokenStart = tokenAtPos.getStart(); + if (!tokenAtPos || tokenStart < position) { + return undefined; + } + var commentOwner; + findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 221: + case 148: + case 149: + case 222: + case 201: + break findOwner; + case 256: + return undefined; + case 226: + if (commentOwner.parent.kind === 226) { + return undefined; + } + break findOwner; + } + } + if (!commentOwner || commentOwner.getStart() < position) { + return undefined; + } + var parameters = getParametersForJsDocOwningNode(commentOwner); + var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); + var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + var docParams = ""; + for (var i = 0, numParams = parameters.length; i < numParams; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 70 ? + currentName.text : + "param" + i; + docParams += indentationStr + " * @param " + paramName + newLine; } + var preamble = "/**" + newLine + + indentationStr + " * "; + var result = preamble + newLine + + docParams + + indentationStr + " */" + + (tokenStart === position ? newLine + indentationStr : ""); + return { newText: result, caretOffset: preamble.length }; } - })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); + JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function getParametersForJsDocOwningNode(commentOwner) { + if (ts.isFunctionLike(commentOwner)) { + return commentOwner.parameters; + } + if (commentOwner.kind === 201) { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + if (varDeclarations.length === 1 && varDeclarations[0].initializer) { + return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + } + } + return ts.emptyArray; + } + function getParametersFromRightHandSideOfAssignment(rightHandSide) { + while (rightHandSide.kind === 179) { + rightHandSide = rightHandSide.expression; + } + switch (rightHandSide.kind) { + case 180: + case 181: + return rightHandSide.parameters; + case 193: + for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (member.kind === 149) { + return member.parameters; + } + } + break; + } + return ts.emptyArray; + } + })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; (function (ts) { - var SymbolDisplay; - (function (SymbolDisplay) { - function getSymbolKind(typeChecker, symbol, location) { - var flags = symbol.getFlags(); - if (flags & 32) - return ts.getDeclarationOfKind(symbol, 192) ? - ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; - if (flags & 384) - return ts.ScriptElementKind.enumElement; - if (flags & 524288) - return ts.ScriptElementKind.typeElement; - if (flags & 64) - return ts.ScriptElementKind.interfaceElement; - if (flags & 262144) - return ts.ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); - if (result === ts.ScriptElementKind.unknown) { - if (flags & 262144) - return ts.ScriptElementKind.typeParameterElement; - if (flags & 8) - return ts.ScriptElementKind.variableElement; - if (flags & 8388608) - return ts.ScriptElementKind.alias; - if (flags & 1536) - return ts.ScriptElementKind.moduleElement; + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; } - return result; - } - SymbolDisplay.getSymbolKind = getSymbolKind; - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location) { - if (typeChecker.isUndefinedSymbol(symbol)) { - return ts.ScriptElementKind.variableElement; + 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; } - if (typeChecker.isArgumentsSymbol(symbol)) { - return ts.ScriptElementKind.localVariableElement; + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath !== undefined) { + possibleSearchDirs.push(projectRootPath); } - if (location.kind === 97 && ts.isExpression(location)) { - return ts.ScriptElementKind.parameterElement; + 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); } - if (flags & 3) { - if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return ts.ScriptElementKind.parameterElement; + getTypingNamesFromSourceFileNames(fileNames); + for (var name_48 in packageNameToTypingLocation) { + if (name_48 in inferredTypings && !inferredTypings[name_48]) { + inferredTypings[name_48] = packageNameToTypingLocation[name_48]; } - else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return ts.ScriptElementKind.constElement; + } + for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { + var excludeTypingName = exclude_1[_a]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); } - else if (ts.forEach(symbol.declarations, ts.isLet)) { - return ts.ScriptElementKind.letElement; + else { + newTypingNames.push(typing); } - return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; } - if (flags & 16) - return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; - if (flags & 32768) - return ts.ScriptElementKind.memberGetAccessorElement; - if (flags & 65536) - return ts.ScriptElementKind.memberSetAccessorElement; - if (flags & 8192) - return ts.ScriptElementKind.memberFunctionElement; - if (flags & 16384) - return ts.ScriptElementKind.constructorImplementationElement; - if (flags & 4) { - if (flags & 268435456) { - var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { - var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 | 3)) { - return ts.ScriptElementKind.memberVariableElement; - } - ts.Debug.assert(!!(rootSymbolFlags & 8192)); - }); - if (!unionPropertyKind) { - var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (typeOfUnionProperty.getCallSignatures().length) { - return ts.ScriptElementKind.memberFunctionElement; - } - return ts.ScriptElementKind.memberVariableElement; + 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; } - return unionPropertyKind; } - return ts.ScriptElementKind.memberVariableElement; } - return ts.ScriptElementKind.unknown; - } - function getSymbolModifiers(symbol) { - return symbol && symbol.declarations && symbol.declarations.length > 0 - ? ts.getNodeModifiers(symbol.declarations[0]) - : ts.ScriptElementKindModifier.none; - } - SymbolDisplay.getSymbolModifiers = getSymbolModifiers; - function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { - if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } - var displayParts = []; - var documentation; - var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); - var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 && ts.isExpression(location); - var type; - if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { - if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { - symbolKind = ts.ScriptElementKind.memberVariableElement; - } - var signature = void 0; - type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (type) { - if (location.parent && location.parent.kind === 172) { - var right = location.parent.name; - if (right === location || (right && right.getFullWidth() === 0)) { - location = location.parent; - } - } - var callExpression = void 0; - if (location.kind === 174 || location.kind === 175) { - callExpression = location; + function getTypingNamesFromJson(jsonPath, filesToWatch) { + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + filesToWatch.push(jsonPath); + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); } - else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { - callExpression = location.parent; + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); } - if (callExpression) { - var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); - if (!signature && candidateSignatures.length) { - signature = candidateSignatures[0]; - } - var useConstructSignatures = callExpression.kind === 175 || callExpression.expression.kind === 95; - var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { - signature = allSignatures.length ? allSignatures[0] : undefined; - } - if (signature) { - if (useConstructSignatures && (symbolFlags & 32)) { - symbolKind = ts.ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else if (symbolFlags & 8388608) { - symbolKind = ts.ScriptElementKind.alias; - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); - displayParts.push(ts.spacePart()); - } - addFullSymbolName(symbol); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); - } - switch (symbolKind) { - case ts.ScriptElementKind.memberVariableElement: - case ts.ScriptElementKind.variableElement: - case ts.ScriptElementKind.constElement: - case ts.ScriptElementKind.letElement: - case ts.ScriptElementKind.parameterElement: - case ts.ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(54)); - displayParts.push(ts.spacePart()); - if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); - displayParts.push(ts.spacePart()); - } - if (!(type.flags & 2097152) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); - } - addSignatureDisplayParts(signature, allSignatures, 8); - break; - default: - addSignatureDisplayParts(signature, allSignatures); - } - hasAddedSymbolInfo = true; - } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 121 && location.parent.kind === 148)) { - var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); - } - else { - signature = allSignatures[0]; - } - if (functionDeclaration.kind === 148) { - symbolKind = ts.ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 && - !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); - } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); } } } - if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192)) { - pushTypePart(ts.ScriptElementKind.localClassElement); - } - else { - displayParts.push(ts.keywordPart(73)); + 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; })); } - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if ((symbolFlags & 64) && (semanticMeaning & 2)) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - } - if (symbolFlags & 524288) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - writeTypeParametersOfSymbol(symbol, sourceFile); - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512)); - } - if (symbolFlags & 384) { - addNewLineIfDisplayPartsExist(); - if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74)); - displayParts.push(ts.spacePart()); + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); } - displayParts.push(ts.keywordPart(81)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); } - if (symbolFlags & 1536) { - addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69; - displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - } - if ((symbolFlags & 262144) && (semanticMeaning & 2)) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90)); - displayParts.push(ts.spacePart()); - if (symbol.parent) { - addFullSymbolName(symbol.parent, enclosingDeclaration); - writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; } - else { - var declaration = ts.getDeclarationOfKind(symbol, 141); - ts.Debug.assert(declaration !== undefined); - declaration = declaration.parent; - if (declaration) { - if (ts.isFunctionLikeKind(declaration.kind)) { - var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152) { - displayParts.push(ts.keywordPart(92)); - displayParts.push(ts.spacePart()); - } - else if (declaration.kind !== 151 && declaration.name) { - addFullSymbolName(declaration.symbol); - } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); - } - else { - displayParts.push(ts.keywordPart(134)); - displayParts.push(ts.spacePart()); - addFullSymbolName(declaration.symbol); - writeTypeParametersOfSymbol(declaration.symbol, sourceFile); - } + 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; } - } - } - if (symbolFlags & 8) { - addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 255) { - var constantValue = typeChecker.getConstantValue(declaration); - if (constantValue !== undefined) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); + 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); } - if (symbolFlags & 8388608) { - addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228) { - displayParts.push(ts.keywordPart(82)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126)); - } - else { - displayParts.push(ts.keywordPart(89)); + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var NavigateTo; + (function (NavigateTo) { + function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { + var patternMatcher = ts.createPatternMatcher(searchValue); + var rawItems = []; + ts.forEach(sourceFiles, function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { + return; } - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229) { - var importEqualsDeclaration = declaration; - if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129)); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18)); - } - else { - var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); - if (internalAliasSymbol) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); - displayParts.push(ts.spacePart()); - addFullSymbolName(internalAliasSymbol, enclosingDeclaration); - } - } - return true; - } - }); - } - if (!hasAddedSymbolInfo) { - if (symbolKind !== ts.ScriptElementKind.unknown) { - if (type) { - if (isThisExpression) { - addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97)); - } - else { - addPrefixForAnyFunctionOrVar(symbol, symbolKind); + var nameToDeclarations = sourceFile.getNamedDeclarations(); + for (var name_49 in nameToDeclarations) { + var declarations = nameToDeclarations[name_49]; + if (declarations) { + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_49); + if (!matches) { + continue; } - if (symbolKind === ts.ScriptElementKind.memberVariableElement || - symbolFlags & 3 || - symbolKind === ts.ScriptElementKind.localVariableElement || - isThisExpression) { - displayParts.push(ts.punctuationPart(54)); - displayParts.push(ts.spacePart()); - if (type.symbol && type.symbol.flags & 262144) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - else { - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; + if (patternMatcher.patternContainsDots) { + var containers = getContainers(declaration); + if (!containers) { + return undefined; + } + matches = patternMatcher.getMatches(containers, name_49); + if (!matches) { + continue; + } } - } - else if (symbolFlags & 16 || - symbolFlags & 8192 || - symbolFlags & 16384 || - symbolFlags & 131072 || - symbolFlags & 98304 || - symbolKind === ts.ScriptElementKind.memberFunctionElement) { - var allSignatures = type.getNonNullableType().getCallSignatures(); - addSignatureDisplayParts(allSignatures[0], allSignatures); + var fileName = sourceFile.fileName; + var matchKind = bestMatchKind(matches); + rawItems.push({ name: name_49, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } + }); + rawItems = ts.filter(rawItems, function (item) { + var decl = item.declaration; + if (decl.kind === 232 || decl.kind === 235 || decl.kind === 230) { + var importer = checker.getSymbolAtLocation(decl.name); + var imported = checker.getAliasedSymbol(importer); + return importer.name !== imported.name; + } else { - symbolKind = getSymbolKind(typeChecker, symbol, location); + return true; } + }); + rawItems.sort(compareNavigateToItems); + if (maxResultCount !== undefined) { + rawItems = rawItems.slice(0, maxResultCount); } - 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 === 256; })) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187) { - continue; - } - var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); - if (!rhsSymbol) { - continue; - } - documentation = rhsSymbol.getDocumentationComment(); - if (documentation.length > 0) { - break; - } - } + var items = ts.map(rawItems, createNavigateToItem); + return items; + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; + if (!match.isCaseSensitive) { + return false; } } + return true; } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; - function addNewLineIfDisplayPartsExist() { - if (displayParts.length) { - displayParts.push(ts.lineBreakPart()); + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 70 || + node.kind === 9 || + node.kind === 8) { + return node.text; + } } + return undefined; } - function addFullSymbolName(symbol, enclosingDeclaration) { - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2); - ts.addRange(displayParts, fullSymbolDisplayParts); - } - function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { - addNewLineIfDisplayPartsExist(); - if (symbolKind) { - pushTypePart(symbolKind); - displayParts.push(ts.spacePart()); - addFullSymbolName(symbol); + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration && declaration.name) { + var text = getTextOfIdentifierOrLiteral(declaration.name); + if (text !== undefined) { + containers.unshift(text); + } + else if (declaration.name.kind === 141) { + return tryAddComputedPropertyName(declaration.name.expression, containers, true); + } + else { + return false; + } } + return true; } - function pushTypePart(symbolKind) { - switch (symbolKind) { - case ts.ScriptElementKind.variableElement: - case ts.ScriptElementKind.functionElement: - case ts.ScriptElementKind.letElement: - case ts.ScriptElementKind.constElement: - case ts.ScriptElementKind.constructorImplementationElement: - displayParts.push(ts.textOrKeywordPart(symbolKind)); - return; - default: - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18)); - return; + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } + return true; } - } - function addSignatureDisplayParts(signature, allSignatures, flags) { - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); - if (allSignatures.length > 1) { - displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.operatorPart(35)); - displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18)); + if (expression.kind === 173) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); + } + return tryAddComputedPropertyName(propertyAccess.expression, containers, true); } - documentation = signature.getDocumentationComment(); - } - function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { - var typeParameterParts = ts.mapToDisplayParts(function (writer) { - typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); - }); - ts.addRange(displayParts, typeParameterParts); - } - } - SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind; - function isLocalVariableOrFunction(symbol) { - if (symbol.parent) { return false; } - return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 179) { - return true; + function getContainers(declaration) { + var containers = []; + if (declaration.name.kind === 141) { + if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { + return undefined; + } } - if (declaration.kind !== 218 && declaration.kind !== 220) { - return false; + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; + } + declaration = ts.getContainerNode(declaration); } - for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { - if (parent_23.kind === 256 || parent_23.kind === 226) { - return false; + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { + var match = matches_3[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; } } - return true; - }); + return bestMatchKind; + } + function compareNavigateToItems(i1, i2) { + return i1.matchKind - i2.matchKind || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()), + containerName: container && container.name ? container.name.text : "", + containerKind: container && container.name ? ts.getNodeKind(container) : "" + }; + } } - })(SymbolDisplay = ts.SymbolDisplay || (ts.SymbolDisplay = {})); + NavigateTo.getNavigateToItems = getNavigateToItems; + })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); var ts; (function (ts) { - function transpileModule(input, transpileOptions) { - var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; - options.suppressOutputPathCheck = true; - options.allowNonTsExtensions = true; - options.noLib = true; - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - options.noResolve = true; - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); - if (transpileOptions.moduleName) { - sourceFile.moduleName = transpileOptions.moduleName; + var NavigationBar; + (function (NavigationBar) { + function getNavigationBarItems(sourceFile) { + curSourceFile = sourceFile; + var result = ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + curSourceFile = undefined; + return result; } - if (transpileOptions.renamedDependencies) { - sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + NavigationBar.getNavigationBarItems = getNavigationBarItems; + function getNavigationTree(sourceFile) { + curSourceFile = sourceFile; + var result = convertToTree(rootNavigationBarNode(sourceFile)); + curSourceFile = undefined; + return result; } - var newLine = ts.getNewLineCharacter(options); - var outputText; - var sourceMapText; - var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { - if (ts.fileExtensionIs(name, ".map")) { - ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); - sourceMapText = text; - } - else { - ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: '" + name + "'"); - outputText = text; - } - }, - getDefaultLibFileName: function () { return "lib.d.ts"; }, - useCaseSensitiveFileNames: function () { return false; }, - getCanonicalFileName: function (fileName) { return fileName; }, - getCurrentDirectory: function () { return ""; }, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } - }; - var program = ts.createProgram([inputFileName], options, compilerHost); - if (transpileOptions.reportDiagnostics) { - ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); - ts.addRange(diagnostics, program.getOptionsDiagnostics()); + NavigationBar.getNavigationTree = getNavigationTree; + var curSourceFile; + function nodeText(node) { + return node.getText(curSourceFile); } - program.emit(); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); - return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; - } - ts.transpileModule = transpileModule; - function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { - var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); - ts.addRange(diagnostics, output.diagnostics); - return output.outputText; - } - ts.transpile = transpile; - var commandLineOptionsStringToEnum; - function fixupCompilerOptions(options, diagnostics) { - commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); - }); - options = ts.clone(options); - var _loop_2 = function (opt) { - if (!ts.hasProperty(options, opt.name)) { - return "continue"; - } - var value = options[opt.name]; - if (typeof value === "string") { - options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); + function navigationBarNodeKind(n) { + return n.node.kind; + } + function pushChild(parent, child) { + if (parent.children) { + parent.children.push(child); } else { - if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { - diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); - } + parent.children = [child]; } - }; - for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { - var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_2(opt); } - return options; - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var standardScanner = ts.createScanner(2, false, 0); - var jsxScanner = ts.createScanner(2, false, 1); - var scanner; - function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); - scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); - scanner.setTextPos(startPos); - var wasNewLine = true; - var leadingTrivia; - var trailingTrivia; - var savedPos; - var lastScanAction; - var lastTokenInfo; + var parentsStack = []; + var parent; + function rootNavigationBarNode(sourceFile) { + ts.Debug.assert(!parentsStack.length); + var root = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; + parent = root; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + addChildrenRecursively(statement); + } + endNode(); + ts.Debug.assert(!parent && !parentsStack.length); + return root; + } + function addLeafNode(node) { + pushChild(parent, emptyNavigationBarNode(node)); + } + function emptyNavigationBarNode(node) { return { - advance: advance, - readTokenInfo: readTokenInfo, - isOnToken: isOnToken, - getCurrentLeadingTrivia: function () { return leadingTrivia; }, - lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, - skipToEndOf: skipToEndOf, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } + node: node, + additionalNodes: undefined, + parent: parent, + children: undefined, + indent: parent.indent + 1 }; - function advance() { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - var isStarted = scanner.getStartPos() !== startPos; - if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4; - } - else { - wasNewLine = false; + } + function startNode(node) { + var navNode = emptyNavigationBarNode(node); + pushChild(parent, navNode); + parentsStack.push(parent); + parent = navNode; + } + function endNode() { + if (parent.children) { + mergeChildren(parent.children); + sortChildren(parent.children); + } + parent = parentsStack.pop(); + } + function addNodeWithRecursiveChild(node, child) { + startNode(node); + addChildrenRecursively(child); + endNode(); + } + function addChildrenRecursively(node) { + if (!node || ts.isToken(node)) { + return; + } + switch (node.kind) { + case 149: + var ctr = node; + addNodeWithRecursiveChild(ctr, ctr.body); + for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { + var param = _a[_i]; + if (ts.isParameterPropertyDeclaration(param)) { + addLeafNode(param); + } } + break; + case 148: + case 150: + case 151: + case 147: + if (!ts.hasDynamicName(node)) { + addNodeWithRecursiveChild(node, node.body); + } + break; + case 146: + case 145: + if (!ts.hasDynamicName(node)) { + addLeafNode(node); + } + break; + case 232: + var importClause = node; + if (importClause.name) { + addLeafNode(importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + if (namedBindings.kind === 233) { + addLeafNode(namedBindings); + } + else { + for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { + var element = _c[_b]; + addLeafNode(element); + } + } + } + break; + case 170: + case 219: + var decl = node; + var name_50 = decl.name; + if (ts.isBindingPattern(name_50)) { + addChildrenRecursively(name_50); + } + else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { + addChildrenRecursively(decl.initializer); + } + else { + addNodeWithRecursiveChild(decl, decl.initializer); + } + break; + case 181: + case 221: + case 180: + addNodeWithRecursiveChild(node, node.body); + break; + case 225: + startNode(node); + for (var _d = 0, _e = node.members; _d < _e.length; _d++) { + var member = _e[_d]; + if (!isComputedProperty(member)) { + addLeafNode(member); + } + } + endNode(); + break; + case 222: + case 193: + case 223: + startNode(node); + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; + addChildrenRecursively(member); + } + endNode(); + break; + case 226: + addNodeWithRecursiveChild(node, getInteriorModule(node).body); + break; + case 239: + case 230: + case 154: + case 152: + case 153: + case 224: + addLeafNode(node); + break; + default: + ts.forEach(node.jsDocComments, function (jsDocComment) { + ts.forEach(jsDocComment.tags, function (tag) { + if (tag.kind === 279) { + addLeafNode(tag); + } + }); + }); + ts.forEachChild(node, addChildrenRecursively); + } + } + function mergeChildren(children) { + var nameToItems = ts.createMap(); + ts.filterMutate(children, function (child) { + var decl = child.node; + var name = decl.name && nodeText(decl.name); + if (!name) { + return true; } - leadingTrivia = undefined; - trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } - var pos = scanner.getStartPos(); - while (pos < endPos) { - var t = scanner.getToken(); - if (!ts.isTrivia(t)) { - break; + var itemsWithSameName = nameToItems[name]; + if (!itemsWithSameName) { + nameToItems[name] = child; + return true; + } + if (itemsWithSameName instanceof Array) { + for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { + var itemWithSameName = itemsWithSameName_1[_i]; + if (tryMerge(itemWithSameName, child)) { + return false; + } } - scanner.scan(); - var item = { - pos: pos, - end: scanner.getStartPos(), - kind: t - }; - pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; + itemsWithSameName.push(child); + return true; + } + else { + var itemWithSameName = itemsWithSameName; + if (tryMerge(itemWithSameName, child)) { + return false; } - leadingTrivia.push(item); + nameToItems[name] = [itemWithSameName, child]; + return true; } - savedPos = scanner.getStartPos(); - } - function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 29: - case 64: - case 65: - case 45: - case 44: - return true; + function tryMerge(a, b) { + if (shouldReallyMerge(a.node, b.node)) { + merge(a, b); + return true; } + return false; } - return false; - } - function shouldRescanJsxIdentifier(node) { - if (node.parent) { - switch (node.parent.kind) { - case 246: - case 243: - case 245: - case 242: - return node.kind === 69; + }); + function shouldReallyMerge(a, b) { + return a.kind === b.kind && (a.kind !== 226 || areSameModule(a, b)); + function areSameModule(a, b) { + if (a.body.kind !== b.body.kind) { + return false; } + if (a.body.kind !== 226) { + return true; + } + return areSameModule(a.body, b.body); } - return false; } - function shouldRescanJsxText(node) { - return node && node.kind === 244; - } - function shouldRescanSlashToken(container) { - return container.kind === 10; + function merge(target, source) { + target.additionalNodes = target.additionalNodes || []; + target.additionalNodes.push(source.node); + if (source.additionalNodes) { + (_a = target.additionalNodes).push.apply(_a, source.additionalNodes); + } + target.children = ts.concatenate(target.children, source.children); + if (target.children) { + mergeChildren(target.children); + sortChildren(target.children); + } + var _a; } - function shouldRescanTemplateToken(container) { - return container.kind === 13 || - container.kind === 14; + } + function sortChildren(children) { + children.sort(compareChildren); + } + function compareChildren(child1, child2) { + var name1 = tryGetName(child1.node), name2 = tryGetName(child2.node); + if (name1 && name2) { + var cmp = localeCompareFix(name1, name2); + return cmp !== 0 ? cmp : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } - function startsWithSlashToken(t) { - return t === 39 || t === 61; + else { + return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } - function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 - : shouldRescanSlashToken(n) - ? 2 - : shouldRescanTemplateToken(n) - ? 3 - : shouldRescanJsxIdentifier(n) - ? 4 - : shouldRescanJsxText(n) - ? 5 - : 0; - if (lastTokenInfo && expectedScanAction === lastScanAction) { - return fixTokenKind(lastTokenInfo, n); - } - if (scanner.getStartPos() !== savedPos) { - ts.Debug.assert(lastTokenInfo !== undefined); - scanner.setTextPos(savedPos); - scanner.scan(); - } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 27) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1; + } + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { + for (var i = 0; i < Math.min(a.length, b.length); i++) { + var chA = a.charAt(i), chB = b.charAt(i); + if (chA === "\"" && chB === "'") { + return 1; } - else if (expectedScanAction === 2 && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2; + if (chA === "'" && chB === "\"") { + return -1; } - else if (expectedScanAction === 3 && currentToken === 16) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3; + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); + if (cmp !== 0) { + return cmp; } - else if (expectedScanAction === 4 && currentToken === 69) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4; + } + return a.length - b.length; + }; + function tryGetName(node) { + if (node.kind === 226) { + return getModuleName(node); + } + var decl = node; + if (decl.name) { + return ts.getPropertyNameForPropertyNameNode(decl.name); + } + switch (node.kind) { + case 180: + case 181: + case 193: + return getFunctionOrClassName(node); + case 279: + return getJSDocTypedefTagName(node); + default: + return undefined; + } + } + function getItemName(node) { + if (node.kind === 226) { + return getModuleName(node); + } + var name = node.name; + if (name) { + var text = nodeText(name); + if (text.length > 0) { + return text; } - else if (expectedScanAction === 5) { - currentToken = scanner.reScanJsxToken(); - lastScanAction = 5; + } + switch (node.kind) { + case 256: + var sourceFile = node; + return ts.isExternalModule(sourceFile) + ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + : ""; + case 181: + case 221: + case 180: + case 222: + case 193: + if (ts.getModifierFlags(node) & 512) { + return "default"; + } + return getFunctionOrClassName(node); + case 149: + return "constructor"; + case 153: + return "new()"; + case 152: + return "()"; + case 154: + return "[]"; + case 279: + return getJSDocTypedefTagName(node); + default: + return ""; + } + } + function getJSDocTypedefTagName(node) { + if (node.name) { + return node.name.text; + } + else { + var parentNode = node.parent && node.parent.parent; + if (parentNode && parentNode.kind === 201) { + if (parentNode.declarationList.declarations.length > 0) { + var nameIdentifier = parentNode.declarationList.declarations[0].name; + if (nameIdentifier.kind === 70) { + return nameIdentifier.text; + } + } } - else { - lastScanAction = 0; + return ""; + } + } + function topLevelItems(root) { + var topLevel = []; + function recur(item) { + if (isTopLevel(item)) { + topLevel.push(item); + if (item.children) { + for (var _i = 0, _a = item.children; _i < _a.length; _i++) { + var child = _a[_i]; + recur(child); + } + } } - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - if (trailingTrivia) { - trailingTrivia = undefined; + } + recur(root); + return topLevel; + function isTopLevel(item) { + switch (navigationBarNodeKind(item)) { + case 222: + case 193: + case 225: + case 223: + case 226: + case 256: + case 224: + case 279: + return true; + case 149: + case 148: + case 150: + case 151: + case 219: + return hasSomeImportantChild(item); + case 181: + case 221: + case 180: + return isTopLevelFunctionDeclaration(item); + default: + return false; } - while (scanner.getStartPos() < endPos) { - currentToken = scanner.scan(); - if (!ts.isTrivia(currentToken)) { - break; - } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; - if (!trailingTrivia) { - trailingTrivia = []; + function isTopLevelFunctionDeclaration(item) { + if (!item.node.body) { + return false; } - trailingTrivia.push(trivia); - if (currentToken === 4) { - scanner.scan(); - break; + switch (navigationBarNodeKind(item.parent)) { + case 227: + case 256: + case 148: + case 149: + return true; + default: + return hasSomeImportantChild(item); } } - lastTokenInfo = { - leadingTrivia: leadingTrivia, - trailingTrivia: trailingTrivia, - token: token - }; - return fixTokenKind(lastTokenInfo, n); + function hasSomeImportantChild(item) { + return ts.forEach(item.children, function (child) { + var childKind = navigationBarNodeKind(child); + return childKind !== 219 && childKind !== 170; + }); + } } - function isOnToken() { - ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); - return startPos < endPos && current !== 1 && !ts.isTrivia(current); + } + var emptyChildItemArray = []; + function convertToTree(n) { + return { + text: getItemName(n.node), + kind: ts.getNodeKind(n.node), + kindModifiers: ts.getNodeModifiers(n.node), + spans: getSpans(n), + childItems: ts.map(n.children, convertToTree) + }; + } + function convertToTopLevelItem(n) { + return { + text: getItemName(n.node), + kind: ts.getNodeKind(n.node), + kindModifiers: ts.getNodeModifiers(n.node), + spans: getSpans(n), + childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + indent: n.indent, + bolded: false, + grayed: false + }; + function convertToChildItem(n) { + return { + text: getItemName(n.node), + kind: ts.getNodeKind(n.node), + kindModifiers: ts.getNodeModifiers(n.node), + spans: getSpans(n), + childItems: emptyChildItemArray, + indent: 0, + bolded: false, + grayed: false + }; } - function fixTokenKind(tokenInfo, container) { - if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { - tokenInfo.token.kind = container.kind; + } + function getSpans(n) { + var spans = [getNodeSpan(n.node)]; + if (n.additionalNodes) { + for (var _i = 0, _a = n.additionalNodes; _i < _a.length; _i++) { + var node = _a[_i]; + spans.push(getNodeSpan(node)); } - return tokenInfo; } - function skipToEndOf(node) { - scanner.setTextPos(node.end); - savedPos = scanner.getStartPos(); - lastScanAction = undefined; - lastTokenInfo = undefined; - wasNewLine = false; - leadingTrivia = undefined; - trailingTrivia = undefined; + return spans; + } + function getModuleName(moduleDeclaration) { + if (ts.isAmbientModule(moduleDeclaration)) { + return ts.getTextOfNode(moduleDeclaration.name); + } + var result = []; + result.push(moduleDeclaration.name.text); + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { + moduleDeclaration = moduleDeclaration.body; + result.push(moduleDeclaration.name.text); } + return result.join("."); } - formatting.getFormattingScanner = getFormattingScanner; - })(formatting = ts.formatting || (ts.formatting = {})); + function getInteriorModule(decl) { + return decl.body.kind === 226 ? getInteriorModule(decl.body) : decl; + } + function isComputedProperty(member) { + return !member.name || member.name.kind === 141; + } + function getNodeSpan(node) { + return node.kind === 256 + ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) + : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); + } + function getFunctionOrClassName(node) { + if (node.name && ts.getFullWidth(node.name) > 0) { + return ts.declarationNameToString(node.name); + } + else if (node.parent.kind === 219) { + return ts.declarationNameToString(node.parent.name); + } + else if (node.parent.kind === 188 && + node.parent.operatorToken.kind === 57) { + return nodeText(node.parent.left); + } + else if (node.parent.kind === 253 && node.parent.name) { + return nodeText(node.parent.name); + } + else if (ts.getModifierFlags(node) & 512) { + return "default"; + } + else { + return ts.isClassLike(node) ? "" : ""; + } + } + function isFunctionOrClassExpression(node) { + return node.kind === 180 || node.kind === 181 || node.kind === 193; + } + })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); var ts; (function (ts) { - var formatting; - (function (formatting) { - var FormattingContext = (function () { - function FormattingContext(sourceFile, formattingRequestKind) { - this.sourceFile = sourceFile; - this.formattingRequestKind = formattingRequestKind; - } - FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { - ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); - ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); - ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); - ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); - ts.Debug.assert(commonParent !== undefined, "commonParent is null"); - this.currentTokenSpan = currentRange; - this.currentTokenParent = currentTokenParent; - this.nextTokenSpan = nextRange; - this.nextTokenParent = nextTokenParent; - this.contextNode = commonParent; - this.contextNodeAllOnSameLine = undefined; - this.nextNodeAllOnSameLine = undefined; - this.tokensAreOnSameLine = undefined; - this.contextNodeBlockIsOnOneLine = undefined; - this.nextNodeBlockIsOnOneLine = undefined; - }; - FormattingContext.prototype.ContextNodeAllOnSameLine = function () { - if (this.contextNodeAllOnSameLine === undefined) { - this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); + var OutliningElementsCollector; + (function (OutliningElementsCollector) { + function collectElements(sourceFile) { + var elements = []; + var collapseText = "..."; + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { + if (hintSpanNode && startElement && endElement) { + var span_12 = { + textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), + hintSpan: ts.createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span_12); } - return this.contextNodeAllOnSameLine; - }; - FormattingContext.prototype.NextNodeAllOnSameLine = function () { - if (this.nextNodeAllOnSameLine === undefined) { - this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); + } + function addOutliningSpanComments(commentSpan, autoCollapse) { + if (commentSpan) { + var span_13 = { + textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), + bannerText: collapseText, + autoCollapse: autoCollapse + }; + elements.push(span_13); } - return this.nextNodeAllOnSameLine; - }; - FormattingContext.prototype.TokensAreOnSameLine = function () { - if (this.tokensAreOnSameLine === undefined) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; - this.tokensAreOnSameLine = (startLine === endLine); + } + function addOutliningForLeadingCommentsForNode(n) { + var comments = ts.getLeadingCommentRangesOfNode(n, sourceFile); + if (comments) { + var firstSingleLineCommentStart = -1; + var lastSingleLineCommentEnd = -1; + var isFirstSingleLineComment = true; + var singleLineCommentCount = 0; + for (var _i = 0, comments_4 = comments; _i < comments_4.length; _i++) { + var currentComment = comments_4[_i]; + if (currentComment.kind === 2) { + if (isFirstSingleLineComment) { + firstSingleLineCommentStart = currentComment.pos; + } + isFirstSingleLineComment = false; + lastSingleLineCommentEnd = currentComment.end; + singleLineCommentCount++; + } + else if (currentComment.kind === 3) { + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); + addOutliningSpanComments(currentComment, false); + singleLineCommentCount = 0; + lastSingleLineCommentEnd = -1; + isFirstSingleLineComment = true; + } + } + combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd); } - return this.tokensAreOnSameLine; - }; - FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { - if (this.contextNodeBlockIsOnOneLine === undefined) { - this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); + } + function combineAndAddMultipleSingleLineComments(count, start, end) { + if (count > 1) { + var multipleSingleLineComments = { + pos: start, + end: end, + kind: 2 + }; + addOutliningSpanComments(multipleSingleLineComments, false); } - return this.contextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { - if (this.nextNodeBlockIsOnOneLine === undefined) { - this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); + } + function autoCollapse(node) { + return ts.isFunctionBlock(node) && node.parent.kind !== 181; + } + var depth = 0; + var maxDepth = 20; + function walk(n) { + if (depth > maxDepth) { + return; } - return this.nextNodeBlockIsOnOneLine; - }; - FormattingContext.prototype.NodeIsOnOneLine = function (node) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; - return startLine === endLine; - }; - FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); - if (openBrace && closeBrace) { - var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; - var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; - return startLine === endLine; + if (ts.isDeclaration(n)) { + addOutliningForLeadingCommentsForNode(n); } - return false; - }; - return FormattingContext; - }()); - formatting.FormattingContext = FormattingContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rule = (function () { - function Rule(Descriptor, Operation, Flag) { - if (Flag === void 0) { Flag = 0; } - this.Descriptor = Descriptor; - this.Operation = Operation; - this.Flag = Flag; + switch (n.kind) { + case 200: + if (!ts.isFunctionBlock(n)) { + var parent_22 = n.parent; + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + if (parent_22.kind === 205 || + parent_22.kind === 208 || + parent_22.kind === 209 || + parent_22.kind === 207 || + parent_22.kind === 204 || + parent_22.kind === 206 || + parent_22.kind === 213 || + parent_22.kind === 252) { + addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + break; + } + if (parent_22.kind === 217) { + var tryStatement = parent_22; + if (tryStatement.tryBlock === n) { + addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + break; + } + else if (tryStatement.finallyBlock === n) { + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + if (finallyKeyword) { + addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); + break; + } + } + } + var span_14 = ts.createTextSpanFromBounds(n.getStart(), n.end); + elements.push({ + textSpan: span_14, + hintSpan: span_14, + bannerText: collapseText, + autoCollapse: autoCollapse(n) + }); + break; + } + case 227: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 222: + case 223: + case 225: + case 172: + case 228: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + break; + } + case 171: + var openBracket = ts.findChildOfKind(n, 20, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21, sourceFile); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); + break; + } + depth++; + ts.forEachChild(n, walk); + depth--; } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; - return Rule; - }()); - formatting.Rule = Rule; - })(formatting = ts.formatting || (ts.formatting = {})); + walk(sourceFile); + return elements; + } + OutliningElementsCollector.collectElements = collectElements; + })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); var ts; (function (ts) { - var formatting; - (function (formatting) { - var RuleDescriptor = (function () { - function RuleDescriptor(LeftTokenRange, RightTokenRange) { - this.LeftTokenRange = LeftTokenRange; - this.RightTokenRange = RightTokenRange; + (function (PatternMatchKind) { + PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; + PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; + PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; + PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; + })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); + var PatternMatchKind = ts.PatternMatchKind; + function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { + return { + kind: kind, + punctuationStripped: punctuationStripped, + isCaseSensitive: isCaseSensitive, + camelCaseWeight: camelCaseWeight + }; + } + function createPatternMatcher(pattern) { + var stringToWordSpans = ts.createMap(); + pattern = pattern.trim(); + var dotSeparatedSegments = pattern.split(".").map(function (p) { return createSegment(p.trim()); }); + var invalidPattern = dotSeparatedSegments.length === 0 || ts.forEach(dotSeparatedSegments, segmentIsInvalid); + return { + getMatches: getMatches, + getMatchesForLastSegmentOfPattern: getMatchesForLastSegmentOfPattern, + patternContainsDots: dotSeparatedSegments.length > 1 + }; + function skipMatch(candidate) { + return invalidPattern || !candidate; + } + function getMatchesForLastSegmentOfPattern(candidate) { + if (skipMatch(candidate)) { + return undefined; } - RuleDescriptor.prototype.toString = function () { - return "[leftRange=" + this.LeftTokenRange + "," + - "rightRange=" + this.RightTokenRange + "]"; - }; - RuleDescriptor.create1 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create2 = function (left, right) { - return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); - }; - RuleDescriptor.create3 = function (left, right) { - return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); - }; - RuleDescriptor.create4 = function (left, right) { - return new RuleDescriptor(left, right); - }; - return RuleDescriptor; - }()); - formatting.RuleDescriptor = RuleDescriptor; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperation = (function () { - function RuleOperation(Context, Action) { - this.Context = Context; - this.Action = Action; + return matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + } + function getMatches(candidateContainers, candidate) { + if (skipMatch(candidate)) { + return undefined; } - RuleOperation.prototype.toString = function () { - return "[context=" + this.Context + "," + - "action=" + this.Action + "]"; - }; - RuleOperation.create1 = function (action) { - return RuleOperation.create2(formatting.RuleOperationContext.Any, action); - }; - RuleOperation.create2 = function (context, action) { - return new RuleOperation(context, action); - }; - return RuleOperation; - }()); - formatting.RuleOperation = RuleOperation; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RuleOperationContext = (function () { - function RuleOperationContext() { - var funcs = []; - for (var _i = 0; _i < arguments.length; _i++) { - funcs[_i - 0] = arguments[_i]; + var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments)); + if (!candidateMatch) { + return undefined; + } + candidateContainers = candidateContainers || []; + if (dotSeparatedSegments.length - 1 > candidateContainers.length) { + return undefined; + } + var totalMatch = candidateMatch; + for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1; i >= 0; i -= 1, j -= 1) { + var segment = dotSeparatedSegments[i]; + var containerName = candidateContainers[j]; + var containerMatch = matchSegment(containerName, segment); + if (!containerMatch) { + return undefined; } - this.customContextChecks = funcs; + ts.addRange(totalMatch, containerMatch); } - RuleOperationContext.prototype.IsAny = function () { - return this === RuleOperationContext.Any; - }; - RuleOperationContext.prototype.InContext = function (context) { - if (this.IsAny()) { + return totalMatch; + } + function getWordSpans(word) { + if (!(word in stringToWordSpans)) { + stringToWordSpans[word] = breakIntoWordSpans(word); + } + return stringToWordSpans[word]; + } + function matchTextChunk(candidate, chunk, punctuationStripped) { + var index = indexOfIgnoringCase(candidate, chunk.textLowerCase); + if (index === 0) { + if (chunk.text.length === candidate.length) { + return createPatternMatch(PatternMatchKind.exact, punctuationStripped, candidate === chunk.text); + } + else { + return createPatternMatch(PatternMatchKind.prefix, punctuationStripped, ts.startsWith(candidate, chunk.text)); + } + } + var isLowercase = chunk.isLowerCase; + if (isLowercase) { + if (index > 0) { + var wordSpans = getWordSpans(candidate); + for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { + var span_15 = wordSpans_1[_i]; + if (partStartsWith(candidate, span_15, chunk.text, true)) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span_15, chunk.text, false)); + } + } + } + } + else { + if (candidate.indexOf(chunk.text) > 0) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, true); + } + } + if (!isLowercase) { + if (chunk.characterSpans.length > 0) { + var candidateParts = getWordSpans(candidate); + var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, false); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, true, camelCaseWeight); + } + camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, true); + if (camelCaseWeight !== undefined) { + return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, false, camelCaseWeight); + } + } + } + if (isLowercase) { + if (chunk.text.length < candidate.length) { + if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, false); + } + } + } + return undefined; + } + function containsSpaceOrAsterisk(text) { + for (var i = 0; i < text.length; i++) { + var ch = text.charCodeAt(i); + if (ch === 32 || ch === 42) { return true; } - for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { - var check = _a[_i]; - if (!check(context)) { + } + return false; + } + function matchSegment(candidate, segment) { + if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) { + var match = matchTextChunk(candidate, segment.totalTextChunk, false); + if (match) { + return [match]; + } + } + var subWordTextChunks = segment.subWordTextChunks; + var matches = undefined; + for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { + var subWordTextChunk = subWordTextChunks_1[_i]; + var result = matchTextChunk(candidate, subWordTextChunk, true); + if (!result) { + return undefined; + } + matches = matches || []; + matches.push(result); + } + return matches; + } + function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { + var patternPartStart = patternSpan ? patternSpan.start : 0; + var patternPartLength = patternSpan ? patternSpan.length : pattern.length; + if (patternPartLength > candidateSpan.length) { + return false; + } + if (ignoreCase) { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (toLowerCase(ch1) !== toLowerCase(ch2)) { return false; } } - return true; - }; - return RuleOperationContext; - }()); - RuleOperationContext.Any = new RuleOperationContext(); - formatting.RuleOperationContext = RuleOperationContext; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Rules = (function () { - function Rules() { - this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); - this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); - this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73, 82, 89]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 79, 100, 85, 80]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); - this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102, 98, 92, 78, 94, 101, 119]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108, 74]), 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 131]), 69), 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.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 129]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 131, 113, 134, 136]), 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([83, 106, 136])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 131, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.HighPriorityCommonRules = [ - this.IgnoreBeforeComment, this.IgnoreAfterLineComment, - this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, - this.NoSpaceAfterQuestionMark, - this.NoSpaceBeforeDot, this.NoSpaceAfterDot, - this.NoSpaceAfterUnaryPrefixOperator, - this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, - this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, - this.SpaceAfterPostincrementWhenFollowedByAdd, - this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, - this.SpaceAfterPostdecrementWhenFollowedBySubtract, - this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, - this.NoSpaceAfterCloseBrace, - this.NewLineBeforeCloseBraceInBlockContext, - this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, - this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, - this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, - this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, - this.NoSpaceBetweenReturnAndSemicolon, - this.SpaceAfterCertainKeywords, - this.SpaceAfterLetConstInVariableDeclaration, - this.NoSpaceBeforeOpenParenInFuncCall, - this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, - this.SpaceAfterVoidOperator, - this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, - this.NoSpaceBetweenTagAndTemplateString, - this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, - this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, - this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, - this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, - this.SpaceAfterModuleName, - this.SpaceBeforeArrow, this.SpaceAfterArrow, - this.NoSpaceAfterEllipsis, - this.NoSpaceAfterOptionalParameters, - this.NoSpaceBetweenEmptyInterfaceBraceBrackets, - this.NoSpaceBeforeOpenAngularBracket, - this.NoSpaceBetweenCloseParenAndAngularBracket, - this.NoSpaceAfterOpenAngularBracket, - this.NoSpaceBeforeCloseAngularBracket, - this.NoSpaceAfterCloseAngularBracket, - this.SpaceBeforeAt, - this.NoSpaceAfterAt, - this.SpaceAfterDecorator, - ]; - this.LowPriorityCommonRules = [ - this.NoSpaceBeforeSemicolon, - this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, - this.NoSpaceBeforeComma, - this.NoSpaceBeforeOpenBracket, - this.NoSpaceAfterCloseBracket, - this.SpaceAfterSemicolon, - this.NoSpaceBeforeOpenParenInFuncDecl, - this.SpaceBetweenStatements, this.SpaceAfterTryFinally - ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); - this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name_51 in o) { - if (o[name_51] === rule) { - return name_51; + else { + for (var i = 0; i < patternPartLength; i++) { + var ch1 = pattern.charCodeAt(patternPartStart + i); + var ch2 = candidate.charCodeAt(candidateSpan.start + i); + if (ch1 !== ch2) { + return false; } } - throw new Error("Unknown rule"); - }; - Rules.IsForContext = function (context) { - return context.contextNode.kind === 206; - }; - Rules.IsNotForContext = function (context) { - return !Rules.IsForContext(context); - }; - Rules.IsBinaryOpContext = function (context) { - switch (context.contextNode.kind) { - case 187: - case 188: - case 195: - case 238: - case 234: - case 154: - case 162: - case 163: - return true; - case 169: - case 223: - case 229: - case 218: - case 142: - case 255: - case 145: - case 144: - return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; - case 207: - return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; - case 208: - return context.currentTokenSpan.kind === 138 || context.nextTokenSpan.kind === 138; - } - return false; - }; - Rules.IsNotBinaryOpContext = function (context) { - return !Rules.IsBinaryOpContext(context); - }; - Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188; - }; - Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { - return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); - }; - Rules.IsBeforeMultilineBlockContext = function (context) { - return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); - }; - Rules.IsMultilineBlockContext = function (context) { - return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsSingleLineBlockContext = function (context) { - return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); - }; - Rules.IsBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.contextNode); - }; - Rules.IsBeforeBlockContext = function (context) { - return Rules.NodeIsBlockContext(context.nextTokenParent); - }; - Rules.NodeIsBlockContext = function (node) { - if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { - return true; - } - switch (node.kind) { - case 199: - case 227: - case 171: - case 226: - return true; + } + return true; + } + function tryCamelCaseMatch(candidate, candidateParts, chunk, ignoreCase) { + var chunkCharacterSpans = chunk.characterSpans; + var currentCandidate = 0; + var currentChunkSpan = 0; + var firstMatch = undefined; + var contiguous = undefined; + while (true) { + if (currentChunkSpan === chunkCharacterSpans.length) { + var weight = 0; + if (contiguous) { + weight += 1; + } + if (firstMatch === 0) { + weight += 2; + } + return weight; } - return false; - }; - Rules.IsFunctionDeclContext = function (context) { - switch (context.contextNode.kind) { - case 220: - case 147: - case 146: - case 149: - case 150: - case 151: - case 179: - case 148: - case 180: - case 222: - return true; + else if (currentCandidate === candidateParts.length) { + return undefined; } - return false; - }; - Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 || context.contextNode.kind === 179; - }; - Rules.IsTypeScriptDeclWithBlockContext = function (context) { - return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); - }; - Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { - switch (node.kind) { - case 221: - case 192: - case 222: - case 224: - case 159: - case 225: - case 236: - case 237: - case 230: - case 233: - return true; + var candidatePart = candidateParts[currentCandidate]; + var gotOneMatchThisCandidate = false; + for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) { + var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan]; + if (gotOneMatchThisCandidate) { + if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) || + !isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) { + break; + } + } + if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) { + break; + } + gotOneMatchThisCandidate = true; + firstMatch = firstMatch === undefined ? currentCandidate : firstMatch; + contiguous = contiguous === undefined ? true : contiguous; + candidatePart = ts.createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length); } - return false; - }; - Rules.IsAfterCodeBlockContext = function (context) { - switch (context.currentTokenParent.kind) { - case 221: - case 225: - case 224: - case 199: - case 252: - case 226: - case 213: - return true; + if (!gotOneMatchThisCandidate && contiguous !== undefined) { + contiguous = false; } + currentCandidate++; + } + } + } + ts.createPatternMatcher = createPatternMatcher; + function createSegment(text) { + return { + totalTextChunk: createTextChunk(text), + subWordTextChunks: breakPatternIntoTextChunks(text) + }; + } + function segmentIsInvalid(segment) { + return segment.subWordTextChunks.length === 0; + } + function isUpperCaseLetter(ch) { + if (ch >= 65 && ch <= 90) { + return true; + } + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { + return false; + } + var str = String.fromCharCode(ch); + return str === str.toUpperCase(); + } + function isLowerCaseLetter(ch) { + if (ch >= 97 && ch <= 122) { + return true; + } + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { + return false; + } + var str = String.fromCharCode(ch); + return str === str.toLowerCase(); + } + function indexOfIgnoringCase(string, value) { + for (var i = 0, n = string.length - value.length; i <= n; i++) { + if (startsWithIgnoringCase(string, value, i)) { + return i; + } + } + return -1; + } + function startsWithIgnoringCase(string, value, start) { + for (var i = 0, n = value.length; i < n; i++) { + var ch1 = toLowerCase(string.charCodeAt(i + start)); + var ch2 = value.charCodeAt(i); + if (ch1 !== ch2) { return false; - }; - Rules.IsControlDeclContext = function (context) { - switch (context.contextNode.kind) { - case 203: - case 213: - case 206: - case 207: - case 208: - case 205: - case 216: - case 204: - case 212: - case 252: - return true; - default: - return false; + } + } + return true; + } + function toLowerCase(ch) { + if (ch >= 65 && ch <= 90) { + return 97 + (ch - 65); + } + if (ch < 127) { + return ch; + } + return String.fromCharCode(ch).toLowerCase().charCodeAt(0); + } + function isDigit(ch) { + return ch >= 48 && ch <= 57; + } + function isWordChar(ch) { + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 || ch === 36; + } + function breakPatternIntoTextChunks(pattern) { + var result = []; + var wordStart = 0; + var wordLength = 0; + for (var i = 0; i < pattern.length; i++) { + var ch = pattern.charCodeAt(i); + if (isWordChar(ch)) { + if (wordLength === 0) { + wordStart = i; } - }; - Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171; - }; - Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174; - }; - Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175; - }; - Rules.IsFunctionCallOrNewContext = function (context) { - return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); - }; - Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24; - }; - Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20; - }; - Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180; - }; - Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244; - }; - Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241; - }; - Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248; - }; - Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246; - }; - Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246; - }; - Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242; - }; - Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { - return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); - }; - Rules.IsEndOfDecoratorContextOnSameLine = function (context) { - return context.TokensAreOnSameLine() && - context.contextNode.decorators && - Rules.NodeIsInDecoratorContext(context.currentTokenParent) && - !Rules.NodeIsInDecoratorContext(context.nextTokenParent); - }; - Rules.NodeIsInDecoratorContext = function (node) { - while (ts.isPartOfExpression(node)) { - node = node.parent; + wordLength++; + } + else { + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + wordLength = 0; } - return node.kind === 143; - }; - Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 && - context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; - }; - Rules.IsNotFormatOnEnter = function (context) { - return context.formattingRequestKind !== 2; - }; - Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 225; - }; - Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159; - }; - Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 && token.kind !== 27) { - return false; + } + } + if (wordLength > 0) { + result.push(createTextChunk(pattern.substr(wordStart, wordLength))); + } + return result; + } + function createTextChunk(text) { + var textLowerCase = text.toLowerCase(); + return { + text: text, + textLowerCase: textLowerCase, + isLowerCase: text === textLowerCase, + characterSpans: breakIntoCharacterSpans(text) + }; + } + function breakIntoCharacterSpans(identifier) { + return breakIntoSpans(identifier, false); + } + ts.breakIntoCharacterSpans = breakIntoCharacterSpans; + function breakIntoWordSpans(identifier) { + return breakIntoSpans(identifier, true); + } + ts.breakIntoWordSpans = breakIntoWordSpans; + function breakIntoSpans(identifier, word) { + var result = []; + var wordStart = 0; + for (var i = 1, n = identifier.length; i < n; i++) { + var lastIsDigit = isDigit(identifier.charCodeAt(i - 1)); + var currentIsDigit = isDigit(identifier.charCodeAt(i)); + var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i); + var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart); + if (charIsPunctuation(identifier.charCodeAt(i - 1)) || + charIsPunctuation(identifier.charCodeAt(i)) || + lastIsDigit !== currentIsDigit || + hasTransitionFromLowerToUpper || + hasTransitionFromUpperToLower) { + if (!isAllPunctuation(identifier, wordStart, i)) { + result.push(ts.createTextSpan(wordStart, i - wordStart)); } - switch (parent.kind) { - case 155: - case 177: - case 221: - case 192: - case 222: - case 220: - case 179: - case 180: - case 147: - case 146: - case 151: - case 152: - case 174: - case 175: - case 194: - return true; - default: - return false; + wordStart = i; + } + } + if (!isAllPunctuation(identifier, wordStart, identifier.length)) { + result.push(ts.createTextSpan(wordStart, identifier.length - wordStart)); + } + return result; + } + function charIsPunctuation(ch) { + switch (ch) { + case 33: + case 34: + case 35: + case 37: + case 38: + case 39: + case 40: + case 41: + case 42: + case 44: + case 45: + case 46: + case 47: + case 58: + case 59: + case 63: + case 64: + case 91: + case 92: + case 93: + case 95: + case 123: + case 125: + return true; + } + return false; + } + function isAllPunctuation(identifier, start, end) { + for (var i = start; i < end; i++) { + var ch = identifier.charCodeAt(i); + if (!charIsPunctuation(ch) || ch === 95 || ch === 36) { + return false; + } + } + return true; + } + function transitionFromUpperToLower(identifier, word, index, wordStart) { + if (word) { + if (index !== wordStart && + index + 1 < identifier.length) { + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); + if (currentIsUpper && nextIsLower) { + for (var i = wordStart; i < index; i++) { + if (!isUpperCaseLetter(identifier.charCodeAt(i))) { + return false; + } + } + return true; } - }; - Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { - return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || - Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); - }; - Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177; - }; - Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 183; - }; - Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 && context.contextNode.expression !== undefined; - }; - return Rules; - }()); - formatting.Rules = Rules; - })(formatting = ts.formatting || (ts.formatting = {})); + } + } + return false; + } + function transitionFromLowerToUpper(identifier, word, index) { + var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1)); + var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); + var transition = word + ? (currentIsUpper && !lastIsUpper) + : currentIsUpper; + return transition; + } })(ts || (ts = {})); var ts; (function (ts) { - var formatting; - (function (formatting) { - var RulesMap = (function () { - function RulesMap() { - this.map = []; - this.mapRowLength = 0; + function preProcessFile(sourceText, readImportFiles, detectJavaScriptImports) { + if (readImportFiles === void 0) { readImportFiles = true; } + if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } + var referencedFiles = []; + var typeReferenceDirectives = []; + var importedFiles = []; + var ambientExternalModules; + var isNoDefaultLib = false; + var braceNesting = 0; + var externalModule = false; + function nextToken() { + var token = ts.scanner.scan(); + if (token === 16) { + braceNesting++; } - RulesMap.create = function (rules) { - var result = new RulesMap(); - result.Initialize(rules); - return result; - }; - RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 + 1; - this.map = new Array(this.mapRowLength * this.mapRowLength); - var rulesBucketConstructionStateList = new Array(this.map.length); - this.FillRules(rules, rulesBucketConstructionStateList); - return this.map; - }; - RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { - var _this = this; - rules.forEach(function (rule) { - _this.FillRule(rule, rulesBucketConstructionStateList); - }); - }; - RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - var rulesBucketIndex = (row * this.mapRowLength) + column; - return rulesBucketIndex; + else if (token === 17) { + braceNesting--; + } + return token; + } + function processTripleSlashDirectives() { + var commentRanges = ts.getLeadingCommentRanges(sourceText, 0); + ts.forEach(commentRanges, function (commentRange) { + var comment = sourceText.substring(commentRange.pos, commentRange.end); + var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, commentRange); + if (referencePathMatchResult) { + isNoDefaultLib = referencePathMatchResult.isNoDefaultLib; + var fileReference = referencePathMatchResult.fileReference; + if (fileReference) { + var collection = referencePathMatchResult.isTypeReferenceDirective + ? typeReferenceDirectives + : referencedFiles; + collection.push(fileReference); + } + } + }); + } + function getFileReference() { + var file = ts.scanner.getTokenValue(); + var pos = ts.scanner.getTokenPos(); + return { + fileName: file, + pos: pos, + end: pos + file.length }; - RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { - var _this = this; - var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; - rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { - rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { - var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); - var rulesBucket = _this.map[rulesBucketIndex]; - if (rulesBucket === undefined) { - rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); - } - rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); - }); - }); - }; - RulesMap.prototype.GetRule = function (context) { - var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); - var bucket = this.map[bucketIndex]; - if (bucket) { - for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { - var rule = _a[_i]; - if (rule.Operation.Context.InContext(context)) { - return rule; - } - } - } - return undefined; - }; - return RulesMap; - }()); - formatting.RulesMap = RulesMap; - var MaskBitSize = 5; - var Mask = 0x1f; - (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; - RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; - RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; - RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; - RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; - var RulesBucketConstructionState = (function () { - function RulesBucketConstructionState() { - this.rulesInsertionIndexBitmap = 0; + } + function recordAmbientExternalModule() { + if (!ambientExternalModules) { + ambientExternalModules = []; } - RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { - var index = 0; - var pos = 0; - var indexBitmap = this.rulesInsertionIndexBitmap; - while (pos <= maskPosition) { - index += (indexBitmap & Mask); - indexBitmap >>= MaskBitSize; - pos += MaskBitSize; - } - return index; - }; - RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { - var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; - value++; - ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); - var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); - temp |= value << maskPosition; - this.rulesInsertionIndexBitmap = temp; - }; - return RulesBucketConstructionState; - }()); - formatting.RulesBucketConstructionState = RulesBucketConstructionState; - var RulesBucket = (function () { - function RulesBucket() { - this.rules = []; + ambientExternalModules.push({ ref: getFileReference(), depth: braceNesting }); + } + function recordModuleName() { + importedFiles.push(getFileReference()); + markAsExternalModuleIfTopLevel(); + } + function markAsExternalModuleIfTopLevel() { + if (braceNesting === 0) { + externalModule = true; } - RulesBucket.prototype.Rules = function () { - return this.rules; - }; - RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { - var position; - if (rule.Operation.Action === 1) { - position = specificTokens ? - RulesPosition.IgnoreRulesSpecific : - RulesPosition.IgnoreRulesAny; + } + function tryConsumeDeclare() { + var token = ts.scanner.getToken(); + if (token === 123) { + token = nextToken(); + if (token === 126) { + token = nextToken(); + if (token === 9) { + recordAmbientExternalModule(); + } } - else if (!rule.Operation.Context.IsAny()) { - position = specificTokens ? - RulesPosition.ContextRulesSpecific : - RulesPosition.ContextRulesAny; + return true; + } + return false; + } + function tryConsumeImport() { + var token = ts.scanner.getToken(); + if (token === 90) { + token = nextToken(); + if (token === 9) { + recordModuleName(); + return true; } else { - position = specificTokens ? - RulesPosition.NoContextRulesSpecific : - RulesPosition.NoContextRulesAny; - } - var state = constructionState[rulesBucketIndex]; - if (state === undefined) { - state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); - } - var index = state.GetInsertionIndex(position); - this.rules.splice(index, 0, rule); - state.IncreaseInsertionIndex(position); - }; - return RulesBucket; - }()); - formatting.RulesBucket = RulesBucket; - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var Shared; - (function (Shared) { - var TokenRangeAccess = (function () { - function TokenRangeAccess(from, to, except) { - this.tokens = []; - for (var token = from; token <= to; token++) { - if (ts.indexOf(except, token) < 0) { - this.tokens.push(token); + if (token === 70 || ts.isKeyword(token)) { + token = nextToken(); + if (token === 137) { + token = nextToken(); + if (token === 9) { + recordModuleName(); + return true; + } + } + else if (token === 57) { + if (tryConsumeRequireCall(true)) { + return true; + } + } + else if (token === 25) { + token = nextToken(); + } + else { + return true; } } - } - TokenRangeAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenRangeAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenRangeAccess; - }()); - Shared.TokenRangeAccess = TokenRangeAccess; - var TokenValuesAccess = (function () { - function TokenValuesAccess(tks) { - this.tokens = tks && tks.length ? tks : []; - } - TokenValuesAccess.prototype.GetTokens = function () { - return this.tokens; - }; - TokenValuesAccess.prototype.Contains = function (token) { - return this.tokens.indexOf(token) >= 0; - }; - return TokenValuesAccess; - }()); - Shared.TokenValuesAccess = TokenValuesAccess; - var TokenSingleValueAccess = (function () { - function TokenSingleValueAccess(token) { - this.token = token; - } - TokenSingleValueAccess.prototype.GetTokens = function () { - return [this.token]; - }; - TokenSingleValueAccess.prototype.Contains = function (tokenValue) { - return tokenValue === this.token; - }; - return TokenSingleValueAccess; - }()); - Shared.TokenSingleValueAccess = TokenSingleValueAccess; - var TokenAllAccess = (function () { - function TokenAllAccess() { - } - TokenAllAccess.prototype.GetTokens = function () { - var result = []; - for (var token = 0; token <= 138; token++) { - result.push(token); + if (token === 16) { + token = nextToken(); + while (token !== 17 && token !== 1) { + token = nextToken(); + } + if (token === 17) { + token = nextToken(); + if (token === 137) { + token = nextToken(); + if (token === 9) { + recordModuleName(); + } + } + } + } + else if (token === 38) { + token = nextToken(); + if (token === 117) { + token = nextToken(); + if (token === 70 || ts.isKeyword(token)) { + token = nextToken(); + if (token === 137) { + token = nextToken(); + if (token === 9) { + recordModuleName(); + } + } + } + } } - return result; - }; - TokenAllAccess.prototype.Contains = function (tokenValue) { - return true; - }; - TokenAllAccess.prototype.toString = function () { - return "[allTokens]"; - }; - return TokenAllAccess; - }()); - Shared.TokenAllAccess = TokenAllAccess; - var TokenRange = (function () { - function TokenRange(tokenAccess) { - this.tokenAccess = tokenAccess; } - TokenRange.FromToken = function (token) { - return new TokenRange(new TokenSingleValueAccess(token)); - }; - TokenRange.FromTokens = function (tokens) { - return new TokenRange(new TokenValuesAccess(tokens)); - }; - TokenRange.FromRange = function (f, to, except) { - if (except === void 0) { except = []; } - return new TokenRange(new TokenRangeAccess(f, to, except)); - }; - TokenRange.AllTokens = function () { - return new TokenRange(new TokenAllAccess()); - }; - TokenRange.prototype.GetTokens = function () { - return this.tokenAccess.GetTokens(); - }; - TokenRange.prototype.Contains = function (token) { - return this.tokenAccess.Contains(token); - }; - TokenRange.prototype.toString = function () { - return this.tokenAccess.toString(); - }; - return TokenRange; - }()); - TokenRange.Any = TokenRange.AllTokens(); - TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(70, 138); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 138, 116, 124]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); - TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([69, 130, 132, 120, 133, 103, 117]); - Shared.TokenRange = TokenRange; - })(Shared = formatting.Shared || (formatting.Shared = {})); - })(formatting = ts.formatting || (ts.formatting = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var formatting; - (function (formatting) { - var RulesProvider = (function () { - function RulesProvider() { - this.globalRules = new formatting.Rules(); + return true; } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; - RulesProvider.prototype.getRulesMap = function () { - return this.rulesMap; - }; - RulesProvider.prototype.ensureUpToDate = function (options) { - if (!this.options || !ts.compareDataObjects(this.options, options)) { - var activeRules = this.createActiveRules(options); - var rulesMap = formatting.RulesMap.create(activeRules); - this.activeRules = activeRules; - this.rulesMap = rulesMap; - this.options = ts.clone(options); - } - }; - RulesProvider.prototype.createActiveRules = function (options) { - var rules = this.globalRules.HighPriorityCommonRules.slice(0); - if (options.insertSpaceAfterCommaDelimiter) { - rules.push(this.globalRules.SpaceAfterComma); - } - else { - rules.push(this.globalRules.NoSpaceAfterComma); - } - if (options.insertSpaceAfterFunctionKeywordForAnonymousFunctions) { - rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); - } - else { - rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); - } - if (options.insertSpaceAfterKeywordsInControlFlowStatements) { - rules.push(this.globalRules.SpaceAfterKeywordInControl); - } - else { - rules.push(this.globalRules.NoSpaceAfterKeywordInControl); - } - if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { - rules.push(this.globalRules.SpaceAfterOpenParen); - rules.push(this.globalRules.SpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenParen); - rules.push(this.globalRules.NoSpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { - rules.push(this.globalRules.SpaceAfterOpenBracket); - rules.push(this.globalRules.SpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBracket); - rules.push(this.globalRules.NoSpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); + return false; + } + function tryConsumeExport() { + var token = ts.scanner.getToken(); + if (token === 83) { + markAsExternalModuleIfTopLevel(); + token = nextToken(); + if (token === 16) { + token = nextToken(); + while (token !== 17 && token !== 1) { + token = nextToken(); + } + if (token === 17) { + token = nextToken(); + if (token === 137) { + token = nextToken(); + if (token === 9) { + recordModuleName(); + } + } + } } - if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces !== false) { - rules.push(this.globalRules.SpaceAfterOpenBrace); - rules.push(this.globalRules.SpaceBeforeCloseBrace); - rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); + else if (token === 38) { + token = nextToken(); + if (token === 137) { + token = nextToken(); + if (token === 9) { + recordModuleName(); + } + } } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBrace); - rules.push(this.globalRules.NoSpaceBeforeCloseBrace); - rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); + else if (token === 90) { + token = nextToken(); + if (token === 70 || ts.isKeyword(token)) { + token = nextToken(); + if (token === 57) { + if (tryConsumeRequireCall(true)) { + return true; + } + } + } } - if (options.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces) { - rules.push(this.globalRules.SpaceAfterTemplateHeadAndMiddle); - rules.push(this.globalRules.SpaceBeforeTemplateMiddleAndTail); + return true; + } + return false; + } + function tryConsumeRequireCall(skipCurrentToken) { + var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); + if (token === 130) { + token = nextToken(); + if (token === 18) { + token = nextToken(); + if (token === 9) { + recordModuleName(); + } } - else { - rules.push(this.globalRules.NoSpaceAfterTemplateHeadAndMiddle); - rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail); + return true; + } + return false; + } + function tryConsumeDefine() { + var token = ts.scanner.getToken(); + if (token === 70 && ts.scanner.getTokenValue() === "define") { + token = nextToken(); + if (token !== 18) { + return true; } - if (options.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { - rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression); - rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression); + token = nextToken(); + if (token === 9) { + token = nextToken(); + if (token === 25) { + token = nextToken(); + } + else { + return true; + } } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression); - rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression); + if (token !== 20) { + return true; } - if (options.insertSpaceAfterSemicolonInForStatements) { - rules.push(this.globalRules.SpaceAfterSemicolonInFor); + token = nextToken(); + var i = 0; + while (token !== 21 && token !== 1) { + if (token === 9) { + recordModuleName(); + i++; + } + token = nextToken(); } - else { - rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); + return true; + } + return false; + } + function processImports() { + ts.scanner.setText(sourceText); + nextToken(); + while (true) { + if (ts.scanner.getToken() === 1) { + break; } - if (options.insertSpaceBeforeAndAfterBinaryOperators) { - rules.push(this.globalRules.SpaceBeforeBinaryOperator); - rules.push(this.globalRules.SpaceAfterBinaryOperator); + if (tryConsumeDeclare() || + tryConsumeImport() || + tryConsumeExport() || + (detectJavaScriptImports && (tryConsumeRequireCall(false) || tryConsumeDefine()))) { + continue; } else { - rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); - rules.push(this.globalRules.NoSpaceAfterBinaryOperator); - } - if (options.placeOpenBraceOnNewLineForControlBlocks) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); - } - if (options.placeOpenBraceOnNewLineForFunctions) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); - rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); + nextToken(); } - if (options.insertSpaceAfterTypeAssertion) { - rules.push(this.globalRules.SpaceAfterTypeAssertion); + } + ts.scanner.setText(undefined); + } + if (readImportFiles) { + processImports(); + } + processTripleSlashDirectives(); + if (externalModule) { + if (ambientExternalModules) { + for (var _i = 0, ambientExternalModules_1 = ambientExternalModules; _i < ambientExternalModules_1.length; _i++) { + var decl = ambientExternalModules_1[_i]; + importedFiles.push(decl.ref); } - else { - rules.push(this.globalRules.NoSpaceAfterTypeAssertion); + } + return { referencedFiles: referencedFiles, typeReferenceDirectives: typeReferenceDirectives, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: undefined }; + } + else { + var ambientModuleNames = void 0; + if (ambientExternalModules) { + for (var _a = 0, ambientExternalModules_2 = ambientExternalModules; _a < ambientExternalModules_2.length; _a++) { + var decl = ambientExternalModules_2[_a]; + if (decl.depth === 0) { + if (!ambientModuleNames) { + ambientModuleNames = []; + } + ambientModuleNames.push(decl.ref.fileName); + } + else { + importedFiles.push(decl.ref); + } } - rules = rules.concat(this.globalRules.LowPriorityCommonRules); - return rules; - }; - return RulesProvider; - }()); - formatting.RulesProvider = RulesProvider; - })(formatting = ts.formatting || (ts.formatting = {})); + } + return { referencedFiles: referencedFiles, typeReferenceDirectives: typeReferenceDirectives, importedFiles: importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientModuleNames }; + } + } + ts.preProcessFile = preProcessFile; })(ts || (ts = {})); var ts; (function (ts) { - var formatting; - (function (formatting) { - function formatOnEnter(position, sourceFile, rulesProvider, options) { - var line = sourceFile.getLineAndCharacterOfPosition(position).line; - if (line === 0) { - return []; - } - var endOfFormatSpan = ts.getEndLinePosition(line, sourceFile); - while (ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(endOfFormatSpan))) { - endOfFormatSpan--; - } - if (ts.isLineBreak(sourceFile.text.charCodeAt(endOfFormatSpan))) { - endOfFormatSpan--; - } - var span = { - pos: ts.getStartPositionOfLine(line - 1, sourceFile), - end: endOfFormatSpan + 1 - }; - return formatSpan(span, sourceFile, options, rulesProvider, 2); - } - formatting.formatOnEnter = formatOnEnter; - function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); - } - formatting.formatOnSemicolon = formatOnSemicolon; - function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); - } - formatting.formatOnClosingCurly = formatOnClosingCurly; - function formatDocument(sourceFile, rulesProvider, options) { - var span = { - pos: 0, - end: sourceFile.text.length - }; - return formatSpan(span, sourceFile, options, rulesProvider, 0); - } - formatting.formatDocument = formatDocument; - function formatSelection(start, end, sourceFile, rulesProvider, options) { - var span = { - pos: ts.getLineStartPositionForPosition(start, sourceFile), - end: end - }; - return formatSpan(span, sourceFile, options, rulesProvider, 1); - } - formatting.formatSelection = formatSelection; - function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { - var parent = findOutermostParent(position, expectedLastToken, sourceFile); - if (!parent) { - return []; + var Rename; + (function (Rename) { + function getRenameInfo(typeChecker, defaultLibFileName, getCanonicalFileName, sourceFile, position) { + var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); + var node = ts.getTouchingWord(sourceFile, position, true); + if (node) { + if (node.kind === 70 || + node.kind === 9 || + ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || + ts.isThis(node)) { + var symbol = typeChecker.getSymbolAtLocation(node); + if (symbol) { + var declarations = symbol.getDeclarations(); + if (declarations && declarations.length > 0) { + if (ts.forEach(declarations, isDefinedInLibraryFile)) { + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); + } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + if (kind) { + return { + canRename: true, + kind: kind, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: typeChecker.getFullyQualifiedName(symbol), + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + } + } + else if (node.kind === 9) { + var type = ts.getStringLiteralTypeForNode(node, typeChecker); + if (type) { + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library)); + } + else { + var displayName = ts.stripQuotes(type.text); + return { + canRename: true, + kind: ts.ScriptElementKind.variableElement, + displayName: displayName, + localizedErrorMessage: undefined, + fullDisplayName: displayName, + kindModifiers: ts.ScriptElementKindModifier.none, + triggerSpan: createTriggerSpanForNode(node, sourceFile) + }; + } + } + } + } } - var span = { - pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), - end: parent.end - }; - return formatSpan(span, sourceFile, options, rulesProvider, requestKind); - } - function findOutermostParent(position, expectedTokenKind, sourceFile) { - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken || - precedingToken.kind !== expectedTokenKind || - position !== precedingToken.getEnd()) { - return undefined; + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element)); + function getRenameInfoError(localizedErrorMessage) { + return { + canRename: false, + localizedErrorMessage: localizedErrorMessage, + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; } - var current = precedingToken; - while (current && - current.parent && - current.parent.end === precedingToken.end && - !isListElement(current.parent, current)) { - current = current.parent; + function isDefinedInLibraryFile(declaration) { + if (defaultLibFileName) { + var sourceFile_1 = declaration.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_1.fileName)); + if (canonicalName === canonicalDefaultLibName) { + return true; + } + } + return false; } - return current; - } - function isListElement(parent, node) { - switch (parent.kind) { - case 221: - case 222: - return ts.rangeContainsRange(parent.members, node); - case 225: - var body = parent.body; - return body && body.kind === 226 && ts.rangeContainsRange(body.statements, node); - case 256: - case 199: - case 226: - return ts.rangeContainsRange(parent.statements, node); - case 252: - return ts.rangeContainsRange(parent.block.statements, node); + function createTriggerSpanForNode(node, sourceFile) { + var start = node.getStart(sourceFile); + var width = node.getWidth(sourceFile); + if (node.kind === 9) { + start += 1; + width -= 2; + } + return ts.createTextSpan(start, width); } - return false; } - function findEnclosingNode(range, sourceFile) { - return find(sourceFile); - function find(n) { - var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); - if (candidate) { - var result = find(candidate); - if (result) { - return result; - } + Rename.getRenameInfo = getRenameInfo; + })(Rename = ts.Rename || (ts.Rename = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var SignatureHelp; + (function (SignatureHelp) { + var emptyArray = []; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + })(SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + var ArgumentListKind = SignatureHelp.ArgumentListKind; + function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { + var typeChecker = program.getTypeChecker(); + var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); + if (!startingToken) { + return undefined; + } + var argumentInfo = getContainingArgumentInfo(startingToken, position, sourceFile); + cancellationToken.throwIfCancellationRequested(); + if (!argumentInfo) { + return undefined; + } + var call = argumentInfo.invocation; + var candidates = []; + var resolvedSignature = typeChecker.getResolvedSignature(call, candidates); + cancellationToken.throwIfCancellationRequested(); + if (!candidates.length) { + if (ts.isSourceFileJavaScript(sourceFile)) { + return createJavaScriptSignatureHelpItems(argumentInfo, program); } - return n; + return undefined; } + return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo, typeChecker); } - function prepareRangeContainsErrorFunction(errors, originalRange) { - if (!errors.length) { - return rangeHasNoErrors; + SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function createJavaScriptSignatureHelpItems(argumentInfo, program) { + if (argumentInfo.invocation.kind !== 175) { + return undefined; } - var sorted = errors - .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) - .sort(function (e1, e2) { return e1.start - e2.start; }); - if (!sorted.length) { - return rangeHasNoErrors; + var callExpression = argumentInfo.invocation; + var expression = callExpression.expression; + var name = expression.kind === 70 + ? expression + : expression.kind === 173 + ? expression.name + : undefined; + if (!name || !name.text) { + return undefined; } - var index = 0; - return function (r) { - while (true) { - if (index >= sorted.length) { - return false; - } - var error = sorted[index]; - if (r.end <= error.start) { - return false; - } - if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { - return true; + var typeChecker = program.getTypeChecker(); + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var nameToDeclarations = sourceFile.getNamedDeclarations(); + var declarations = nameToDeclarations[name.text]; + if (declarations) { + for (var _b = 0, declarations_10 = declarations; _b < declarations_10.length; _b++) { + var declaration = declarations_10[_b]; + var symbol = declaration.symbol; + if (symbol) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); + if (type) { + var callSignatures = type.getCallSignatures(); + if (callSignatures && callSignatures.length) { + return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo, typeChecker); + } + } + } } - index++; } - }; - function rangeHasNoErrors(r) { - return false; } } - function getScanStartPosition(enclosingNode, originalRange, sourceFile) { - var start = enclosingNode.getStart(sourceFile); - if (start === originalRange.pos && enclosingNode.end === originalRange.end) { - return start; + function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { + if (node.parent.kind === 175 || node.parent.kind === 176) { + var callExpression = node.parent; + if (node.kind === 26 || + node.kind === 18) { + var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + ts.Debug.assert(list !== undefined); + return { + kind: isTypeArgList ? 0 : 1, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list, sourceFile), + argumentIndex: 0, + argumentCount: getArgumentCount(list) + }; + } + var listItemInfo = ts.findListItemInfo(node); + if (listItemInfo) { + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + var argumentIndex = getArgumentIndex(list, node); + var argumentCount = getArgumentCount(list); + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: isTypeArgList ? 0 : 1, + invocation: callExpression, + argumentsSpan: getApplicableSpanForArguments(list, sourceFile), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + return undefined; } - var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); - if (!precedingToken) { - return enclosingNode.pos; + else if (node.kind === 12 && node.parent.kind === 177) { + if (ts.isInsideTemplateLiteral(node, position)) { + return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); + } } - if (precedingToken.end >= originalRange.pos) { - return enclosingNode.pos; + else if (node.kind === 13 && node.parent.parent.kind === 177) { + var templateExpression = node.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 190); + var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - return precedingToken.end; + else if (node.parent.kind === 198 && node.parent.parent.parent.kind === 177) { + var templateSpan = node.parent; + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + ts.Debug.assert(templateExpression.kind === 190); + if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { + return undefined; + } + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); + } + return undefined; } - function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1; - var child; - while (n) { - var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 && line !== previousLine) { + function getArgumentIndex(argumentsList, node) { + var argumentIndex = 0; + var listChildren = argumentsList.getChildren(); + for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { + var child = listChildren_1[_i]; + if (child === node) { break; } - if (formatting.SmartIndenter.shouldIndentChildNode(n, child)) { - return options.indentSize; + if (child.kind !== 25) { + argumentIndex++; } - previousLine = line; - child = n; - n = n.parent; } - return 0; + return argumentIndex; } - function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); - var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); - var previousRangeHasError; - var previousRange; - var previousParent; - var previousRangeStartLine; - var lastIndentedLine; - var indentationOnLastIndentedLine; - var edits = []; - formattingScanner.advance(); - if (formattingScanner.isOnToken()) { - var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; - var undecoratedStartLine = startLine; - if (enclosingNode.decorators) { - undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; + function getArgumentCount(argumentsList) { + var listChildren = argumentsList.getChildren(); + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25) { + argumentCount++; + } + return argumentCount; + } + function getArgumentIndexForTemplatePiece(spanIndex, node, position) { + ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); + if (ts.isTemplateLiteralKind(node.kind)) { + if (ts.isInsideTemplateLiteral(node, position)) { + return 0; } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); - processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); + return spanIndex + 2; } - if (!formattingScanner.isOnToken()) { - var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); - if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, undefined); - trimTrailingWhitespacesForRemainingRange(); + return spanIndex + 1; + } + function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { + var argumentCount = tagExpression.template.kind === 12 + ? 1 + : tagExpression.template.templateSpans.length + 1; + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + kind: 2, + invocation: tagExpression, + argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + function getApplicableSpanForArguments(argumentsList, sourceFile) { + var applicableSpanStart = argumentsList.getFullStart(); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false); + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getApplicableSpanForTaggedTemplate(taggedTemplate, sourceFile) { + var template = taggedTemplate.template; + var applicableSpanStart = template.getStart(); + var applicableSpanEnd = template.getEnd(); + if (template.kind === 190) { + var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (lastSpan.literal.getFullWidth() === 0) { + applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); } } - formattingScanner.close(); - return edits; - function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { - if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || - ts.rangeContainsStartEnd(range, startPos, endPos)) { - if (inheritedIndentation !== -1) { - return inheritedIndentation; - } + return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + function getContainingArgumentInfo(node, position, sourceFile) { + for (var n = node; n.kind !== 256; n = n.parent) { + if (ts.isFunctionBlock(n)) { + return undefined; } - else { - var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; - var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); - var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); - if (startLine !== parentStartLine || startPos === column) { - var baseIndentSize = formatting.SmartIndenter.getBaseIndentation(options); - return baseIndentSize > column ? baseIndentSize : column; - } + if (n.pos < n.parent.pos || n.end > n.parent.end) { + ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); + } + var argumentInfo = getImmediatelyContainingArgumentInfo(n, position, sourceFile); + if (argumentInfo) { + return argumentInfo; } - return -1; } - function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { - var indentation = inheritedIndentation; - var delta = formatting.SmartIndenter.shouldIndentChildNode(node) ? options.indentSize : 0; - if (effectiveParentStartLine === startLine) { - indentation = startLine === lastIndentedLine - ? indentationOnLastIndentedLine - : parentDynamicIndentation.getIndentation(); - delta = Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta); + return undefined; + } + SignatureHelp.getContainingArgumentInfo = getContainingArgumentInfo; + function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { + var children = parent.getChildren(sourceFile); + var indexOfOpenerToken = children.indexOf(openerToken); + ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); + return children[indexOfOpenerToken + 1]; + } + function selectBestInvalidOverloadIndex(candidates, argumentCount) { + var maxParamsSignatureIndex = -1; + var maxParams = -1; + for (var i = 0; i < candidates.length; i++) { + var candidate = candidates[i]; + if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { + return i; } - else if (indentation === -1) { - if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(node); - } + if (candidate.parameters.length > maxParams) { + maxParams = candidate.parameters.length; + maxParamsSignatureIndex = i; } - return { - indentation: indentation, - delta: delta - }; } - function getFirstNonDecoratorTokenOfNode(node) { - if (node.modifiers && node.modifiers.length) { - return node.modifiers[0].kind; + return maxParamsSignatureIndex; + } + function createSignatureHelpItems(candidates, bestSignature, argumentListInfo, typeChecker) { + var applicableSpan = argumentListInfo.argumentsSpan; + var isTypeParameterList = argumentListInfo.kind === 0; + var invocation = argumentListInfo.invocation; + var callTarget = ts.getInvokedExpression(invocation); + var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); + var items = ts.map(candidates, function (candidateSignature) { + var signatureHelpParameters; + var prefixDisplayParts = []; + var suffixDisplayParts = []; + if (callTargetDisplayParts) { + ts.addRange(prefixDisplayParts, callTargetDisplayParts); } - switch (node.kind) { - case 221: return 73; - case 222: return 107; - case 220: return 87; - case 224: return 224; - case 149: return 123; - case 150: return 131; - case 147: - if (node.asteriskToken) { - return 37; - } - case 145: - case 142: - return node.name.kind; + if (isTypeParameterList) { + prefixDisplayParts.push(ts.punctuationPart(26)); + var typeParameters = candidateSignature.typeParameters; + signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(28)); + var parameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); + }); + ts.addRange(suffixDisplayParts, parameterParts); + } + else { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); + }); + ts.addRange(prefixDisplayParts, typeParameterParts); + prefixDisplayParts.push(ts.punctuationPart(18)); + var parameters = candidateSignature.parameters; + signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; + suffixDisplayParts.push(ts.punctuationPart(19)); } + var returnTypeParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); + }); + ts.addRange(suffixDisplayParts, returnTypeParts); + return { + isVariadic: candidateSignature.hasRestParameter, + prefixDisplayParts: prefixDisplayParts, + suffixDisplayParts: suffixDisplayParts, + separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], + parameters: signatureHelpParameters, + documentation: candidateSignature.getDocumentationComment() + }; + }); + var argumentIndex = argumentListInfo.argumentIndex; + var argumentCount = argumentListInfo.argumentCount; + var selectedItemIndex = candidates.indexOf(bestSignature); + if (selectedItemIndex < 0) { + selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); } - function getDynamicIndentation(node, nodeStartLine, indentation, delta) { + ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); + return { + items: items, + applicableSpan: applicableSpan, + selectedItemIndex: selectedItemIndex, + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + function createSignatureHelpParameterForParameter(parameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); + }); return { - getIndentationForComment: function (kind, tokenIndentation, container) { - switch (kind) { - case 16: - case 20: - case 18: - return indentation + getEffectiveDelta(delta, container); - } - return tokenIndentation !== -1 ? tokenIndentation : indentation; - }, - getIndentationForToken: function (line, kind, container) { - if (nodeStartLine !== line && node.decorators) { - if (kind === getFirstNonDecoratorTokenOfNode(node)) { - return indentation; - } - } - switch (kind) { - case 15: - case 16: - case 19: - case 20: - case 17: - case 18: - case 80: - case 104: - case 55: - return indentation; - default: - return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; - } - }, - getIndentation: function () { return indentation; }, - getDelta: function (child) { return getEffectiveDelta(delta, child); }, - recomputeIndentation: function (lineAdded) { - if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent, node)) { - if (lineAdded) { - indentation += options.indentSize; - } - else { - indentation -= options.indentSize; - } - if (formatting.SmartIndenter.shouldIndentChildNode(node)) { - delta = options.indentSize; - } - else { - delta = 0; - } - } - } + name: parameter.name, + documentation: parameter.getDocumentationComment(), + displayParts: displayParts, + isOptional: typeChecker.isOptionalParameter(parameter.valueDeclaration) }; - function getEffectiveDelta(delta, child) { - return formatting.SmartIndenter.nodeWillIndentChild(node, child, true) ? delta : 0; - } } - function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { - if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { - return; - } - var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); - var childContextNode = contextNode; - ts.forEachChild(node, function (child) { - processChildNode(child, -1, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); - }, function (nodes) { - processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); + function createSignatureHelpParameterForTypeParameter(typeParameter) { + var displayParts = ts.mapToDisplayParts(function (writer) { + return typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); }); - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > node.end) { - break; - } - consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); + return { + name: typeParameter.symbol.name, + documentation: emptyArray, + displayParts: displayParts, + isOptional: false + }; + } + } + })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var SymbolDisplay; + (function (SymbolDisplay) { + function getSymbolKind(typeChecker, symbol, location) { + var flags = symbol.getFlags(); + if (flags & 32) + return ts.getDeclarationOfKind(symbol, 193) ? + ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; + if (flags & 384) + return ts.ScriptElementKind.enumElement; + if (flags & 524288) + return ts.ScriptElementKind.typeElement; + if (flags & 64) + return ts.ScriptElementKind.interfaceElement; + if (flags & 262144) + return ts.ScriptElementKind.typeParameterElement; + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); + if (result === ts.ScriptElementKind.unknown) { + if (flags & 262144) + return ts.ScriptElementKind.typeParameterElement; + if (flags & 8) + return ts.ScriptElementKind.variableElement; + if (flags & 8388608) + return ts.ScriptElementKind.alias; + if (flags & 1536) + return ts.ScriptElementKind.moduleElement; + } + return result; + } + SymbolDisplay.getSymbolKind = getSymbolKind; + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location) { + if (typeChecker.isUndefinedSymbol(symbol)) { + return ts.ScriptElementKind.variableElement; + } + if (typeChecker.isArgumentsSymbol(symbol)) { + return ts.ScriptElementKind.localVariableElement; + } + if (location.kind === 98 && ts.isExpression(location)) { + return ts.ScriptElementKind.parameterElement; + } + if (flags & 3) { + if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { + return ts.ScriptElementKind.parameterElement; } - function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { - var childStartPos = child.getStart(sourceFile); - var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; - var undecoratedChildStartLine = childStartLine; - if (child.decorators) { - undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; - } - var childIndentationAmount = -1; - if (isListItem) { - childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1) { - inheritedIndentation = childIndentationAmount; + else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { + return ts.ScriptElementKind.constElement; + } + else if (ts.forEach(symbol.declarations, ts.isLet)) { + return ts.ScriptElementKind.letElement; + } + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; + } + if (flags & 16) + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; + if (flags & 32768) + return ts.ScriptElementKind.memberGetAccessorElement; + if (flags & 65536) + return ts.ScriptElementKind.memberSetAccessorElement; + if (flags & 8192) + return ts.ScriptElementKind.memberFunctionElement; + if (flags & 16384) + return ts.ScriptElementKind.constructorImplementationElement; + if (flags & 4) { + if (flags & 268435456) { + var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { + var rootSymbolFlags = rootSymbol.getFlags(); + if (rootSymbolFlags & (98308 | 3)) { + return ts.ScriptElementKind.memberVariableElement; } - } - if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { - if (child.end < originalRange.pos) { - formattingScanner.skipToEndOf(child); + ts.Debug.assert(!!(rootSymbolFlags & 8192)); + }); + if (!unionPropertyKind) { + var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (typeOfUnionProperty.getCallSignatures().length) { + return ts.ScriptElementKind.memberFunctionElement; } - return inheritedIndentation; - } - if (child.getFullWidth() === 0) { - return inheritedIndentation; + return ts.ScriptElementKind.memberVariableElement; } - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(node); - if (tokenInfo.token.end > childStartPos) { - break; + return unionPropertyKind; + } + return ts.ScriptElementKind.memberVariableElement; + } + return ts.ScriptElementKind.unknown; + } + function getSymbolModifiers(symbol) { + return symbol && symbol.declarations && symbol.declarations.length > 0 + ? ts.getNodeModifiers(symbol.declarations[0]) + : ts.ScriptElementKindModifier.none; + } + SymbolDisplay.getSymbolModifiers = getSymbolModifiers; + function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { + if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } + var displayParts = []; + var documentation; + var symbolFlags = symbol.flags; + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); + var hasAddedSymbolInfo; + var isThisExpression = location.kind === 98 && ts.isExpression(location); + var type; + if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { + if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { + symbolKind = ts.ScriptElementKind.memberVariableElement; + } + var signature = void 0; + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (type) { + if (location.parent && location.parent.kind === 173) { + var right = location.parent.name; + if (right === location || (right && right.getFullWidth() === 0)) { + location = location.parent; } - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); - } - if (!formattingScanner.isOnToken()) { - return inheritedIndentation; } - if (ts.isToken(child)) { - var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); - consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); - return inheritedIndentation; + var callExpression = void 0; + if (location.kind === 175 || location.kind === 176) { + callExpression = location; } - var effectiveParentStartLine = child.kind === 143 ? childStartLine : undecoratedParentStartLine; - var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); - processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - childContextNode = node; - if (isFirstListItem && parent.kind === 170 && inheritedIndentation === -1) { - inheritedIndentation = childIndentation.indentation; + else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { + callExpression = location.parent; } - return inheritedIndentation; - } - function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { - var listStartToken = getOpenTokenForList(parent, nodes); - var listEndToken = getCloseTokenForOpenToken(listStartToken); - var listDynamicIndentation = parentDynamicIndentation; - var startLine = parentStartLine; - if (listStartToken !== 0) { - while (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.end > nodes.pos) { - break; + if (callExpression) { + var candidateSignatures = []; + signature = typeChecker.getResolvedSignature(callExpression, candidateSignatures); + if (!signature && candidateSignatures.length) { + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; + var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 32)) { + symbolKind = ts.ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (tokenInfo.token.kind === listStartToken) { - 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); + else if (symbolFlags & 8388608) { + symbolKind = ts.ScriptElementKind.alias; + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(93)); + displayParts.push(ts.spacePart()); + } + addFullSymbolName(symbol); } else { - consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + addPrefixForAnyFunctionOrVar(symbol, symbolKind); } - } - } - var inheritedIndentation = -1; - for (var i = 0; i < nodes.length; i++) { - var child = nodes[i]; - inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true, i === 0); - } - if (listEndToken !== 0) { - if (formattingScanner.isOnToken()) { - var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { - consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + switch (symbolKind) { + case ts.ScriptElementKind.memberVariableElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.parameterElement: + case ts.ScriptElementKind.localVariableElement: + displayParts.push(ts.punctuationPart(55)); + displayParts.push(ts.spacePart()); + if (useConstructSignatures) { + displayParts.push(ts.keywordPart(93)); + displayParts.push(ts.spacePart()); + } + if (!(type.flags & 2097152) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); + } + addSignatureDisplayParts(signature, allSignatures, 8); + break; + default: + addSignatureDisplayParts(signature, allSignatures); } + hasAddedSymbolInfo = true; } } - } - function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container) { - ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); - var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); - var indentToken = false; - if (currentTokenInfo.leadingTrivia) { - processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); - } - var lineAdded; - var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); - var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); - if (isTokenInRange) { - var rangeHasError = rangeContainsError(currentTokenInfo.token); - var savePreviousRange = previousRange; - lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); - if (rangeHasError) { - indentToken = false; + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || + (location.kind === 122 && location.parent.kind === 149)) { + var functionDeclaration = location.parent; + var allSignatures = functionDeclaration.kind === 149 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { - if (lineAdded !== undefined) { - indentToken = lineAdded; - } - else { - var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; - indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; - } + signature = allSignatures[0]; } - } - if (currentTokenInfo.trailingTrivia) { - processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); - } - if (indentToken) { - var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? - dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) : - -1; - var indentNextTokenOrTrivia = true; - if (currentTokenInfo.leadingTrivia) { - var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); - for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { - var triviaItem = _a[_i]; - var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); - switch (triviaItem.kind) { - case 3: - if (triviaInRange) { - indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); - } - indentNextTokenOrTrivia = false; - break; - case 2: - if (indentNextTokenOrTrivia && triviaInRange) { - insertIndentation(triviaItem.pos, commentIndentation, false); - } - indentNextTokenOrTrivia = false; - break; - case 4: - indentNextTokenOrTrivia = true; - break; - } - } + if (functionDeclaration.kind === 149) { + symbolKind = ts.ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - if (tokenIndentation !== -1 && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); - lastIndentedLine = tokenStart.line; - indentationOnLastIndentedLine = tokenIndentation; + else { + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 && + !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; } - formattingScanner.advance(); - childContextNode = parent; } } - function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { - var triviaItem = trivia_1[_i]; - if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { - var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); - processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); - } + if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { + if (ts.getDeclarationOfKind(symbol, 193)) { + pushTypePart(ts.ScriptElementKind.localClassElement); + } + else { + displayParts.push(ts.keywordPart(74)); } + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); } - function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { - var rangeHasError = rangeContainsError(range); - var lineAdded; - if (!rangeHasError && !previousRangeHasError) { - if (!previousRange) { - var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); - trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); - } - else { - lineAdded = - processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); - } + if ((symbolFlags & 64) && (semanticMeaning & 2)) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(108)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if (symbolFlags & 524288) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(135)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.spacePart()); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512)); + } + if (symbolFlags & 384) { + addNewLineIfDisplayPartsExist(); + if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { + displayParts.push(ts.keywordPart(75)); + displayParts.push(ts.spacePart()); } - previousRange = range; - previousParent = parent; - previousRangeStartLine = rangeStart.line; - previousRangeHasError = rangeHasError; - return lineAdded; + displayParts.push(ts.keywordPart(82)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); } - function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { - formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = rulesProvider.getRulesMap().GetRule(formattingContext); - var trimTrailingWhitespaces; - var lineAdded; - if (rule) { - applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - if (rule.Operation.Action & (2 | 8) && currentStartLine !== previousStartLine) { - lineAdded = false; - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(false); + if (symbolFlags & 1536) { + addNewLineIfDisplayPartsExist(); + var declaration = ts.getDeclarationOfKind(symbol, 226); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70; + displayParts.push(ts.keywordPart(isNamespace ? 127 : 126)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + } + if ((symbolFlags & 262144) && (semanticMeaning & 2)) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(91)); + displayParts.push(ts.spacePart()); + if (symbol.parent) { + addFullSymbolName(symbol.parent, enclosingDeclaration); + writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); + } + else { + var declaration = ts.getDeclarationOfKind(symbol, 142); + ts.Debug.assert(declaration !== undefined); + declaration = declaration.parent; + if (declaration) { + if (ts.isFunctionLikeKind(declaration.kind)) { + var signature = typeChecker.getSignatureFromDeclaration(declaration); + if (declaration.kind === 153) { + displayParts.push(ts.keywordPart(93)); + displayParts.push(ts.spacePart()); + } + else if (declaration.kind !== 152 && declaration.name) { + addFullSymbolName(declaration.symbol); + } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - } - else if (rule.Operation.Action & 4 && currentStartLine === previousStartLine) { - lineAdded = true; - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(true); + else { + displayParts.push(ts.keywordPart(135)); + displayParts.push(ts.spacePart()); + addFullSymbolName(declaration.symbol); + writeTypeParametersOfSymbol(declaration.symbol, sourceFile); } } - trimTrailingWhitespaces = !(rule.Operation.Action & 8) && rule.Flag !== 1; - } - else { - trimTrailingWhitespaces = true; - } - if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { - trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); } - return lineAdded; } - function insertIndentation(pos, indentation, lineAdded) { - var indentationString = getIndentationString(indentation, options); - if (lineAdded) { - recordReplace(pos, 0, indentationString); - } - else { - var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); - var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); - if (indentation !== tokenStart.character || indentationIsDifferent(indentationString, startLinePosition)) { - recordReplace(startLinePosition, tokenStart.character, indentationString); + if (symbolFlags & 8) { + addPrefixForAnyFunctionOrVar(symbol, "enum member"); + var declaration = symbol.declarations[0]; + if (declaration.kind === 255) { + var constantValue = typeChecker.getConstantValue(declaration); + if (constantValue !== undefined) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } } } - function indentationIsDifferent(indentationString, startLinePosition) { - return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); - } - function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { - var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; - var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; - var parts; - if (startLine === endLine) { - if (!firstLineIsIndented) { - insertIndentation(commentRange.pos, indentation, false); - } - return; + if (symbolFlags & 8388608) { + addNewLineIfDisplayPartsExist(); + if (symbol.declarations[0].kind === 229) { + displayParts.push(ts.keywordPart(83)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(127)); } else { - parts = []; - var startPos = commentRange.pos; - for (var line = startLine; line < endLine; line++) { - var endOfLine = ts.getEndLinePosition(line, sourceFile); - parts.push({ pos: startPos, end: endOfLine }); - startPos = ts.getStartPositionOfLine(line + 1, sourceFile); - } - parts.push({ pos: startPos, end: commentRange.end }); - } - var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); - if (indentation === nonWhitespaceColumnInFirstPart.column) { - return; + displayParts.push(ts.keywordPart(90)); } - var startIndex = 0; - if (firstLineIsIndented) { - startIndex = 1; - startLine++; - } - var delta = indentation - nonWhitespaceColumnInFirstPart.column; - for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { - var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); - var nonWhitespaceCharacterAndColumn = i === 0 - ? nonWhitespaceColumnInFirstPart - : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; - if (newIndentation > 0) { - var indentationString = getIndentationString(newIndentation, options); - recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 230) { + var importEqualsDeclaration = declaration; + if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(130)); + displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(19)); + } + else { + var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); + if (internalAliasSymbol) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.spacePart()); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } + } + return true; } - else { - recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); + }); + } + if (!hasAddedSymbolInfo) { + if (symbolKind !== ts.ScriptElementKind.unknown) { + if (type) { + if (isThisExpression) { + addNewLineIfDisplayPartsExist(); + displayParts.push(ts.keywordPart(98)); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolFlags & 3 || + symbolKind === ts.ScriptElementKind.localVariableElement || + isThisExpression) { + displayParts.push(ts.punctuationPart(55)); + displayParts.push(ts.spacePart()); + if (type.symbol && type.symbol.flags & 262144) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); + } + else { + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + } + } + else if (symbolFlags & 16 || + symbolFlags & 8192 || + symbolFlags & 16384 || + symbolFlags & 131072 || + symbolFlags & 98304 || + symbolKind === ts.ScriptElementKind.memberFunctionElement) { + var allSignatures = type.getNonNullableType().getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); + } } } + else { + symbolKind = getSymbolKind(typeChecker, symbol, location); + } } - function trimTrailingWhitespacesForLines(line1, line2, range) { - for (var line = line1; line < line2; line++) { - var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); - var lineEndPosition = ts.getEndLinePosition(line, sourceFile); - if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { - continue; - } - var whitespaceStart = getTrailingWhitespaceStartPosition(lineStartPosition, lineEndPosition); - if (whitespaceStart !== -1) { - ts.Debug.assert(whitespaceStart === lineStartPosition || !ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(whitespaceStart - 1))); - recordDelete(whitespaceStart, lineEndPosition + 1 - whitespaceStart); + 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 === 256; })) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (!declaration.parent || declaration.parent.kind !== 188) { + continue; + } + var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); + if (!rhsSymbol) { + continue; + } + documentation = rhsSymbol.getDocumentationComment(); + if (documentation.length > 0) { + break; + } + } } } } - function getTrailingWhitespaceStartPosition(start, end) { - var pos = end; - while (pos >= start && ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(pos))) { - pos--; - } - if (pos !== end) { - return pos + 1; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + function addNewLineIfDisplayPartsExist() { + if (displayParts.length) { + displayParts.push(ts.lineBreakPart()); } - return -1; - } - function trimTrailingWhitespacesForRemainingRange() { - var startPosition = previousRange ? previousRange.end : originalRange.pos; - var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; - var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; - trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); } - function newTextChange(start, len, newText) { - return { span: ts.createTextSpan(start, len), newText: newText }; - } - function recordDelete(start, len) { - if (len) { - edits.push(newTextChange(start, len, "")); - } + function addFullSymbolName(symbol, enclosingDeclaration) { + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2); + ts.addRange(displayParts, fullSymbolDisplayParts); } - function recordReplace(start, len, newText) { - if (len || newText) { - edits.push(newTextChange(start, len, newText)); + function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { + addNewLineIfDisplayPartsExist(); + if (symbolKind) { + pushTypePart(symbolKind); + displayParts.push(ts.spacePart()); + addFullSymbolName(symbol); } } - function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { - switch (rule.Operation.Action) { - case 1: + function pushTypePart(symbolKind) { + switch (symbolKind) { + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.functionElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.constructorImplementationElement: + displayParts.push(ts.textOrKeywordPart(symbolKind)); + return; + default: + displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(19)); return; - case 8: - if (previousRange.end !== currentRange.pos) { - recordDelete(previousRange.end, currentRange.pos - previousRange.end); - } - break; - case 4: - if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { - return; - } - var lineDelta = currentStartLine - previousStartLine; - if (lineDelta !== 1) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.newLineCharacter); - } - break; - case 2: - if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { - return; - } - var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - } - break; } } - } - function getOpenTokenForList(node, list) { - switch (node.kind) { - case 148: - case 220: - case 179: - case 147: - case 146: - case 180: - if (node.typeParameters === list) { - return 25; - } - else if (node.parameters === list) { - return 17; - } - break; - case 174: - case 175: - if (node.typeArguments === list) { - return 25; - } - else if (node.arguments === list) { - return 17; - } - break; - case 155: - if (node.typeArguments === list) { - return 25; - } + function addSignatureDisplayParts(signature, allSignatures, flags) { + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); + if (allSignatures.length > 1) { + displayParts.push(ts.spacePart()); + displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.operatorPart(36)); + displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); + displayParts.push(ts.punctuationPart(19)); + } + documentation = signature.getDocumentationComment(); } - return 0; - } - function getCloseTokenForOpenToken(kind) { - switch (kind) { - case 17: - return 18; - case 25: - return 27; + function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { + var typeParameterParts = ts.mapToDisplayParts(function (writer) { + typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); + }); + ts.addRange(displayParts, typeParameterParts); } - return 0; } - var internedSizes; - var internedTabsIndentation; - var internedSpacesIndentation; - function getIndentationString(indentation, options) { - var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.tabSize || internedSizes.indentSize !== options.indentSize); - if (resetInternedStrings) { - internedSizes = { tabSize: options.tabSize, indentSize: options.indentSize }; - internedTabsIndentation = internedSpacesIndentation = undefined; + SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind; + function isLocalVariableOrFunction(symbol) { + if (symbol.parent) { + return false; } - if (!options.convertTabsToSpaces) { - var tabs = Math.floor(indentation / options.tabSize); - var spaces = indentation - tabs * options.tabSize; - var tabString = void 0; - if (!internedTabsIndentation) { - internedTabsIndentation = []; - } - if (internedTabsIndentation[tabs] === undefined) { - internedTabsIndentation[tabs] = tabString = repeat("\t", tabs); + return ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 180) { + return true; } - else { - tabString = internedTabsIndentation[tabs]; + if (declaration.kind !== 219 && declaration.kind !== 221) { + return false; } - return spaces ? tabString + repeat(" ", spaces) : tabString; - } - else { - var spacesString = void 0; - var quotient = Math.floor(indentation / options.indentSize); - var remainder = indentation % options.indentSize; - if (!internedSpacesIndentation) { - internedSpacesIndentation = []; + for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { + if (parent_23.kind === 256 || parent_23.kind === 227) { + return false; + } } - if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.indentSize * quotient); - internedSpacesIndentation[quotient] = spacesString; + return true; + }); + } + })(SymbolDisplay = ts.SymbolDisplay || (ts.SymbolDisplay = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function transpileModule(input, transpileOptions) { + var diagnostics = []; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); + options.isolatedModules = true; + options.suppressOutputPathCheck = true; + options.allowNonTsExtensions = true; + options.noLib = true; + options.lib = undefined; + options.types = undefined; + options.noEmit = undefined; + options.noEmitOnError = undefined; + options.paths = undefined; + options.rootDirs = undefined; + options.declaration = undefined; + options.declarationDir = undefined; + options.out = undefined; + options.outFile = undefined; + options.noResolve = true; + var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var sourceFile = ts.createSourceFile(inputFileName, input, options.target); + if (transpileOptions.moduleName) { + sourceFile.moduleName = transpileOptions.moduleName; + } + if (transpileOptions.renamedDependencies) { + sourceFile.renamedDependencies = ts.createMap(transpileOptions.renamedDependencies); + } + var newLine = ts.getNewLineCharacter(options); + var outputText; + var sourceMapText; + var compilerHost = { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { + if (ts.fileExtensionIs(name, ".map")) { + ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); + sourceMapText = text; } else { - spacesString = internedSpacesIndentation[quotient]; + ts.Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: '" + name + "'"); + outputText = text; } - return remainder ? spacesString + repeat(" ", remainder) : spacesString; + }, + getDefaultLibFileName: function () { return "lib.d.ts"; }, + useCaseSensitiveFileNames: function () { return false; }, + getCanonicalFileName: function (fileName) { return fileName; }, + getCurrentDirectory: function () { return ""; }, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return fileName === inputFileName; }, + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } + }; + var program = ts.createProgram([inputFileName], options, compilerHost); + if (transpileOptions.reportDiagnostics) { + ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile)); + ts.addRange(diagnostics, program.getOptionsDiagnostics()); + } + program.emit(); + ts.Debug.assert(outputText !== undefined, "Output generation failed"); + return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; + } + ts.transpileModule = transpileModule; + function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { + var output = transpileModule(input, { compilerOptions: compilerOptions, fileName: fileName, reportDiagnostics: !!diagnostics, moduleName: moduleName }); + ts.addRange(diagnostics, output.diagnostics); + return output.outputText; + } + ts.transpile = transpile; + var commandLineOptionsStringToEnum; + function fixupCompilerOptions(options, diagnostics) { + commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { + return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); + }); + options = ts.clone(options); + var _loop_2 = function (opt) { + if (!ts.hasProperty(options, opt.name)) { + return "continue"; } - function repeat(value, count) { - var s = ""; - for (var i = 0; i < count; i++) { - s += value; + var value = options[opt.name]; + if (typeof value === "string") { + options[opt.name] = ts.parseCustomTypeOption(opt, value, diagnostics); + } + else { + if (!ts.forEachProperty(opt.type, function (v) { return v === value; })) { + diagnostics.push(ts.createCompilerDiagnosticForInvalidCustomType(opt)); } - return s; } + }; + for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { + var opt = commandLineOptionsStringToEnum_1[_i]; + _loop_2(opt); } - formatting.getIndentationString = getIndentationString; - })(formatting = ts.formatting || (ts.formatting = {})); + return options; + } })(ts || (ts = {})); var ts; (function (ts) { var formatting; (function (formatting) { - var SmartIndenter; - (function (SmartIndenter) { - function getIndentation(position, sourceFile, options) { - if (position > sourceFile.text.length) { - return getBaseIndentation(options); - } - if (options.indentStyle === ts.IndentStyle.None) { - return 0; - } - var precedingToken = ts.findPrecedingToken(position, sourceFile); - if (!precedingToken) { - return getBaseIndentation(options); - } - var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); - if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { - return 0; + var standardScanner = ts.createScanner(4, false, 0); + var jsxScanner = ts.createScanner(4, false, 1); + var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); + function getFormattingScanner(sourceFile, startPos, endPos) { + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); + scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; + scanner.setText(sourceFile.text); + scanner.setTextPos(startPos); + var wasNewLine = true; + var leadingTrivia; + var trailingTrivia; + var savedPos; + var lastScanAction; + var lastTokenInfo; + return { + advance: advance, + readTokenInfo: readTokenInfo, + isOnToken: isOnToken, + getCurrentLeadingTrivia: function () { return leadingTrivia; }, + lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, + skipToEndOf: skipToEndOf, + close: function () { + ts.Debug.assert(scanner !== undefined); + lastTokenInfo = undefined; + scanner.setText(undefined); + scanner = undefined; } - var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (options.indentStyle === ts.IndentStyle.Block) { - var current_1 = position; - while (current_1 > 0) { - var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char)) { - break; - } - current_1--; + }; + function advance() { + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); + lastTokenInfo = undefined; + var isStarted = scanner.getStartPos() !== startPos; + if (isStarted) { + if (trailingTrivia) { + ts.Debug.assert(trailingTrivia.length !== 0); + wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4; } - var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); - return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); - } - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 187) { - var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; + else { + wasNewLine = false; } } - var previous; - var current = precedingToken; - var currentStart; - var indentationDelta; - while (current) { - if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; - } + leadingTrivia = undefined; + trailingTrivia = undefined; + if (!isStarted) { + scanner.scan(); + } + var pos = scanner.getStartPos(); + while (pos < endPos) { + var t = scanner.getToken(); + if (!ts.isTrivia(t)) { break; } - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation; + scanner.scan(); + var item = { + pos: pos, + end: scanner.getStartPos(), + kind: t + }; + pos = scanner.getStartPos(); + if (!leadingTrivia) { + leadingTrivia = []; } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + options.indentSize; + leadingTrivia.push(item); + } + savedPos = scanner.getStartPos(); + } + function shouldRescanGreaterThanToken(node) { + if (node) { + switch (node.kind) { + case 30: + case 65: + case 66: + case 46: + case 45: + return true; } - previous = current; - current = current.parent; } - if (!current) { - return getBaseIndentation(options); + return false; + } + function shouldRescanJsxIdentifier(node) { + if (node.parent) { + switch (node.parent.kind) { + case 246: + case 244: + case 245: + case 243: + return node.kind === 70; + } } - return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + return false; } - SmartIndenter.getIndentation = getIndentation; - function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { - var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + function shouldRescanJsxText(node) { + return node && node.kind === 10; } - SmartIndenter.getIndentationForNode = getIndentationForNode; - function getBaseIndentation(options) { - return options.baseIndentSize || 0; + function shouldRescanSlashToken(container) { + return container.kind === 11; } - SmartIndenter.getBaseIndentation = getBaseIndentation; - function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { - var parent = current.parent; - var parentStart; - while (parent) { - var useActualIndentation = true; - if (ignoreActualIndentationRange) { - var start = current.getStart(sourceFile); - useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; - } - if (useActualIndentation) { - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - parentStart = getParentStart(parent, current, sourceFile); - var parentAndChildShareLine = parentStart.line === currentStart.line || - childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); - if (useActualIndentation) { - var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); - if (actualIndentation !== -1) { - return actualIndentation + indentationDelta; - } - } - if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { - indentationDelta += options.indentSize; - } - current = parent; - currentStart = parentStart; - parent = current.parent; - } - return indentationDelta + getBaseIndentation(options); - } - function getParentStart(parent, child, sourceFile) { - var containingList = getContainingList(child, sourceFile); - if (containingList) { - return sourceFile.getLineAndCharacterOfPosition(containingList.pos); - } - return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); - } - function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { - var commaItemInfo = ts.findListItemInfo(commaToken); - if (commaItemInfo && commaItemInfo.listItemIndex > 0) { - return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); - } - else { - return -1; - } + function shouldRescanTemplateToken(container) { + return container.kind === 14 || + container.kind === 15; } - function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { - var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 256 || !parentAndChildShareLine); - if (!useActualIndentation) { - return -1; - } - return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); + function startsWithSlashToken(t) { + return t === 40 || t === 62; } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { - var nextToken = ts.findNextToken(precedingToken, current); - if (!nextToken) { - return false; + function readTokenInfo(n) { + ts.Debug.assert(scanner !== undefined); + if (!isOnToken()) { + return { + leadingTrivia: leadingTrivia, + trailingTrivia: undefined, + token: undefined + }; } - if (nextToken.kind === 15) { - return true; + var expectedScanAction = shouldRescanGreaterThanToken(n) + ? 1 + : shouldRescanSlashToken(n) + ? 2 + : shouldRescanTemplateToken(n) + ? 3 + : shouldRescanJsxIdentifier(n) + ? 4 + : shouldRescanJsxText(n) + ? 5 + : 0; + if (lastTokenInfo && expectedScanAction === lastScanAction) { + return fixTokenKind(lastTokenInfo, n); } - else if (nextToken.kind === 16) { - var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + if (scanner.getStartPos() !== savedPos) { + ts.Debug.assert(lastTokenInfo !== undefined); + scanner.setTextPos(savedPos); + scanner.scan(); } - return false; - } - function getStartLineAndCharacterForNode(n, sourceFile) { - return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - } - function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); - ts.Debug.assert(elseKeyword !== undefined); - var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; - return elseKeywordStartLine === childStartLine; + var currentToken = scanner.getToken(); + if (expectedScanAction === 1 && currentToken === 28) { + currentToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 1; } - return false; - } - SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; - function getContainingList(node, sourceFile) { - if (node.parent) { - switch (node.parent.kind) { - case 155: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 171: - return node.parent.properties; - case 170: - return node.parent.elements; - case 220: - case 179: - case 180: - case 147: - case 146: - case 151: - case 152: { - var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; - } - case 175: - case 174: { - var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; - } - } + else if (expectedScanAction === 2 && startsWithSlashToken(currentToken)) { + currentToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === currentToken); + lastScanAction = 2; } - return undefined; - } - function getActualIndentationForListItem(node, sourceFile, options) { - var containingList = getContainingList(node, sourceFile); - return containingList ? getActualIndentationFromList(containingList) : -1; - function getActualIndentationFromList(list) { - var index = ts.indexOf(list, node); - return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; + else if (expectedScanAction === 3 && currentToken === 17) { + currentToken = scanner.reScanTemplateToken(); + lastScanAction = 3; } - } - function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 18) { - return -1; + else if (expectedScanAction === 4 && currentToken === 70) { + currentToken = scanner.scanJsxIdentifier(); + lastScanAction = 4; } - if (node.parent && (node.parent.kind === 174 || - node.parent.kind === 175) && - node.parent.expression !== node) { - var fullCallOrNewExpression = node.parent.expression; - var startingExpression = getStartingExpression(fullCallOrNewExpression); - if (fullCallOrNewExpression === startingExpression) { - return -1; - } - var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); - var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); - if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { - return -1; - } - return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); + else if (expectedScanAction === 5) { + currentToken = scanner.reScanJsxToken(); + lastScanAction = 5; } - return -1; - function getStartingExpression(node) { - while (true) { - switch (node.kind) { - case 174: - case 175: - case 172: - case 173: - node = node.expression; - break; - default: - return node; - } - } + else { + lastScanAction = 0; } - } - function deriveActualIndentationFromList(list, index, sourceFile, options) { - ts.Debug.assert(index >= 0 && index < list.length); - var node = list[index]; - var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); - for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24) { - continue; - } - var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; - if (prevEndLine !== lineAndCharacter.line) { - return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); - } - lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); + var token = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + if (trailingTrivia) { + trailingTrivia = undefined; } - return -1; - } - function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { - var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); - return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); - } - function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { - var character = 0; - var column = 0; - for (var pos = startPos; pos < endPos; pos++) { - var ch = sourceFile.text.charCodeAt(pos); - if (!ts.isWhiteSpaceSingleLine(ch)) { + while (scanner.getStartPos() < endPos) { + currentToken = scanner.scan(); + if (!ts.isTrivia(currentToken)) { break; } - if (ch === 9) { - column += options.tabSize + (column % options.tabSize); + var trivia = { + pos: scanner.getStartPos(), + end: scanner.getTextPos(), + kind: currentToken + }; + if (!trailingTrivia) { + trailingTrivia = []; } - else { - column++; + trailingTrivia.push(trivia); + if (currentToken === 4) { + scanner.scan(); + break; } - character++; } - return { column: column, character: character }; - } - SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; - function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { - return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; + lastTokenInfo = { + leadingTrivia: leadingTrivia, + trailingTrivia: trailingTrivia, + token: token + }; + return fixTokenKind(lastTokenInfo, n); } - SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 202: - case 221: - case 192: - case 222: - case 224: - case 223: - case 170: - case 199: - case 226: - case 171: - case 159: - case 161: - case 227: - case 250: - case 249: - case 178: - case 172: - case 174: - case 175: - case 200: - case 218: - case 235: - case 211: - case 188: - case 168: - case 167: - case 243: - case 242: - case 248: - case 146: - case 151: - case 152: - case 142: - case 156: - case 157: - case 164: - case 176: - case 184: - case 237: - case 233: - case 238: - case 234: - return true; - } - return false; + function isOnToken() { + ts.Debug.assert(scanner !== undefined); + var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); + var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + return startPos < endPos && current !== 1 && !ts.isTrivia(current); } - function nodeWillIndentChild(parent, child, indentByDefault) { - var childKind = child ? child.kind : 0; - switch (parent.kind) { - case 204: - case 205: - case 207: - case 208: - case 206: - case 203: - case 220: - case 179: - case 147: - case 180: - case 148: - case 149: - case 150: - return childKind !== 199; - case 236: - return childKind !== 237; - case 230: - return childKind !== 231 || - (child.namedBindings && child.namedBindings.kind !== 233); - case 241: - return childKind !== 245; + function fixTokenKind(tokenInfo, container) { + if (ts.isToken(container) && tokenInfo.token.kind !== container.kind) { + tokenInfo.token.kind = container.kind; } - return indentByDefault; + return tokenInfo; } - SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; - function shouldIndentChildNode(parent, child) { - return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, false); + function skipToEndOf(node) { + scanner.setTextPos(node.end); + savedPos = scanner.getStartPos(); + lastScanAction = undefined; + lastTokenInfo = undefined; + wasNewLine = false; + leadingTrivia = undefined; + trailingTrivia = undefined; } - SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; - })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); + } + formatting.getFormattingScanner = getFormattingScanner; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; (function (ts) { - var codefix; - (function (codefix) { - var codeFixes = ts.createMap(); - function registerCodeFix(action) { - ts.forEach(action.errorCodes, function (error) { - var fixes = codeFixes[error]; - if (!fixes) { - fixes = []; - codeFixes[error] = fixes; - } - fixes.push(action); - }); - } - codefix.registerCodeFix = registerCodeFix; - function getSupportedErrorCodes() { - return Object.keys(codeFixes); - } - codefix.getSupportedErrorCodes = getSupportedErrorCodes; - function getFixes(context) { - var fixes = codeFixes[context.errorCode]; - var allActions = []; - ts.forEach(fixes, function (f) { - var actions = f.getCodeActions(context); - if (actions && actions.length > 0) { - allActions = allActions.concat(actions); + var formatting; + (function (formatting) { + var FormattingContext = (function () { + function FormattingContext(sourceFile, formattingRequestKind) { + this.sourceFile = sourceFile; + this.formattingRequestKind = formattingRequestKind; + } + FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { + ts.Debug.assert(currentRange !== undefined, "currentTokenSpan is null"); + ts.Debug.assert(currentTokenParent !== undefined, "currentTokenParent is null"); + ts.Debug.assert(nextRange !== undefined, "nextTokenSpan is null"); + ts.Debug.assert(nextTokenParent !== undefined, "nextTokenParent is null"); + ts.Debug.assert(commonParent !== undefined, "commonParent is null"); + this.currentTokenSpan = currentRange; + this.currentTokenParent = currentTokenParent; + this.nextTokenSpan = nextRange; + this.nextTokenParent = nextTokenParent; + this.contextNode = commonParent; + this.contextNodeAllOnSameLine = undefined; + this.nextNodeAllOnSameLine = undefined; + this.tokensAreOnSameLine = undefined; + this.contextNodeBlockIsOnOneLine = undefined; + this.nextNodeBlockIsOnOneLine = undefined; + }; + FormattingContext.prototype.ContextNodeAllOnSameLine = function () { + if (this.contextNodeAllOnSameLine === undefined) { + this.contextNodeAllOnSameLine = this.NodeIsOnOneLine(this.contextNode); } - }); - return allActions; - } - codefix.getFixes = getFixes; - })(codefix = ts.codefix || (ts.codefix = {})); -})(ts || (ts = {})); -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 !== 121) { - return undefined; + return this.contextNodeAllOnSameLine; + }; + FormattingContext.prototype.NextNodeAllOnSameLine = function () { + if (this.nextNodeAllOnSameLine === undefined) { + this.nextNodeAllOnSameLine = this.NodeIsOnOneLine(this.nextTokenParent); } - 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 } }] }] - }]; - } - }); - codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], - getCodeActions: function (context) { - var sourceFile = context.sourceFile; - var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97) { - return undefined; + return this.nextNodeAllOnSameLine; + }; + FormattingContext.prototype.TokensAreOnSameLine = function () { + if (this.tokensAreOnSameLine === undefined) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line; + this.tokensAreOnSameLine = (startLine === endLine); } - var constructor = ts.getContainingFunction(token); - var superCall = findSuperCall(constructor.body); - if (!superCall) { - return undefined; + return this.tokensAreOnSameLine; + }; + FormattingContext.prototype.ContextNodeBlockIsOnOneLine = function () { + if (this.contextNodeBlockIsOnOneLine === undefined) { + this.contextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.contextNode); } - if (superCall.expression && superCall.expression.kind == 174) { - var arguments_1 = superCall.expression.arguments; - for (var i = 0; i < arguments_1.length; i++) { - if (arguments_1[i].expression === token) { - return undefined; - } - } + return this.contextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NextNodeBlockIsOnOneLine = function () { + if (this.nextNodeBlockIsOnOneLine === undefined) { + this.nextNodeBlockIsOnOneLine = this.BlockIsOnOneLine(this.nextTokenParent); } - var newPosition = getOpenBraceEnd(constructor, sourceFile); - var changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; - return [{ - description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes: changes - }]; - function findSuperCall(n) { - if (n.kind === 202 && ts.isSuperCall(n.expression)) { - return n; - } - if (ts.isFunctionLike(n)) { - return undefined; - } - return ts.forEachChild(n, findSuperCall); + return this.nextNodeBlockIsOnOneLine; + }; + FormattingContext.prototype.NodeIsOnOneLine = function (node) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + return startLine === endLine; + }; + FormattingContext.prototype.BlockIsOnOneLine = function (node) { + var openBrace = ts.findChildOfKind(node, 16, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17, this.sourceFile); + if (openBrace && closeBrace) { + var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; + var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; + return startLine === endLine; } - } - }); - })(codefix = ts.codefix || (ts.codefix = {})); + return false; + }; + return FormattingContext; + }()); + formatting.FormattingContext = FormattingContext; + })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; (function (ts) { - ts.servicesVersion = "0.5"; - function createNode(kind, pos, end, parent) { - var node = kind >= 139 ? new NodeObject(kind, pos, end) : - kind === 69 ? new IdentifierObject(69, pos, end) : - new TokenObject(kind, pos, end); - node.parent = parent; - return node; - } - var NodeObject = (function () { - function NodeObject(kind, pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0; - this.transformFlags = undefined; - this.excludeTransformFlags = undefined; - this.parent = undefined; - this.kind = kind; - } - NodeObject.prototype.getSourceFile = function () { - return ts.getSourceFileOfNode(this); - }; - NodeObject.prototype.getStart = function (sourceFile, includeJsDocComment) { - return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment); - }; - NodeObject.prototype.getFullStart = function () { - return this.pos; - }; - NodeObject.prototype.getEnd = function () { - return this.end; - }; - NodeObject.prototype.getWidth = function (sourceFile) { - return this.getEnd() - this.getStart(sourceFile); - }; - NodeObject.prototype.getFullWidth = function () { - return this.end - this.pos; - }; - NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { - return this.getStart(sourceFile) - this.pos; - }; - NodeObject.prototype.getFullText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); - }; - NodeObject.prototype.getText = function (sourceFile) { - if (!sourceFile) { - sourceFile = this.getSourceFile(); - } - return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd()); - }; - NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end, useJSDocScanner) { - ts.scanner.setTextPos(pos); - while (pos < end) { - var token = useJSDocScanner ? ts.scanner.scanJSDocToken() : ts.scanner.scan(); - var textPos = ts.scanner.getTextPos(); - if (textPos <= end) { - nodes.push(createNode(token, pos, textPos, this)); - } - pos = textPos; + var formatting; + (function (formatting) { + (function (FormattingRequestKind) { + FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; + FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; + FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; + FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; + FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; + })(formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + var FormattingRequestKind = formatting.FormattingRequestKind; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rule = (function () { + function Rule(Descriptor, Operation, Flag) { + if (Flag === void 0) { Flag = 0; } + this.Descriptor = Descriptor; + this.Operation = Operation; + this.Flag = Flag; } - return pos; - }; - NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286, nodes.pos, nodes.end, this); - list._children = []; - var pos = nodes.pos; - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; - if (pos < node.pos) { - pos = this.addSyntheticNodes(list._children, pos, node.pos); - } - list._children.push(node); - pos = node.end; + Rule.prototype.toString = function () { + return "[desc=" + this.Descriptor + "," + + "operation=" + this.Operation + "," + + "flag=" + this.Flag + "]"; + }; + return Rule; + }()); + formatting.Rule = Rule; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(formatting.RuleAction || (formatting.RuleAction = {})); + var RuleAction = formatting.RuleAction; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleDescriptor = (function () { + function RuleDescriptor(LeftTokenRange, RightTokenRange) { + this.LeftTokenRange = LeftTokenRange; + this.RightTokenRange = RightTokenRange; } - if (pos < nodes.end) { - this.addSyntheticNodes(list._children, pos, nodes.end); + RuleDescriptor.prototype.toString = function () { + return "[leftRange=" + this.LeftTokenRange + "," + + "rightRange=" + this.RightTokenRange + "]"; + }; + RuleDescriptor.create1 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create2 = function (left, right) { + return RuleDescriptor.create4(left, formatting.Shared.TokenRange.FromToken(right)); + }; + RuleDescriptor.create3 = function (left, right) { + return RuleDescriptor.create4(formatting.Shared.TokenRange.FromToken(left), right); + }; + RuleDescriptor.create4 = function (left, right) { + return new RuleDescriptor(left, right); + }; + return RuleDescriptor; + }()); + formatting.RuleDescriptor = RuleDescriptor; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(formatting.RuleFlags || (formatting.RuleFlags = {})); + var RuleFlags = formatting.RuleFlags; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperation = (function () { + function RuleOperation(Context, Action) { + this.Context = Context; + this.Action = Action; } - return list; - }; - NodeObject.prototype.createChildren = function (sourceFile) { - var _this = this; - var children; - if (this.kind >= 139) { - ts.scanner.setText((sourceFile || this.getSourceFile()).text); - children = []; - var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 273 && this.kind <= 285; - var processNode = function (node) { - var isJSDocTagNode = ts.isJSDocTag(node); - if (!isJSDocTagNode && pos_3 < node.pos) { - pos_3 = _this.addSyntheticNodes(children, pos_3, node.pos, useJSDocScanner_1); - } - children.push(node); - if (!isJSDocTagNode) { - pos_3 = node.end; - } - }; - var processNodes = function (nodes) { - if (pos_3 < nodes.pos) { - pos_3 = _this.addSyntheticNodes(children, pos_3, nodes.pos, useJSDocScanner_1); - } - children.push(_this.createSyntaxList(nodes)); - pos_3 = nodes.end; - }; - if (this.jsDocComments) { - for (var _i = 0, _a = this.jsDocComments; _i < _a.length; _i++) { - var jsDocComment = _a[_i]; - processNode(jsDocComment); - } - } - pos_3 = this.pos; - ts.forEachChild(this, processNode, processNodes); - if (pos_3 < this.end) { - this.addSyntheticNodes(children, pos_3, this.end); + RuleOperation.prototype.toString = function () { + return "[context=" + this.Context + "," + + "action=" + this.Action + "]"; + }; + RuleOperation.create1 = function (action) { + return RuleOperation.create2(formatting.RuleOperationContext.Any, action); + }; + RuleOperation.create2 = function (context, action) { + return new RuleOperation(context, action); + }; + return RuleOperation; + }()); + formatting.RuleOperation = RuleOperation; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RuleOperationContext = (function () { + function RuleOperationContext() { + var funcs = []; + for (var _i = 0; _i < arguments.length; _i++) { + funcs[_i - 0] = arguments[_i]; } - ts.scanner.setText(undefined); - } - this._children = children || ts.emptyArray; - }; - NodeObject.prototype.getChildCount = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children.length; - }; - NodeObject.prototype.getChildAt = function (index, sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children[index]; - }; - NodeObject.prototype.getChildren = function (sourceFile) { - if (!this._children) - this.createChildren(sourceFile); - return this._children; - }; - NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - if (!children.length) { - return undefined; - } - var child = children[0]; - return child.kind < 139 ? child : child.getFirstToken(sourceFile); - }; - NodeObject.prototype.getLastToken = function (sourceFile) { - var children = this.getChildren(sourceFile); - var child = ts.lastOrUndefined(children); - if (!child) { - return undefined; - } - return child.kind < 139 ? child : child.getLastToken(sourceFile); - }; - return NodeObject; - }()); - var TokenOrIdentifierObject = (function () { - function TokenOrIdentifierObject(pos, end) { - this.pos = pos; - this.end = end; - this.flags = 0; - this.parent = undefined; - } - TokenOrIdentifierObject.prototype.getSourceFile = function () { - return ts.getSourceFileOfNode(this); - }; - TokenOrIdentifierObject.prototype.getStart = function (sourceFile, includeJsDocComment) { - return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment); - }; - TokenOrIdentifierObject.prototype.getFullStart = function () { - return this.pos; - }; - TokenOrIdentifierObject.prototype.getEnd = function () { - return this.end; - }; - TokenOrIdentifierObject.prototype.getWidth = function (sourceFile) { - return this.getEnd() - this.getStart(sourceFile); - }; - TokenOrIdentifierObject.prototype.getFullWidth = function () { - return this.end - this.pos; - }; - TokenOrIdentifierObject.prototype.getLeadingTriviaWidth = function (sourceFile) { - return this.getStart(sourceFile) - this.pos; - }; - TokenOrIdentifierObject.prototype.getFullText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); - }; - TokenOrIdentifierObject.prototype.getText = function (sourceFile) { - return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); - }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { - return 0; - }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { - return undefined; - }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { - return ts.emptyArray; - }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { - return undefined; - }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { - return undefined; - }; - return TokenOrIdentifierObject; - }()); - var SymbolObject = (function () { - function SymbolObject(flags, name) { - this.flags = flags; - this.name = name; - } - SymbolObject.prototype.getFlags = function () { - return this.flags; - }; - SymbolObject.prototype.getName = function () { - return this.name; - }; - SymbolObject.prototype.getDeclarations = function () { - return this.declarations; - }; - SymbolObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4)); - } - return this.documentationComment; - }; - return SymbolObject; - }()); - var TokenObject = (function (_super) { - __extends(TokenObject, _super); - function TokenObject(kind, pos, end) { - var _this = _super.call(this, pos, end) || this; - _this.kind = kind; - return _this; - } - return TokenObject; - }(TokenOrIdentifierObject)); - var IdentifierObject = (function (_super) { - __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { - return _super.call(this, pos, end) || this; - } - return IdentifierObject; - }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69; - var TypeObject = (function () { - function TypeObject(checker, flags) { - this.checker = checker; - this.flags = flags; - } - TypeObject.prototype.getFlags = function () { - return this.flags; - }; - TypeObject.prototype.getSymbol = function () { - return this.symbol; - }; - TypeObject.prototype.getProperties = function () { - return this.checker.getPropertiesOfType(this); - }; - TypeObject.prototype.getProperty = function (propertyName) { - return this.checker.getPropertyOfType(this, propertyName); - }; - TypeObject.prototype.getApparentProperties = function () { - return this.checker.getAugmentedPropertiesOfType(this); - }; - TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0); - }; - TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1); - }; - TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0); - }; - TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1); - }; - TypeObject.prototype.getBaseTypes = function () { - return this.flags & (32768 | 65536) - ? this.checker.getBaseTypes(this) - : undefined; - }; - TypeObject.prototype.getNonNullableType = function () { - return this.checker.getNonNullableType(this); - }; - return TypeObject; - }()); - var SignatureObject = (function () { - function SignatureObject(checker) { - this.checker = checker; - } - SignatureObject.prototype.getDeclaration = function () { - return this.declaration; - }; - SignatureObject.prototype.getTypeParameters = function () { - return this.typeParameters; - }; - SignatureObject.prototype.getParameters = function () { - return this.parameters; - }; - SignatureObject.prototype.getReturnType = function () { - return this.checker.getReturnTypeOfSignature(this); - }; - SignatureObject.prototype.getDocumentationComment = function () { - if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], undefined, false) : []; - } - return this.documentationComment; - }; - return SignatureObject; - }()); - var SourceFileObject = (function (_super) { - __extends(SourceFileObject, _super); - function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; - } - SourceFileObject.prototype.update = function (newText, textChangeRange) { - return ts.updateSourceFile(this, newText, textChangeRange); - }; - SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { - return ts.getLineAndCharacterOfPosition(this, position); - }; - SourceFileObject.prototype.getLineStarts = function () { - return ts.getLineStarts(this); - }; - SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { - return ts.getPositionOfLineAndCharacter(this, line, character); - }; - SourceFileObject.prototype.getNamedDeclarations = function () { - if (!this.namedDeclarations) { - this.namedDeclarations = this.computeNamedDeclarations(); + this.customContextChecks = funcs; } - return this.namedDeclarations; - }; - SourceFileObject.prototype.computeNamedDeclarations = function () { - var result = ts.createMap(); - ts.forEachChild(this, visit); - return result; - function addDeclaration(declaration) { - var name = getDeclarationName(declaration); - if (name) { - ts.multiMapAdd(result, name, declaration); + RuleOperationContext.prototype.IsAny = function () { + return this === RuleOperationContext.Any; + }; + RuleOperationContext.prototype.InContext = function (context) { + if (this.IsAny()) { + return true; } - } - function getDeclarations(name) { - return result[name] || (result[name] = []); - } - function getDeclarationName(declaration) { - if (declaration.name) { - var result_6 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_6 !== undefined) { - return result_6; - } - if (declaration.name.kind === 140) { - var expr = declaration.name.expression; - if (expr.kind === 172) { - return expr.name.text; - } - return getTextOfIdentifierOrLiteral(expr); + for (var _i = 0, _a = this.customContextChecks; _i < _a.length; _i++) { + var check = _a[_i]; + if (!check(context)) { + return false; } } - return undefined; + return true; + }; + return RuleOperationContext; + }()); + RuleOperationContext.Any = new RuleOperationContext(); + formatting.RuleOperationContext = RuleOperationContext; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Rules = (function () { + function Rules() { + this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); + this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + 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.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.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)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70, 3, 74, 83, 90]); + 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.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)); + this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103, 99, 93, 79, 95, 102, 120]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + 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.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)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 132]), 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.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([126, 130]), 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, 126, 127, 111, 113, 112, 132, 114, 135, 137]), 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, 137])), 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)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.FromTokens([19, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.FromTokens([18, 20, 28, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 132, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 38]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119, 88), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70, formatting.Shared.TokenRange.FromTokens([12, 13])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); + 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.HighPriorityCommonRules = [ + this.IgnoreBeforeComment, this.IgnoreAfterLineComment, + this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, + this.NoSpaceAfterQuestionMark, + this.NoSpaceBeforeDot, this.NoSpaceAfterDot, + this.NoSpaceAfterUnaryPrefixOperator, + this.NoSpaceAfterUnaryPreincrementOperator, this.NoSpaceAfterUnaryPredecrementOperator, + this.NoSpaceBeforeUnaryPostincrementOperator, this.NoSpaceBeforeUnaryPostdecrementOperator, + this.SpaceAfterPostincrementWhenFollowedByAdd, + this.SpaceAfterAddWhenFollowedByUnaryPlus, this.SpaceAfterAddWhenFollowedByPreincrement, + this.SpaceAfterPostdecrementWhenFollowedBySubtract, + this.SpaceAfterSubtractWhenFollowedByUnaryMinus, this.SpaceAfterSubtractWhenFollowedByPredecrement, + this.NoSpaceAfterCloseBrace, + this.NewLineBeforeCloseBraceInBlockContext, + this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets, + this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration, + this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember, + this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand, + this.NoSpaceBetweenReturnAndSemicolon, + this.SpaceAfterCertainKeywords, + this.SpaceAfterLetConstInVariableDeclaration, + this.NoSpaceBeforeOpenParenInFuncCall, + this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator, + this.SpaceAfterVoidOperator, + this.SpaceBetweenAsyncAndOpenParen, this.SpaceBetweenAsyncAndFunctionKeyword, + this.NoSpaceBetweenTagAndTemplateString, + this.SpaceBeforeJsxAttribute, this.SpaceBeforeSlashInJsxOpeningElement, this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement, + this.NoSpaceBeforeEqualInJsxAttribute, this.NoSpaceAfterEqualInJsxAttribute, + this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport, + this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords, + this.SpaceAfterModuleName, + this.SpaceBeforeArrow, this.SpaceAfterArrow, + this.NoSpaceAfterEllipsis, + this.NoSpaceAfterOptionalParameters, + this.NoSpaceBetweenEmptyInterfaceBraceBrackets, + this.NoSpaceBeforeOpenAngularBracket, + this.NoSpaceBetweenCloseParenAndAngularBracket, + this.NoSpaceAfterOpenAngularBracket, + this.NoSpaceBeforeCloseAngularBracket, + this.NoSpaceAfterCloseAngularBracket, + this.SpaceBeforeAt, + this.NoSpaceAfterAt, + this.SpaceAfterDecorator, + ]; + this.LowPriorityCommonRules = [ + this.NoSpaceBeforeSemicolon, + this.SpaceBeforeOpenBraceInControl, this.SpaceBeforeOpenBraceInFunction, this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock, + this.NoSpaceBeforeComma, + 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)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); + this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); + this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); } - function getTextOfIdentifierOrLiteral(node) { - if (node) { - if (node.kind === 69 || - node.kind === 9 || - node.kind === 8) { - return node.text; + Rules.prototype.getRuleName = function (rule) { + var o = this; + for (var name_51 in o) { + if (o[name_51] === rule) { + return name_51; } } - return undefined; - } - function visit(node) { - switch (node.kind) { - case 220: - case 179: - case 147: + throw new Error("Unknown rule"); + }; + Rules.IsForContext = function (context) { + return context.contextNode.kind === 207; + }; + Rules.IsNotForContext = function (context) { + return !Rules.IsForContext(context); + }; + Rules.IsBinaryOpContext = function (context) { + switch (context.contextNode.kind) { + case 188: + case 189: + case 196: + case 239: + case 235: + case 155: + case 163: + case 164: + return true; + case 170: + case 224: + case 230: + case 219: + case 143: + case 255: case 146: - var functionDeclaration = node; - var declarationName = getDeclarationName(functionDeclaration); - if (declarationName) { - var declarations = getDeclarations(declarationName); - var lastDeclaration = ts.lastOrUndefined(declarations); - if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { - if (functionDeclaration.body && !lastDeclaration.body) { - declarations[declarations.length - 1] = functionDeclaration; - } - } - else { - declarations.push(functionDeclaration); - } - ts.forEachChild(node, visit); - } - break; + case 145: + return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; + case 208: + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 209: + return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; + } + return false; + }; + Rules.IsNotBinaryOpContext = function (context) { + return !Rules.IsBinaryOpContext(context); + }; + Rules.IsConditionalOperatorContext = function (context) { + return context.contextNode.kind === 189; + }; + Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { + return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); + }; + Rules.IsBeforeMultilineBlockContext = function (context) { + return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); + }; + Rules.IsMultilineBlockContext = function (context) { + return Rules.IsBlockContext(context) && !(context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsSingleLineBlockContext = function (context) { + return Rules.IsBlockContext(context) && (context.ContextNodeAllOnSameLine() || context.ContextNodeBlockIsOnOneLine()); + }; + Rules.IsBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.contextNode); + }; + Rules.IsBeforeBlockContext = function (context) { + return Rules.NodeIsBlockContext(context.nextTokenParent); + }; + Rules.NodeIsBlockContext = function (node) { + if (Rules.NodeIsTypeScriptDeclWithBlockContext(node)) { + return true; + } + switch (node.kind) { + case 200: + case 228: + case 172: + case 227: + return true; + } + return false; + }; + Rules.IsFunctionDeclContext = function (context) { + switch (context.contextNode.kind) { case 221: - case 192: + case 148: + case 147: + case 150: + case 151: + case 152: + case 180: + case 149: + case 181: + case 223: + return true; + } + return false; + }; + Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { + return context.contextNode.kind === 221 || context.contextNode.kind === 180; + }; + Rules.IsTypeScriptDeclWithBlockContext = function (context) { + return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); + }; + Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { + switch (node.kind) { case 222: + case 193: case 223: - case 224: case 225: - case 229: + case 160: + case 226: + case 237: case 238: - case 234: - case 229: case 231: - case 232: - case 149: - case 150: - case 159: - addDeclaration(node); - ts.forEachChild(node, visit); - break; - case 142: - if (!ts.hasModifier(node, 92)) { - break; + case 234: + return true; + } + return false; + }; + Rules.IsAfterCodeBlockContext = function (context) { + switch (context.currentTokenParent.kind) { + case 222: + case 226: + case 225: + case 200: + case 252: + case 227: + case 214: + return true; + } + return false; + }; + Rules.IsControlDeclContext = function (context) { + switch (context.contextNode.kind) { + case 204: + case 214: + case 207: + case 208: + case 209: + case 206: + case 217: + case 205: + case 213: + case 252: + return true; + default: + return false; + } + }; + Rules.IsObjectContext = function (context) { + return context.contextNode.kind === 172; + }; + Rules.IsFunctionCallContext = function (context) { + return context.contextNode.kind === 175; + }; + Rules.IsNewContext = function (context) { + return context.contextNode.kind === 176; + }; + Rules.IsFunctionCallOrNewContext = function (context) { + return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); + }; + Rules.IsPreviousTokenNotComma = function (context) { + return context.currentTokenSpan.kind !== 25; + }; + Rules.IsNextTokenNotCloseBracket = function (context) { + return context.nextTokenSpan.kind !== 21; + }; + Rules.IsArrowFunctionContext = function (context) { + return context.contextNode.kind === 181; + }; + Rules.IsNonJsxSameLineTokenContext = function (context) { + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; + }; + Rules.IsNonJsxElementContext = function (context) { + return context.contextNode.kind !== 242; + }; + Rules.IsJsxExpressionContext = function (context) { + return context.contextNode.kind === 248; + }; + Rules.IsNextTokenParentJsxAttribute = function (context) { + return context.nextTokenParent.kind === 246; + }; + Rules.IsJsxAttributeContext = function (context) { + return context.contextNode.kind === 246; + }; + Rules.IsJsxSelfClosingElementContext = function (context) { + return context.contextNode.kind === 243; + }; + Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { + return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); + }; + Rules.IsEndOfDecoratorContextOnSameLine = function (context) { + return context.TokensAreOnSameLine() && + context.contextNode.decorators && + Rules.NodeIsInDecoratorContext(context.currentTokenParent) && + !Rules.NodeIsInDecoratorContext(context.nextTokenParent); + }; + Rules.NodeIsInDecoratorContext = function (node) { + while (ts.isPartOfExpression(node)) { + node = node.parent; + } + return node.kind === 144; + }; + Rules.IsStartOfVariableDeclarationList = function (context) { + return context.currentTokenParent.kind === 220 && + context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; + }; + Rules.IsNotFormatOnEnter = function (context) { + return context.formattingRequestKind !== 2; + }; + Rules.IsModuleDeclContext = function (context) { + return context.contextNode.kind === 226; + }; + Rules.IsObjectTypeContext = function (context) { + return context.contextNode.kind === 160; + }; + Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { + if (token.kind !== 26 && token.kind !== 28) { + return false; + } + switch (parent.kind) { + case 156: + case 178: + case 222: + case 193: + case 223: + case 221: + case 180: + case 181: + case 148: + case 147: + case 152: + case 153: + case 175: + case 176: + case 195: + return true; + default: + return false; + } + }; + Rules.IsTypeArgumentOrParameterOrAssertionContext = function (context) { + return Rules.IsTypeArgumentOrParameterOrAssertion(context.currentTokenSpan, context.currentTokenParent) || + Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); + }; + Rules.IsTypeAssertionContext = function (context) { + return context.contextNode.kind === 178; + }; + Rules.IsVoidOpContext = function (context) { + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; + }; + Rules.IsYieldOrYieldStarWithOperand = function (context) { + return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; + }; + return Rules; + }()); + formatting.Rules = Rules; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesMap = (function () { + function RulesMap() { + this.map = []; + this.mapRowLength = 0; + } + RulesMap.create = function (rules) { + var result = new RulesMap(); + result.Initialize(rules); + return result; + }; + RulesMap.prototype.Initialize = function (rules) { + this.mapRowLength = 139 + 1; + this.map = new Array(this.mapRowLength * this.mapRowLength); + var rulesBucketConstructionStateList = new Array(this.map.length); + this.FillRules(rules, rulesBucketConstructionStateList); + return this.map; + }; + RulesMap.prototype.FillRules = function (rules, rulesBucketConstructionStateList) { + var _this = this; + rules.forEach(function (rule) { + _this.FillRule(rule, rulesBucketConstructionStateList); + }); + }; + RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 && column <= 139, "Must compute formatting context from tokens"); + var rulesBucketIndex = (row * this.mapRowLength) + column; + return rulesBucketIndex; + }; + RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { + var _this = this; + var specificRule = rule.Descriptor.LeftTokenRange !== formatting.Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== formatting.Shared.TokenRange.Any; + rule.Descriptor.LeftTokenRange.GetTokens().forEach(function (left) { + rule.Descriptor.RightTokenRange.GetTokens().forEach(function (right) { + var rulesBucketIndex = _this.GetRuleBucketIndex(left, right); + var rulesBucket = _this.map[rulesBucketIndex]; + if (rulesBucket === undefined) { + rulesBucket = _this.map[rulesBucketIndex] = new RulesBucket(); } - case 218: - case 169: { - var decl = node; - if (ts.isBindingPattern(decl.name)) { - ts.forEachChild(decl.name, visit); - break; + rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex); + }); + }); + }; + RulesMap.prototype.GetRule = function (context) { + var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind); + var bucket = this.map[bucketIndex]; + if (bucket) { + for (var _i = 0, _a = bucket.Rules(); _i < _a.length; _i++) { + var rule = _a[_i]; + if (rule.Operation.Context.InContext(context)) { + return rule; } - if (decl.initializer) - visit(decl.initializer); } - case 255: - case 145: - case 144: - addDeclaration(node); - break; - case 236: - if (node.exportClause) { - ts.forEach(node.exportClause.elements, visit); - } - break; - case 230: - var importClause = node.importClause; - if (importClause) { - if (importClause.name) { - addDeclaration(importClause); - } - if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { - addDeclaration(importClause.namedBindings); - } - else { - ts.forEach(importClause.namedBindings.elements, visit); - } - } - } - break; - default: - ts.forEachChild(node, visit); } + return undefined; + }; + return RulesMap; + }()); + formatting.RulesMap = RulesMap; + var MaskBitSize = 5; + var Mask = 0x1f; + (function (RulesPosition) { + RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; + RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["ContextRulesSpecific"] = MaskBitSize * 2] = "ContextRulesSpecific"; + RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; + RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; + RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; + })(formatting.RulesPosition || (formatting.RulesPosition = {})); + var RulesPosition = formatting.RulesPosition; + var RulesBucketConstructionState = (function () { + function RulesBucketConstructionState() { + this.rulesInsertionIndexBitmap = 0; } - }; - return SourceFileObject; - }(NodeObject)); - function getServicesObjectAllocator() { - return { - getNodeConstructor: function () { return NodeObject; }, - getTokenConstructor: function () { return TokenObject; }, - getIdentifierConstructor: function () { return IdentifierObject; }, - getSourceFileConstructor: function () { return SourceFileObject; }, - getSymbolConstructor: function () { return SymbolObject; }, - getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } - }; - } - function toEditorSettings(optionsAsMap) { - var allPropertiesAreCamelCased = true; - for (var key in optionsAsMap) { - if (ts.hasProperty(optionsAsMap, key) && !isCamelCase(key)) { - allPropertiesAreCamelCased = false; - break; - } - } - if (allPropertiesAreCamelCased) { - return optionsAsMap; - } - var settings = {}; - for (var key in optionsAsMap) { - if (ts.hasProperty(optionsAsMap, key)) { - var newKey = isCamelCase(key) ? key : key.charAt(0).toLowerCase() + key.substr(1); - settings[newKey] = optionsAsMap[key]; - } - } - return settings; - } - ts.toEditorSettings = toEditorSettings; - function isCamelCase(s) { - return !s.length || s.charAt(0) === s.charAt(0).toLowerCase(); - } - function displayPartsToString(displayParts) { - if (displayParts) { - return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); - } - return ""; - } - ts.displayPartsToString = displayPartsToString; - function getDefaultCompilerOptions() { - return { - target: 1, - jsx: 1 - }; - } - ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - function getSupportedCodeFixes() { - return ts.codefix.getSupportedErrorCodes(); - } - ts.getSupportedCodeFixes = getSupportedCodeFixes; - var HostCache = (function () { - function HostCache(host, getCanonicalFileName) { - this.host = host; - this.getCanonicalFileName = getCanonicalFileName; - this.currentDirectory = host.getCurrentDirectory(); - this.fileNameToEntry = ts.createFileMap(); - var rootFileNames = host.getScriptFileNames(); - for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { - var fileName = rootFileNames_1[_i]; - this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); - } - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); - } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.createEntry = function (fileName, path) { - var entry; - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (scriptSnapshot) { - entry = { - hostFileName: fileName, - version: this.host.getScriptVersion(fileName), - scriptSnapshot: scriptSnapshot, - scriptKind: ts.getScriptKind(fileName, this.host) - }; - } - this.fileNameToEntry.set(path, entry); - return entry; - }; - HostCache.prototype.getEntry = function (path) { - return this.fileNameToEntry.get(path); - }; - HostCache.prototype.contains = function (path) { - return this.fileNameToEntry.contains(path); - }; - HostCache.prototype.getOrCreateEntry = function (fileName) { - var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); - return this.getOrCreateEntryByPath(fileName, path); - }; - HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) { - return this.contains(path) - ? this.getEntry(path) - : this.createEntry(fileName, path); - }; - HostCache.prototype.getRootFileNames = function () { - var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { - if (value) { - fileNames.push(value.hostFileName); + RulesBucketConstructionState.prototype.GetInsertionIndex = function (maskPosition) { + var index = 0; + var pos = 0; + var indexBitmap = this.rulesInsertionIndexBitmap; + while (pos <= maskPosition) { + index += (indexBitmap & Mask); + indexBitmap >>= MaskBitSize; + pos += MaskBitSize; } - }); - return fileNames; - }; - HostCache.prototype.getVersion = function (path) { - var file = this.getEntry(path); - return file && file.version; - }; - HostCache.prototype.getScriptSnapshot = function (path) { - var file = this.getEntry(path); - return file && file.scriptSnapshot; - }; - return HostCache; - }()); - var SyntaxTreeCache = (function () { - function SyntaxTreeCache(host) { - this.host = host; - } - SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { - var scriptSnapshot = this.host.getScriptSnapshot(fileName); - if (!scriptSnapshot) { - throw new Error("Could not find file: '" + fileName + "'."); - } - var scriptKind = ts.getScriptKind(fileName, this.host); - var version = this.host.getScriptVersion(fileName); - var sourceFile; - if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true, scriptKind); - } - else if (this.currentFileVersion !== version) { - var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); - sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); + return index; + }; + RulesBucketConstructionState.prototype.IncreaseInsertionIndex = function (maskPosition) { + var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; + value++; + ts.Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); + temp |= value << maskPosition; + this.rulesInsertionIndexBitmap = temp; + }; + return RulesBucketConstructionState; + }()); + formatting.RulesBucketConstructionState = RulesBucketConstructionState; + var RulesBucket = (function () { + function RulesBucket() { + this.rules = []; } - if (sourceFile) { - this.currentFileVersion = version; - this.currentFileName = fileName; - this.currentFileScriptSnapshot = scriptSnapshot; - this.currentSourceFile = sourceFile; - } - return this.currentSourceFile; - }; - return SyntaxTreeCache; - }()); - function setSourceFileFields(sourceFile, scriptSnapshot, version) { - sourceFile.version = version; - sourceFile.scriptSnapshot = scriptSnapshot; - } - function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) { - var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); - var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind); - setSourceFileFields(sourceFile, scriptSnapshot, version); - return sourceFile; - } - ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; - function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { - if (textChangeRange) { - if (version !== sourceFile.version) { - if (!ts.disableIncrementalParsing) { - var newText = void 0; - var prefix = textChangeRange.span.start !== 0 - ? sourceFile.text.substr(0, textChangeRange.span.start) - : ""; - var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length - ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) - : ""; - if (textChangeRange.newLength === 0) { - newText = prefix && suffix ? prefix + suffix : prefix || suffix; - } - else { - var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); - newText = prefix && suffix - ? prefix + changedText + suffix - : prefix - ? (prefix + changedText) - : (changedText + suffix); - } - var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - setSourceFileFields(newSourceFile, scriptSnapshot, version); - newSourceFile.nameTable = undefined; - if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { - if (sourceFile.scriptSnapshot.dispose) { - sourceFile.scriptSnapshot.dispose(); + RulesBucket.prototype.Rules = function () { + return this.rules; + }; + RulesBucket.prototype.AddRule = function (rule, specificTokens, constructionState, rulesBucketIndex) { + var position; + if (rule.Operation.Action === 1) { + position = specificTokens ? + RulesPosition.IgnoreRulesSpecific : + RulesPosition.IgnoreRulesAny; + } + else if (!rule.Operation.Context.IsAny()) { + position = specificTokens ? + RulesPosition.ContextRulesSpecific : + RulesPosition.ContextRulesAny; + } + else { + position = specificTokens ? + RulesPosition.NoContextRulesSpecific : + RulesPosition.NoContextRulesAny; + } + var state = constructionState[rulesBucketIndex]; + if (state === undefined) { + state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState(); + } + var index = state.GetInsertionIndex(position); + this.rules.splice(index, 0, rule); + state.IncreaseInsertionIndex(position); + }; + return RulesBucket; + }()); + formatting.RulesBucket = RulesBucket; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Shared; + (function (Shared) { + var TokenRangeAccess = (function () { + function TokenRangeAccess(from, to, except) { + this.tokens = []; + for (var token = from; token <= to; token++) { + if (ts.indexOf(except, token) < 0) { + this.tokens.push(token); } - sourceFile.scriptSnapshot = undefined; } - return newSourceFile; } - } - } - return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true, sourceFile.scriptKind); - } - ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; - var CancellationTokenObject = (function () { - function CancellationTokenObject(cancellationToken) { - this.cancellationToken = cancellationToken; - } - CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - }; - CancellationTokenObject.prototype.throwIfCancellationRequested = function () { - if (this.isCancellationRequested()) { - throw new ts.OperationCanceledException(); - } - }; - return CancellationTokenObject; - }()); - function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } - var syntaxTreeCache = new SyntaxTreeCache(host); - var ruleProvider; - var program; - var lastProjectVersion; - var lastTypesRootVersion = 0; - var useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); - var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - var currentDirectory = host.getCurrentDirectory(); - if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { - ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); - } - function log(message) { - if (host.log) { - host.log(message); - } - } - var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitivefileNames); - function getValidSourceFile(fileName) { - var sourceFile = program.getSourceFile(fileName); - if (!sourceFile) { - throw new Error("Could not find file: '" + fileName + "'."); - } - return sourceFile; - } - function getRuleProvider(options) { - if (!ruleProvider) { - ruleProvider = new ts.formatting.RulesProvider(); - } - ruleProvider.ensureUpToDate(options); - return ruleProvider; - } - function synchronizeHostData() { - if (host.getProjectVersion) { - var hostProjectVersion = host.getProjectVersion(); - if (hostProjectVersion) { - if (lastProjectVersion === hostProjectVersion) { - return; - } - lastProjectVersion = hostProjectVersion; + TokenRangeAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenRangeAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenRangeAccess; + }()); + Shared.TokenRangeAccess = TokenRangeAccess; + var TokenValuesAccess = (function () { + function TokenValuesAccess(tks) { + this.tokens = tks && tks.length ? tks : []; } - } - var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; - if (lastTypesRootVersion !== typeRootsVersion) { - log("TypeRoots version has changed; provide new program"); - program = undefined; - lastTypesRootVersion = typeRootsVersion; - } - var hostCache = new HostCache(host, getCanonicalFileName); - if (programUpToDate()) { - return; - } - var oldSettings = program && program.getCompilerOptions(); - var newSettings = hostCache.compilationSettings(); - var shouldCreateNewSourceFiles = oldSettings && - (oldSettings.target !== newSettings.target || - oldSettings.module !== newSettings.module || - oldSettings.moduleResolution !== newSettings.moduleResolution || - oldSettings.noResolve !== newSettings.noResolve || - oldSettings.jsx !== newSettings.jsx || - oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || - oldSettings.baseUrl !== newSettings.baseUrl || - !ts.equalOwnProperties(oldSettings.paths, newSettings.paths)); - var compilerHost = { - getSourceFile: getOrCreateSourceFile, - getSourceFileByPath: getOrCreateSourceFileByPath, - getCancellationToken: function () { return cancellationToken; }, - getCanonicalFileName: getCanonicalFileName, - useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, - getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, - getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return currentDirectory; }, - fileExists: function (fileName) { - return hostCache.getOrCreateEntry(fileName) !== undefined; - }, - readFile: function (fileName) { - var entry = hostCache.getOrCreateEntry(fileName); - return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); - }, - directoryExists: function (directoryName) { - return ts.directoryProbablyExists(directoryName, host); - }, - getDirectories: function (path) { - return host.getDirectories ? host.getDirectories(path) : []; + TokenValuesAccess.prototype.GetTokens = function () { + return this.tokens; + }; + TokenValuesAccess.prototype.Contains = function (token) { + return this.tokens.indexOf(token) >= 0; + }; + return TokenValuesAccess; + }()); + Shared.TokenValuesAccess = TokenValuesAccess; + var TokenSingleValueAccess = (function () { + function TokenSingleValueAccess(token) { + this.token = token; } - }; - if (host.trace) { - compilerHost.trace = function (message) { return host.trace(message); }; - } - if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; - } - if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile); + TokenSingleValueAccess.prototype.GetTokens = function () { + return [this.token]; }; - } - var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); - var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); - if (program) { - var oldSourceFiles = program.getSourceFiles(); - var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings); - for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { - var oldSourceFile = oldSourceFiles_1[_i]; - if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) { - documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); + TokenSingleValueAccess.prototype.Contains = function (tokenValue) { + return tokenValue === this.token; + }; + return TokenSingleValueAccess; + }()); + Shared.TokenSingleValueAccess = TokenSingleValueAccess; + var TokenAllAccess = (function () { + function TokenAllAccess() { + } + TokenAllAccess.prototype.GetTokens = function () { + var result = []; + for (var token = 0; token <= 139; token++) { + result.push(token); } + return result; + }; + TokenAllAccess.prototype.Contains = function () { + return true; + }; + TokenAllAccess.prototype.toString = function () { + return "[allTokens]"; + }; + return TokenAllAccess; + }()); + Shared.TokenAllAccess = TokenAllAccess; + var TokenRange = (function () { + function TokenRange(tokenAccess) { + this.tokenAccess = tokenAccess; } + TokenRange.FromToken = function (token) { + return new TokenRange(new TokenSingleValueAccess(token)); + }; + TokenRange.FromTokens = function (tokens) { + return new TokenRange(new TokenValuesAccess(tokens)); + }; + TokenRange.FromRange = function (f, to, except) { + if (except === void 0) { except = []; } + return new TokenRange(new TokenRangeAccess(f, to, except)); + }; + TokenRange.AllTokens = function () { + return new TokenRange(new TokenAllAccess()); + }; + TokenRange.prototype.GetTokens = function () { + return this.tokenAccess.GetTokens(); + }; + TokenRange.prototype.Contains = function (token) { + return this.tokenAccess.Contains(token); + }; + TokenRange.prototype.toString = function () { + return this.tokenAccess.toString(); + }; + return TokenRange; + }()); + TokenRange.Any = TokenRange.AllTokens(); + TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); + TokenRange.Keywords = TokenRange.FromRange(71, 139); + TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 139, 117, 125]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); + TokenRange.Comments = TokenRange.FromTokens([2, 3]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 131, 133, 121, 134, 104, 118]); + Shared.TokenRange = TokenRange; + })(Shared = formatting.Shared || (formatting.Shared = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var RulesProvider = (function () { + function RulesProvider() { + this.globalRules = new formatting.Rules(); } - hostCache = undefined; - program = newProgram; - program.getTypeChecker(); - return; - function getOrCreateSourceFile(fileName) { - return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName)); - } - function getOrCreateSourceFileByPath(fileName, path) { - ts.Debug.assert(hostCache !== undefined); - var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); - if (!hostFileInformation) { - return undefined; + RulesProvider.prototype.getRuleName = function (rule) { + return this.globalRules.getRuleName(rule); + }; + RulesProvider.prototype.getRuleByName = function (name) { + return this.globalRules[name]; + }; + RulesProvider.prototype.getRulesMap = function () { + return this.rulesMap; + }; + RulesProvider.prototype.ensureUpToDate = function (options) { + if (!this.options || !ts.compareDataObjects(this.options, options)) { + var activeRules = this.createActiveRules(options); + var rulesMap = formatting.RulesMap.create(activeRules); + this.activeRules = activeRules; + this.rulesMap = rulesMap; + this.options = ts.clone(options); } - if (!shouldCreateNewSourceFiles) { - var oldSourceFile = program && program.getSourceFileByPath(path); - if (oldSourceFile) { - ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); - return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); - } + }; + RulesProvider.prototype.createActiveRules = function (options) { + var rules = this.globalRules.HighPriorityCommonRules.slice(0); + if (options.insertSpaceAfterCommaDelimiter) { + rules.push(this.globalRules.SpaceAfterComma); } - return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); - } - function sourceFileUpToDate(sourceFile) { - if (!sourceFile) { - return false; + else { + rules.push(this.globalRules.NoSpaceAfterComma); } - var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); - return sourceFile.version === hostCache.getVersion(path); - } - function programUpToDate() { - if (!program) { - return false; + if (options.insertSpaceAfterFunctionKeywordForAnonymousFunctions) { + rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); } - var rootFileNames = hostCache.getRootFileNames(); - if (program.getSourceFiles().length !== rootFileNames.length) { - return false; + else { + rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); } - for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { - var fileName = rootFileNames_2[_i]; - if (!sourceFileUpToDate(program.getSourceFile(fileName))) { - return false; - } + if (options.insertSpaceAfterKeywordsInControlFlowStatements) { + rules.push(this.globalRules.SpaceAfterKeywordInControl); } - return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); + else { + rules.push(this.globalRules.NoSpaceAfterKeywordInControl); + } + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { + rules.push(this.globalRules.SpaceAfterOpenParen); + rules.push(this.globalRules.SpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenParen); + rules.push(this.globalRules.NoSpaceBeforeCloseParen); + rules.push(this.globalRules.NoSpaceBetweenParens); + } + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + rules.push(this.globalRules.SpaceAfterOpenBracket); + rules.push(this.globalRules.SpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBracket); + rules.push(this.globalRules.NoSpaceBeforeCloseBracket); + rules.push(this.globalRules.NoSpaceBetweenBrackets); + } + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces !== false) { + rules.push(this.globalRules.SpaceAfterOpenBrace); + rules.push(this.globalRules.SpaceBeforeCloseBrace); + rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBrace); + rules.push(this.globalRules.NoSpaceBeforeCloseBrace); + rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); + } + if (options.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces) { + rules.push(this.globalRules.SpaceAfterTemplateHeadAndMiddle); + rules.push(this.globalRules.SpaceBeforeTemplateMiddleAndTail); + } + else { + rules.push(this.globalRules.NoSpaceAfterTemplateHeadAndMiddle); + rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail); + } + if (options.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { + rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression); + rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression); + } + else { + rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression); + rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression); + } + if (options.insertSpaceAfterSemicolonInForStatements) { + rules.push(this.globalRules.SpaceAfterSemicolonInFor); + } + else { + rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); + } + if (options.insertSpaceBeforeAndAfterBinaryOperators) { + rules.push(this.globalRules.SpaceBeforeBinaryOperator); + rules.push(this.globalRules.SpaceAfterBinaryOperator); + } + else { + rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); + rules.push(this.globalRules.NoSpaceAfterBinaryOperator); + } + if (options.placeOpenBraceOnNewLineForControlBlocks) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); + } + if (options.placeOpenBraceOnNewLineForFunctions) { + rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); + rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); + } + if (options.insertSpaceAfterTypeAssertion) { + rules.push(this.globalRules.SpaceAfterTypeAssertion); + } + else { + rules.push(this.globalRules.NoSpaceAfterTypeAssertion); + } + rules = rules.concat(this.globalRules.LowPriorityCommonRules); + return rules; + }; + return RulesProvider; + }()); + formatting.RulesProvider = RulesProvider; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); + function formatOnEnter(position, sourceFile, rulesProvider, options) { + var line = sourceFile.getLineAndCharacterOfPosition(position).line; + if (line === 0) { + return []; + } + var endOfFormatSpan = ts.getEndLinePosition(line, sourceFile); + while (ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(endOfFormatSpan))) { + endOfFormatSpan--; } + if (ts.isLineBreak(sourceFile.text.charCodeAt(endOfFormatSpan))) { + endOfFormatSpan--; + } + var span = { + pos: ts.getStartPositionOfLine(line - 1, sourceFile), + end: endOfFormatSpan + 1 + }; + return formatSpan(span, sourceFile, options, rulesProvider, 2); } - function getProgram() { - synchronizeHostData(); - return program; + formatting.formatOnEnter = formatOnEnter; + function formatOnSemicolon(position, sourceFile, rulesProvider, options) { + return formatOutermostParent(position, 24, sourceFile, options, rulesProvider, 3); } - function cleanupSemanticCache() { + formatting.formatOnSemicolon = formatOnSemicolon; + function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { + return formatOutermostParent(position, 17, sourceFile, options, rulesProvider, 4); } - function dispose() { - if (program) { - ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); - }); - } + formatting.formatOnClosingCurly = formatOnClosingCurly; + function formatDocument(sourceFile, rulesProvider, options) { + var span = { + pos: 0, + end: sourceFile.text.length + }; + return formatSpan(span, sourceFile, options, rulesProvider, 0); } - function getSyntacticDiagnostics(fileName) { - synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + formatting.formatDocument = formatDocument; + function formatSelection(start, end, sourceFile, rulesProvider, options) { + var span = { + pos: ts.getLineStartPositionForPosition(start, sourceFile), + end: end + }; + return formatSpan(span, sourceFile, options, rulesProvider, 1); } - function getSemanticDiagnostics(fileName) { - synchronizeHostData(); - var targetSourceFile = getValidSourceFile(fileName); - var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); - if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; + formatting.formatSelection = formatSelection; + function formatOutermostParent(position, expectedLastToken, sourceFile, options, rulesProvider, requestKind) { + var parent = findOutermostParent(position, expectedLastToken, sourceFile); + if (!parent) { + return []; } - var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); - } - function getCompilerOptionsDiagnostics() { - synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); - } - function getCompletionsAtPosition(fileName, position) { - synchronizeHostData(); - return ts.Completions.getCompletionsAtPosition(host, program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position); - } - function getCompletionEntryDetails(fileName, position, entryName) { - synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position, entryName); - } - function getCompletionEntrySymbol(fileName, position, entryName) { - synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position, entryName); + var span = { + pos: ts.getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile), + end: parent.end + }; + return formatSpan(span, sourceFile, options, rulesProvider, requestKind); } - function getQuickInfoAtPosition(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, position); - if (node === sourceFile) { - return undefined; - } - if (ts.isLabelName(node)) { + function findOutermostParent(position, expectedTokenKind, sourceFile) { + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken || + precedingToken.kind !== expectedTokenKind || + position !== precedingToken.getEnd()) { return undefined; } - var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol || typeChecker.isUnknownSymbol(symbol)) { - switch (node.kind) { - case 69: - case 172: - case 139: - case 97: - case 165: - case 95: - var type = typeChecker.getTypeAtLocation(node); - if (type) { - return { - kind: ts.ScriptElementKind.unknown, - kindModifiers: ts.ScriptElementKindModifier.none, - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined - }; - } - } - return undefined; + var current = precedingToken; + while (current && + current.parent && + current.parent.end === precedingToken.end && + !isListElement(current.parent, current)) { + current = current.parent; } - var displayPartsDocumentationsAndKind = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, ts.getContainerNode(node), node); - return { - kind: displayPartsDocumentationsAndKind.symbolKind, - kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), - displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation - }; - } - function getDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); - } - function getImplementationAtPosition(fileName, position) { - synchronizeHostData(); - return ts.GoToImplementation.getImplementationAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); - } - function getTypeDefinitionAtPosition(fileName, position) { - synchronizeHostData(); - return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); + return current; } - function getOccurrencesAtPosition(fileName, position) { - var results = getOccurrencesAtPositionCore(fileName, position); - if (results) { - var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); - results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + function isListElement(parent, node) { + switch (parent.kind) { + case 222: + case 223: + return ts.rangeContainsRange(parent.members, node); + case 226: + var body = parent.body; + return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); + case 256: + case 200: + case 227: + return ts.rangeContainsRange(parent.statements, node); + case 252: + return ts.rangeContainsRange(parent.block.statements, node); } - return results; - } - function getDocumentHighlights(fileName, position, filesToSearch) { - synchronizeHostData(); - var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return program.getSourceFile(f); }); - var sourceFile = getValidSourceFile(fileName); - return ts.DocumentHighlights.getDocumentHighlights(program.getTypeChecker(), cancellationToken, sourceFile, position, sourceFilesToSearch); + return false; } - function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); - return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); - function convertDocumentHighlights(documentHighlights) { - if (!documentHighlights) { - return undefined; - } - var result = []; - for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { - var entry = documentHighlights_1[_i]; - for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { - var highlightSpan = _b[_a]; - result.push({ - fileName: entry.fileName, - textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, - isDefinition: false - }); + function findEnclosingNode(range, sourceFile) { + return find(sourceFile); + function find(n) { + var candidate = ts.forEachChild(n, function (c) { return ts.startEndContainsRange(c.getStart(sourceFile), c.end, range) && c; }); + if (candidate) { + var result = find(candidate); + if (result) { + return result; } } - return result; - } - } - function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); - return ts.FindAllReferences.convertReferences(referencedSymbols); - } - function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); - return ts.FindAllReferences.convertReferences(referencedSymbols); - } - function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false); - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments) { - synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); - } - function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { - synchronizeHostData(); - var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); - return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); - } - function getEmitOutput(fileName, emitOnlyDtsFiles) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var outputFiles = []; - function writeFile(fileName, data, writeByteOrderMark) { - outputFiles.push({ - name: fileName, - writeByteOrderMark: writeByteOrderMark, - text: data - }); + return n; } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); - return { - outputFiles: outputFiles, - emitSkipped: emitOutput.emitSkipped - }; - } - function getSignatureHelpItems(fileName, position) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); - } - function getNonBoundSourceFile(fileName) { - return syntaxTreeCache.getCurrentSourceFile(fileName); } - function getSourceFile(fileName) { - return getNonBoundSourceFile(fileName); - } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var node = ts.getTouchingPropertyName(sourceFile, startPos); - if (node === sourceFile) { - return; + function prepareRangeContainsErrorFunction(errors, originalRange) { + if (!errors.length) { + return rangeHasNoErrors; } - switch (node.kind) { - case 172: - case 139: - case 9: - case 84: - case 99: - case 93: - case 95: - case 97: - case 165: - case 69: - break; - default: - return; + var sorted = errors + .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) + .sort(function (e1, e2) { return e1.start - e2.start; }); + if (!sorted.length) { + return rangeHasNoErrors; } - var nodeForStartPos = node; - while (true) { - if (ts.isRightSideOfPropertyAccess(nodeForStartPos) || ts.isRightSideOfQualifiedName(nodeForStartPos)) { - nodeForStartPos = nodeForStartPos.parent; - } - else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 225 && - nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { - nodeForStartPos = nodeForStartPos.parent.parent.name; + var index = 0; + return function (r) { + while (true) { + if (index >= sorted.length) { + return false; } - else { - break; + var error = sorted[index]; + if (r.end <= error.start) { + return false; } + if (ts.startEndOverlapsWithStartEnd(r.pos, r.end, error.start, error.start + error.length)) { + return true; + } + index++; } - else { - break; - } + }; + function rangeHasNoErrors() { + return false; } - return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); - } - function getBreakpointStatementAtPosition(fileName, position) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); - } - function getNavigationBarItems(fileName) { - return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); - } - function getNavigationTree(fileName) { - return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); - } - function isTsOrTsxFile(fileName) { - var kind = ts.getScriptKind(fileName, host); - return kind === 3 || kind === 4; } - function getSemanticClassifications(fileName, span) { - if (!isTsOrTsxFile(fileName)) { - return []; + function getScanStartPosition(enclosingNode, originalRange, sourceFile) { + var start = enclosingNode.getStart(sourceFile); + if (start === originalRange.pos && enclosingNode.end === originalRange.end) { + return start; } - synchronizeHostData(); - return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); - } - function getEncodedSemanticClassifications(fileName, span) { - if (!isTsOrTsxFile(fileName)) { - return { spans: [], endOfLineState: 0 }; + var precedingToken = ts.findPrecedingToken(originalRange.pos, sourceFile); + if (!precedingToken) { + return enclosingNode.pos; } - synchronizeHostData(); - return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); - } - function getSyntacticClassifications(fileName, span) { - return ts.getSyntacticClassifications(cancellationToken, syntaxTreeCache.getCurrentSourceFile(fileName), span); - } - function getEncodedSyntacticClassifications(fileName, span) { - return ts.getEncodedSyntacticClassifications(cancellationToken, syntaxTreeCache.getCurrentSourceFile(fileName), span); - } - function getOutliningSpans(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); + if (precedingToken.end >= originalRange.pos) { + return enclosingNode.pos; + } + return precedingToken.end; } - function getBraceMatchingAtPosition(fileName, position) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var result = []; - var token = ts.getTouchingToken(sourceFile, position); - if (token.getStart(sourceFile) === position) { - var matchKind = getMatchingTokenKind(token); - if (matchKind) { - var parentElement = token.parent; - var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { - var current = childNodes_1[_i]; - if (current.kind === matchKind) { - var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); - var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); - if (range1.start < range2.start) { - result.push(range1, range2); - } - else { - result.push(range2, range1); - } - break; - } - } + function getOwnOrInheritedDelta(n, options, sourceFile) { + var previousLine = -1; + var child; + while (n) { + var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; + if (previousLine !== -1 && line !== previousLine) { + break; } - } - return result; - function getMatchingTokenKind(token) { - switch (token.kind) { - case 15: return 16; - case 17: return 18; - case 19: return 20; - case 25: return 27; - case 16: return 15; - case 18: return 17; - case 20: return 19; - case 27: return 25; + if (formatting.SmartIndenter.shouldIndentChildNode(n, child)) { + return options.indentSize; } - return undefined; - } - } - function getIndentationAtPosition(fileName, position, editorOptions) { - var start = ts.timestamp(); - var settings = toEditorSettings(editorOptions); - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - log("getIndentationAtPosition: getCurrentSourceFile: " + (ts.timestamp() - start)); - start = ts.timestamp(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, settings); - log("getIndentationAtPosition: computeIndentation : " + (ts.timestamp() - start)); - return result; - } - function getFormattingEditsForRange(fileName, start, end, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var settings = toEditorSettings(options); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(settings), settings); - } - function getFormattingEditsForDocument(fileName, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var settings = toEditorSettings(options); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(settings), settings); - } - function getFormattingEditsAfterKeystroke(fileName, position, key, options) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var settings = toEditorSettings(options); - if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); - } - else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + previousLine = line; + child = n; + n = n.parent; } - return []; + return 0; } - function getCodeFixesAtPosition(fileName, start, end, errorCodes) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - var span = { start: start, length: end - start }; - var newLineChar = ts.getNewLineOrDefaultFromHost(host); - var allFixes = []; - ts.forEach(errorCodes, function (error) { - cancellationToken.throwIfCancellationRequested(); - var context = { - errorCode: error, - sourceFile: sourceFile, - span: span, - program: program, - newLineCharacter: newLineChar - }; - var fixes = ts.codefix.getFixes(context); - if (fixes) { - allFixes = allFixes.concat(fixes); + function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { + var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); + var enclosingNode = findEnclosingNode(originalRange, sourceFile); + var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); + var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + var previousRangeHasError; + var previousRange; + var previousParent; + var previousRangeStartLine; + var lastIndentedLine; + var indentationOnLastIndentedLine; + var edits = []; + formattingScanner.advance(); + if (formattingScanner.isOnToken()) { + var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; + var undecoratedStartLine = startLine; + if (enclosingNode.decorators) { + undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - }); - return allFixes; - } - function getDocCommentTemplateAtPosition(fileName, position) { - return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); - } - function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { - if (openingBrace === 60) { - return false; - } - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position)) { - return false; - } - if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123; + var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); + processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } - if (ts.isInTemplateString(sourceFile, position)) { - return false; + if (!formattingScanner.isOnToken()) { + var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); + if (leadingTrivia) { + processTrivia(leadingTrivia, enclosingNode, enclosingNode, undefined); + trimTrailingWhitespacesForRemainingRange(); + } } - return true; - } - function getTodoComments(fileName, descriptors) { - synchronizeHostData(); - var sourceFile = getValidSourceFile(fileName); - cancellationToken.throwIfCancellationRequested(); - var fileContents = sourceFile.text; - var result = []; - if (descriptors.length > 0) { - var regExp = getTodoCommentsRegExp(); - var matchArray = void 0; - while (matchArray = regExp.exec(fileContents)) { - cancellationToken.throwIfCancellationRequested(); - var firstDescriptorCaptureIndex = 3; - ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); - var preamble = matchArray[1]; - var matchPosition = matchArray.index + preamble.length; - var token = ts.getTokenAtPosition(sourceFile, matchPosition); - if (!ts.isInsideComment(sourceFile, token, matchPosition)) { - continue; - } - var descriptor = undefined; - for (var i = 0, n = descriptors.length; i < n; i++) { - if (matchArray[i + firstDescriptorCaptureIndex]) { - descriptor = descriptors[i]; - } + formattingScanner.close(); + return edits; + function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { + if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || + ts.rangeContainsStartEnd(range, startPos, endPos)) { + if (inheritedIndentation !== -1) { + return inheritedIndentation; } - ts.Debug.assert(descriptor !== undefined); - if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { - continue; + } + else { + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var startLinePosition = ts.getLineStartPositionForPosition(startPos, sourceFile); + var column = formatting.SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options); + if (startLine !== parentStartLine || startPos === column) { + var baseIndentSize = formatting.SmartIndenter.getBaseIndentation(options); + return baseIndentSize > column ? baseIndentSize : column; } - var message = matchArray[2]; - result.push({ - descriptor: descriptor, - message: message, - position: matchPosition - }); } + return -1; } - return result; - function escapeRegExp(str) { - return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { + var indentation = inheritedIndentation; + var delta = formatting.SmartIndenter.shouldIndentChildNode(node) ? options.indentSize : 0; + if (effectiveParentStartLine === startLine) { + indentation = startLine === lastIndentedLine + ? indentationOnLastIndentedLine + : parentDynamicIndentation.getIndentation(); + delta = Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta); + } + else if (indentation === -1) { + if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { + indentation = parentDynamicIndentation.getIndentation(); + } + else { + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(node); + } + } + return { + indentation: indentation, + delta: delta + }; } - function getTodoCommentsRegExp() { - var singleLineCommentStart = /(?:\/\/+\s*)/.source; - var multiLineCommentStart = /(?:\/\*+\s*)/.source; - var anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source; - var preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; - var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; - var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; - var messageRemainder = /(?:.*?)/.source; - var messagePortion = "(" + literals + messageRemainder + ")"; - var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; - return new RegExp(regExpString, "gim"); - } - function isLetterOrDigit(char) { - return (char >= 97 && char <= 122) || - (char >= 65 && char <= 90) || - (char >= 48 && char <= 57); - } - } - function getRenameInfo(fileName, position) { - synchronizeHostData(); - var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); - return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); - } - return { - dispose: dispose, - cleanupSemanticCache: cleanupSemanticCache, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, - getSyntacticClassifications: getSyntacticClassifications, - getSemanticClassifications: getSemanticClassifications, - getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, - getEncodedSemanticClassifications: getEncodedSemanticClassifications, - getCompletionsAtPosition: getCompletionsAtPosition, - getCompletionEntryDetails: getCompletionEntryDetails, - getCompletionEntrySymbol: getCompletionEntrySymbol, - getSignatureHelpItems: getSignatureHelpItems, - getQuickInfoAtPosition: getQuickInfoAtPosition, - getDefinitionAtPosition: getDefinitionAtPosition, - getImplementationAtPosition: getImplementationAtPosition, - getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, - getReferencesAtPosition: getReferencesAtPosition, - findReferences: findReferences, - getOccurrencesAtPosition: getOccurrencesAtPosition, - getDocumentHighlights: getDocumentHighlights, - getNameOrDottedNameSpan: getNameOrDottedNameSpan, - getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, - getNavigateToItems: getNavigateToItems, - getRenameInfo: getRenameInfo, - findRenameLocations: findRenameLocations, - getNavigationBarItems: getNavigationBarItems, - getNavigationTree: getNavigationTree, - getOutliningSpans: getOutliningSpans, - getTodoComments: getTodoComments, - getBraceMatchingAtPosition: getBraceMatchingAtPosition, - getIndentationAtPosition: getIndentationAtPosition, - getFormattingEditsForRange: getFormattingEditsForRange, - getFormattingEditsForDocument: getFormattingEditsForDocument, - getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, - getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, - isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, - getCodeFixesAtPosition: getCodeFixesAtPosition, - getEmitOutput: getEmitOutput, - getNonBoundSourceFile: getNonBoundSourceFile, - getSourceFile: getSourceFile, - getProgram: getProgram - }; - } - ts.createLanguageService = createLanguageService; - function getNameTable(sourceFile) { - if (!sourceFile.nameTable) { - initializeNameTable(sourceFile); - } - return sourceFile.nameTable; - } - ts.getNameTable = getNameTable; - function initializeNameTable(sourceFile) { - var nameTable = ts.createMap(); - walk(sourceFile); - sourceFile.nameTable = nameTable; - function walk(node) { - switch (node.kind) { - case 69: - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; - break; - case 9: - case 8: - if (ts.isDeclarationName(node) || - node.parent.kind === 240 || - isArgumentOfElementAccessExpression(node) || - ts.isLiteralComputedPropertyDeclarationName(node)) { - nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; - } - break; - default: - ts.forEachChild(node, walk); - if (node.jsDocComments) { - for (var _i = 0, _a = node.jsDocComments; _i < _a.length; _i++) { - var jsDocComment = _a[_i]; - ts.forEachChild(jsDocComment, walk); - } - } - } - } - } - function isArgumentOfElementAccessExpression(node) { - return node && - node.parent && - node.parent.kind === 173 && - node.parent.argumentExpression === node; - } - function getDefaultLibFilePath(options) { - if (typeof __dirname !== "undefined") { - return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); - } - throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); - } - ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var ScriptInfo = (function () { - function ScriptInfo(host, fileName, content, scriptKind, isOpen, hasMixedContent) { - if (isOpen === void 0) { isOpen = false; } - if (hasMixedContent === void 0) { hasMixedContent = false; } - this.host = host; - this.fileName = fileName; - this.scriptKind = scriptKind; - this.isOpen = isOpen; - this.hasMixedContent = hasMixedContent; - this.containingProjects = []; - this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); - this.svc = server.ScriptVersionCache.fromString(host, content); - this.scriptKind = scriptKind - ? scriptKind - : ts.getScriptKindFromFileName(fileName); - } - ScriptInfo.prototype.getFormatCodeSettings = function () { - return this.formatCodeSettings; - }; - ScriptInfo.prototype.attachToProject = function (project) { - var isNew = !this.isAttached(project); - if (isNew) { - this.containingProjects.push(project); + function getFirstNonDecoratorTokenOfNode(node) { + if (node.modifiers && node.modifiers.length) { + return node.modifiers[0].kind; } - return isNew; - }; - ScriptInfo.prototype.isAttached = function (project) { - switch (this.containingProjects.length) { - case 0: return false; - case 1: return this.containingProjects[0] === project; - case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; - default: return ts.contains(this.containingProjects, project); + switch (node.kind) { + case 222: return 74; + case 223: return 108; + case 221: return 88; + case 225: return 225; + case 150: return 124; + case 151: return 132; + case 148: + if (node.asteriskToken) { + return 38; + } + case 146: + case 143: + return node.name.kind; } - }; - ScriptInfo.prototype.detachFromProject = function (project) { - switch (this.containingProjects.length) { - case 0: - return; - case 1: - if (this.containingProjects[0] === project) { - this.containingProjects.pop(); + } + function getDynamicIndentation(node, nodeStartLine, indentation, delta) { + return { + getIndentationForComment: function (kind, tokenIndentation, container) { + switch (kind) { + case 17: + case 21: + case 19: + return indentation + getEffectiveDelta(delta, container); } - break; - case 2: - if (this.containingProjects[0] === project) { - this.containingProjects[0] = this.containingProjects.pop(); + return tokenIndentation !== -1 ? tokenIndentation : indentation; + }, + getIndentationForToken: function (line, kind, container) { + if (nodeStartLine !== line && node.decorators) { + if (kind === getFirstNonDecoratorTokenOfNode(node)) { + return indentation; + } } - else if (this.containingProjects[1] === project) { - this.containingProjects.pop(); + 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; + } + }, + getIndentation: function () { return indentation; }, + getDelta: function (child) { return getEffectiveDelta(delta, child); }, + recomputeIndentation: function (lineAdded) { + if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent, node)) { + if (lineAdded) { + indentation += options.indentSize; + } + else { + indentation -= options.indentSize; + } + if (formatting.SmartIndenter.shouldIndentChildNode(node)) { + delta = options.indentSize; + } + else { + delta = 0; + } } - break; - default: - server.removeItemFromSet(this.containingProjects, project); - break; - } - }; - ScriptInfo.prototype.detachAllProjects = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.removeFile(this, false); - } - this.containingProjects.length = 0; - }; - ScriptInfo.prototype.getDefaultProject = function () { - if (this.containingProjects.length === 0) { - return server.Errors.ThrowNoProject(); - } - ts.Debug.assert(this.containingProjects.length !== 0); - return this.containingProjects[0]; - }; - ScriptInfo.prototype.setFormatOptions = function (formatSettings) { - if (formatSettings) { - if (!this.formatCodeSettings) { - this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); } - server.mergeMaps(this.formatCodeSettings, formatSettings); - } - }; - ScriptInfo.prototype.setWatcher = function (watcher) { - this.stopWatcher(); - this.fileWatcher = watcher; - }; - ScriptInfo.prototype.stopWatcher = function () { - if (this.fileWatcher) { - this.fileWatcher.close(); - this.fileWatcher = undefined; - } - }; - ScriptInfo.prototype.getLatestVersion = function () { - return this.svc.latestVersion().toString(); - }; - ScriptInfo.prototype.reload = function (script) { - this.svc.reload(script); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.saveTo = function (fileName) { - var snap = this.snap(); - this.host.writeFile(fileName, snap.getText(0, snap.getLength())); - }; - ScriptInfo.prototype.reloadFromFile = function () { - if (this.hasMixedContent) { - this.reload(""); - } - else { - this.svc.reloadFromFile(this.fileName); - this.markContainingProjectsAsDirty(); - } - }; - ScriptInfo.prototype.snap = function () { - return this.svc.getSnapshot(); - }; - ScriptInfo.prototype.getLineInfo = function (line) { - var snap = this.snap(); - return snap.index.lineNumberToInfo(line); - }; - ScriptInfo.prototype.editContent = function (start, end, newText) { - this.svc.edit(start, end - start, newText); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.markContainingProjectsAsDirty = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.markAsDirty(); - } - }; - ScriptInfo.prototype.lineToTextSpan = function (line) { - var index = this.snap().index; - var lineInfo = index.lineNumberToInfo(line + 1); - var len; - if (lineInfo.leaf) { - len = lineInfo.leaf.text.length; + }; + function getEffectiveDelta(delta, child) { + return formatting.SmartIndenter.nodeWillIndentChild(node, child, true) ? delta : 0; } - else { - var nextLineInfo = index.lineNumberToInfo(line + 2); - len = nextLineInfo.offset - lineInfo.offset; + } + function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { + if (!ts.rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) { + return; } - return ts.createTextSpan(lineInfo.offset, len); - }; - ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { - var index = this.snap().index; - var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.offset + offset - 1); - }; - ScriptInfo.prototype.positionToLineOffset = function (position) { - var index = this.snap().index; - var lineOffset = index.charOffsetToLineNumberAndPos(position); - return { line: lineOffset.line, offset: lineOffset.offset + 1 }; - }; - return ScriptInfo; - }()); - server.ScriptInfo = ScriptInfo; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var LSHost = (function () { - function LSHost(host, project, cancellationToken) { - var _this = this; - this.host = host; - this.project = project; - this.cancellationToken = cancellationToken; - this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); - this.resolvedModuleNames = ts.createFileMap(); - this.resolvedTypeReferenceDirectives = ts.createFileMap(); - if (host.trace) { - this.trace = function (s) { return host.trace(s); }; + var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta); + var childContextNode = contextNode; + ts.forEachChild(node, function (child) { + processChildNode(child, -1, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, false); + }, function (nodes) { + processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); + }); + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > node.end) { + break; + } + consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation); } - this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (primaryResult.resolvedModule) { - if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { - return primaryResult; + function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + var childStartPos = child.getStart(sourceFile); + var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; + var undecoratedChildStartLine = childStartLine; + if (child.decorators) { + undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; + } + var childIndentationAmount = -1; + if (isListItem) { + childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); + if (childIndentationAmount !== -1) { + inheritedIndentation = childIndentationAmount; } } - var secondaryLookupFailedLookupLocations = []; - var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; - if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { - var traceEnabled = ts.isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); + if (!ts.rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) { + if (child.end < originalRange.pos) { + formattingScanner.skipToEndOf(child); } - var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; - var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); - if (resolvedName) { - return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); + return inheritedIndentation; + } + if (child.getFullWidth() === 0) { + return inheritedIndentation; + } + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(node); + if (tokenInfo.token.end > childStartPos) { + break; } + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); } - if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { - primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); + if (!formattingScanner.isOnToken()) { + return inheritedIndentation; } - return primaryResult; - }; - } - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { - var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var currentResolutionsInFile = cache.get(path); - var newResolutions = ts.createMap(); - var resolvedModules = []; - var compilerOptions = this.getCompilationSettings(); - var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; - for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { - var name_52 = names_3[_i]; - var resolution = newResolutions[name_52]; - if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; - if (moduleResolutionIsValid(existingResolution)) { - resolution = existingResolution; + if (ts.isToken(child) && child.kind !== 10) { + var tokenInfo = formattingScanner.readTokenInfo(child); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); + consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); + return inheritedIndentation; + } + var effectiveParentStartLine = child.kind === 144 ? childStartLine : undecoratedParentStartLine; + var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); + processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); + childContextNode = node; + if (isFirstListItem && parent.kind === 171 && inheritedIndentation === -1) { + inheritedIndentation = childIndentation.indentation; + } + return inheritedIndentation; + } + function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + var listStartToken = getOpenTokenForList(parent, nodes); + var listEndToken = getCloseTokenForOpenToken(listStartToken); + var listDynamicIndentation = parentDynamicIndentation; + var startLine = parentStartLine; + if (listStartToken !== 0) { + while (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.end > nodes.pos) { + break; + } + else if (tokenInfo.token.kind === listStartToken) { + 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); + } + else { + consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation); + } } - else { - newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); + } + var inheritedIndentation = -1; + for (var i = 0; i < nodes.length; i++) { + var child = nodes[i]; + inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true, i === 0); + } + if (listEndToken !== 0) { + if (formattingScanner.isOnToken()) { + var tokenInfo = formattingScanner.readTokenInfo(parent); + if (tokenInfo.token.kind === listEndToken && ts.rangeContainsRange(parent, tokenInfo.token)) { + consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); + } } } - ts.Debug.assert(resolution !== undefined); - resolvedModules.push(getResult(resolution)); } - cache.set(path, newResolutions); - return resolvedModules; - function moduleResolutionIsValid(resolution) { - if (!resolution) { - return false; + function consumeTokenAndAdvanceScanner(currentTokenInfo, parent, dynamicIndentation, container) { + ts.Debug.assert(ts.rangeContainsRange(parent, currentTokenInfo.token)); + var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine(); + var indentToken = false; + if (currentTokenInfo.leadingTrivia) { + processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var result = getResult(resolution); - if (result) { - if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { - return false; + var lineAdded; + var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); + var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); + if (isTokenInRange) { + var rangeHasError = rangeContainsError(currentTokenInfo.token); + var savePreviousRange = previousRange; + lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); + if (rangeHasError) { + indentToken = false; + } + else { + if (lineAdded !== undefined) { + indentToken = lineAdded; + } + else { + var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; + indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; + } } - return true; } - return resolution.failedLookupLocations.length === 0; - } - }; - LSHost.prototype.getProjectVersion = function () { - return this.project.getProjectVersion(); - }; - LSHost.prototype.getCompilationSettings = function () { - return this.compilationSettings; - }; - LSHost.prototype.useCaseSensitiveFileNames = function () { - return this.host.useCaseSensitiveFileNames; - }; - LSHost.prototype.getCancellationToken = function () { - return this.cancellationToken; - }; - LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); - }; - LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }); - }; - LSHost.prototype.getDefaultLibFileName = function () { - var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); - return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); - }; - LSHost.prototype.getScriptSnapshot = function (filename) { - var scriptInfo = this.project.getScriptInfoLSHost(filename); - if (scriptInfo) { - return scriptInfo.snap(); + if (currentTokenInfo.trailingTrivia) { + processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); + } + if (indentToken) { + var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? + dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) : + -1; + var indentNextTokenOrTrivia = true; + if (currentTokenInfo.leadingTrivia) { + var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); + for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) { + var triviaItem = _a[_i]; + var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); + switch (triviaItem.kind) { + case 3: + if (triviaInRange) { + indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia); + } + indentNextTokenOrTrivia = false; + break; + case 2: + if (indentNextTokenOrTrivia && triviaInRange) { + insertIndentation(triviaItem.pos, commentIndentation, false); + } + indentNextTokenOrTrivia = false; + break; + case 4: + indentNextTokenOrTrivia = true; + break; + } + } + } + if (tokenIndentation !== -1 && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded); + lastIndentedLine = tokenStart.line; + indentationOnLastIndentedLine = tokenIndentation; + } + } + formattingScanner.advance(); + childContextNode = parent; } - }; - LSHost.prototype.getScriptFileNames = function () { - return this.project.getRootFilesLSHost(); - }; - LSHost.prototype.getTypeRootsVersion = function () { - return this.project.typesVersion; - }; - LSHost.prototype.getScriptKind = function (fileName) { - var info = this.project.getScriptInfoLSHost(fileName); - return info && info.scriptKind; - }; - LSHost.prototype.getScriptVersion = function (filename) { - var info = this.project.getScriptInfoLSHost(filename); - return info && info.getLatestVersion(); - }; - LSHost.prototype.getCurrentDirectory = function () { - return this.host.getCurrentDirectory(); - }; - LSHost.prototype.resolvePath = function (path) { - return this.host.resolvePath(path); - }; - LSHost.prototype.fileExists = function (path) { - return this.host.fileExists(path); - }; - LSHost.prototype.readFile = function (fileName) { - return this.host.readFile(fileName); - }; - LSHost.prototype.directoryExists = function (path) { - return this.host.directoryExists(path); - }; - LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { - return this.host.readDirectory(path, extensions, exclude, include); - }; - LSHost.prototype.getDirectories = function (path) { - return this.host.getDirectories(path); - }; - LSHost.prototype.notifyFileRemoved = function (info) { - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - }; - LSHost.prototype.setCompilationSettings = function (opt) { - this.compilationSettings = opt; - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); - }; - return LSHost; - }()); - server.LSHost = LSHost; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.nullTypingsInstaller = { - enqueueInstallTypingsRequest: function () { }, - attach: function (projectService) { }, - onProjectClosed: function (p) { }, - globalTypingsCacheLocation: undefined - }; - var TypingsCacheEntry = (function () { - function TypingsCacheEntry() { - } - return TypingsCacheEntry; - }()); - function setIsEqualTo(arr1, arr2) { - if (arr1 === arr2) { - return true; - } - if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { - return true; } - var set = ts.createMap(); - var unique = 0; - for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { - var v = arr1_1[_i]; - if (set[v] !== true) { - set[v] = true; - unique++; + function processTrivia(trivia, parent, contextNode, dynamicIndentation) { + for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { + var triviaItem = trivia_1[_i]; + if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { + var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); + processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); + } } } - for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { - var v = arr2_1[_a]; - if (!ts.hasProperty(set, v)) { - return false; - } - if (set[v] === true) { - set[v] = false; - unique--; + function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { + var rangeHasError = rangeContainsError(range); + var lineAdded; + if (!rangeHasError && !previousRangeHasError) { + if (!previousRange) { + var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos); + trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line); + } + else { + lineAdded = + processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation); + } } + previousRange = range; + previousParent = parent; + previousRangeStartLine = rangeStart.line; + previousRangeHasError = rangeHasError; + return lineAdded; } - return unique === 0; - } - function typingOptionsChanged(opt1, opt2) { - return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery || - !setIsEqualTo(opt1.include, opt2.include) || - !setIsEqualTo(opt1.exclude, opt2.exclude); - } - function compilerOptionsChanged(opt1, opt2) { - return opt1.allowJs != opt2.allowJs; - } - function toTypingsArray(arr) { - arr.sort(); - return arr; - } - var TypingsCache = (function () { - function TypingsCache(installer) { - this.installer = installer; - this.perProjectCache = ts.createMap(); - } - TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { - var typingOptions = project.getTypingOptions(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - return server.emptyArray; + function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { + formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); + var rule = rulesProvider.getRulesMap().GetRule(formattingContext); + var trimTrailingWhitespaces; + var lineAdded; + if (rule) { + applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + if (rule.Operation.Action & (2 | 8) && currentStartLine !== previousStartLine) { + lineAdded = false; + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(false); + } + } + else if (rule.Operation.Action & 4 && currentStartLine === previousStartLine) { + lineAdded = true; + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(true); + } + } + trimTrailingWhitespaces = !(rule.Operation.Action & 8) && rule.Flag !== 1; } - var entry = this.perProjectCache[project.getProjectName()]; - var result = entry ? entry.typings : server.emptyArray; - if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { - this.perProjectCache[project.getProjectName()] = { - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - typings: result, - poisoned: true - }; - this.installer.enqueueInstallTypingsRequest(project, typingOptions); + else { + trimTrailingWhitespaces = true; } - return result; - }; - TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { - var typingOptions = project.getTypingOptions(); - if (!typingOptions.enableAutoDiscovery) { - return; + if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { + trimTrailingWhitespacesForLines(previousStartLine, currentStartLine, previousItem); } - this.installer.enqueueInstallTypingsRequest(project, typingOptions); - }; - TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { - this.perProjectCache[projectName] = { - compilerOptions: compilerOptions, - typingOptions: typingOptions, - typings: toTypingsArray(newTypings), - poisoned: false - }; - }; - TypingsCache.prototype.onProjectClosed = function (project) { - delete this.perProjectCache[project.getProjectName()]; - this.installer.onProjectClosed(project); - }; - return TypingsCache; - }()); - server.TypingsCache = TypingsCache; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var crypto = require("crypto"); - function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; - } - server.shouldEmitFile = shouldEmitFile; - var BuilderFileInfo = (function () { - function BuilderFileInfo(scriptInfo, project) { - this.scriptInfo = scriptInfo; - this.project = project; + return lineAdded; } - 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 !== 225 || statement.name.kind !== 9) { - return false; - } - } - return true; - }; - BuilderFileInfo.prototype.computeHash = function (text) { - return crypto.createHash("md5") - .update(text) - .digest("base64"); - }; - 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); + function insertIndentation(pos, indentation, lineAdded) { + var indentationString = getIndentationString(indentation, options); + if (lineAdded) { + recordReplace(pos, 0, indentationString); } else { - var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); + var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); + if (indentation !== tokenStart.character || indentationIsDifferent(indentationString, startLinePosition)) { + recordReplace(startLinePosition, tokenStart.character, indentationString); } } - return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; - }; - return BuilderFileInfo; - }()); - server.BuilderFileInfo = BuilderFileInfo; - var AbstractBuilder = (function () { - function AbstractBuilder(project, ctor) { - this.project = project; - this.ctor = ctor; - this.fileInfos = ts.createFileMap(); } - AbstractBuilder.prototype.getFileInfo = function (path) { - return this.fileInfos.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.fileInfos.getKeys(); - }; - AbstractBuilder.prototype.setFileInfo = function (path, info) { - this.fileInfos.set(path, info); - }; - AbstractBuilder.prototype.removeFileInfo = function (path) { - this.fileInfos.remove(path); - }; - AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.fileInfos.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); + function indentationIsDifferent(indentationString, startLinePosition) { + return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); + } + function indentMultilineComment(commentRange, indentation, firstLineIsIndented) { + var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line; + var parts; + if (startLine === endLine) { + if (!firstLineIsIndented) { + insertIndentation(commentRange.pos, indentation, false); } + return; } - 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; + else { + parts = []; + var startPos = commentRange.pos; + for (var line = startLine; line < endLine; line++) { + var endOfLine = ts.getEndLinePosition(line, sourceFile); + parts.push({ pos: startPos, end: endOfLine }); + startPos = ts.getStartPositionOfLine(line + 1, sourceFile); } - return this.project.getAllEmittableFiles(); + parts.push({ pos: startPos, end: commentRange.end }); } - return singleFileResult; - }; - return NonModuleBuilder; - }(AbstractBuilder)); - var ModuleBuilderFileInfo = (function (_super) { - __extends(ModuleBuilderFileInfo, _super); - function ModuleBuilderFileInfo() { - var _this = _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); + var startLinePos = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceColumnInFirstPart = formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options); + if (indentation === nonWhitespaceColumnInFirstPart.column) { return; } - var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (insertIndex < 0) { - array.splice(~insertIndex, 0, fileInfo); + var startIndex = 0; + if (firstLineIsIndented) { + startIndex = 1; + startLine++; } - }; - ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { - if (!array || array.length === 0) { - return; + var delta = indentation - nonWhitespaceColumnInFirstPart.column; + for (var i = startIndex, len = parts.length; i < len; i++, startLine++) { + var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile); + var nonWhitespaceCharacterAndColumn = i === 0 + ? nonWhitespaceColumnInFirstPart + : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); + var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; + if (newIndentation > 0) { + var indentationString = getIndentationString(newIndentation, options); + recordReplace(startLinePos_1, nonWhitespaceCharacterAndColumn.character, indentationString); + } + else { + recordDelete(startLinePos_1, nonWhitespaceCharacterAndColumn.character); + } } - if (array[0] === fileInfo) { - array.splice(0, 1); - return; + } + function trimTrailingWhitespacesForLines(line1, line2, range) { + for (var line = line1; line < line2; line++) { + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var lineEndPosition = ts.getEndLinePosition(line, sourceFile); + if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) { + continue; + } + var whitespaceStart = getTrailingWhitespaceStartPosition(lineStartPosition, lineEndPosition); + if (whitespaceStart !== -1) { + ts.Debug.assert(whitespaceStart === lineStartPosition || !ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(whitespaceStart - 1))); + recordDelete(whitespaceStart, lineEndPosition + 1 - whitespaceStart); + } } - var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); - if (removeIndex >= 0) { - array.splice(removeIndex, 1); + } + function getTrailingWhitespaceStartPosition(start, end) { + var pos = end; + while (pos >= start && ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(pos))) { + pos--; } - }; - 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); + if (pos !== end) { + return pos + 1; } - 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; + return -1; } - ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { - var _this = this; - if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { - return []; + function trimTrailingWhitespacesForRemainingRange() { + var startPosition = previousRange ? previousRange.end : originalRange.pos; + var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; + trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); + } + function newTextChange(start, len, newText) { + return { span: ts.createTextSpan(start, len), newText: newText }; + } + function recordDelete(start, len) { + if (len) { + edits.push(newTextChange(start, len, "")); } - 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); + } + function recordReplace(start, len, newText) { + if (len || newText) { + edits.push(newTextChange(start, len, newText)); } - 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); + } + function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { + switch (rule.Operation.Action) { + case 1: + return; + case 8: + if (previousRange.end !== currentRange.pos) { + recordDelete(previousRange.end, currentRange.pos - previousRange.end); } - }); - this.projectVersionForDependencyGraph = this.project.getProjectVersion(); - } - }; - ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { - if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { - return; + break; + case 4: + if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { + return; + } + var lineDelta = currentStartLine - previousStartLine; + if (lineDelta !== 1) { + recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.newLineCharacter); + } + break; + case 2: + if (rule.Flag !== 1 && previousStartLine !== currentStartLine) { + return; + } + var posDelta = currentRange.pos - previousRange.end; + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32) { + recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); + } + break; } - 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++; + } + } + function getOpenTokenForList(node, list) { + switch (node.kind) { + case 149: + case 221: + case 180: + case 148: + case 147: + case 181: + if (node.typeParameters === list) { + return 26; } - else if (compare > 0) { - newReference.addReferencedBy(fileInfo); - newIndex++; + else if (node.parameters === list) { + return 18; } - else { - oldIndex++; - newIndex++; + break; + case 175: + case 176: + if (node.typeArguments === list) { + return 26; } - } - 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); - } - } + else if (node.arguments === list) { + return 18; } - fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; - } - var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { - result.push(fileName); + break; + case 156: + if (node.typeArguments === list) { + return 26; } - } - 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); } + return 0; } - server.createBuilder = createBuilder; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - (function (ProjectKind) { - ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; - ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; - ProjectKind[ProjectKind["External"] = 2] = "External"; - })(server.ProjectKind || (server.ProjectKind = {})); - var ProjectKind = server.ProjectKind; - function remove(items, item) { - var index = items.indexOf(item); - if (index >= 0) { - items.splice(index, 1); + function getCloseTokenForOpenToken(kind) { + switch (kind) { + case 18: + return 19; + case 26: + return 28; } + return 0; } - function countEachFileTypes(infos) { - var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - switch (info.scriptKind) { - case 1: - result.js += 1; - break; - case 2: - result.jsx += 1; - break; - case 3: - ts.fileExtensionIs(info.fileName, ".d.ts") - ? result.dts += 1 - : result.ts += 1; - break; - case 4: - result.tsx += 1; - break; - } + var internedSizes; + var internedTabsIndentation; + var internedSpacesIndentation; + function getIndentationString(indentation, options) { + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.tabSize || internedSizes.indentSize !== options.indentSize); + if (resetInternedStrings) { + internedSizes = { tabSize: options.tabSize, indentSize: options.indentSize }; + internedTabsIndentation = internedSpacesIndentation = undefined; } - return result; - } - function hasOneOrMoreJsAndNoTsFiles(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; - } - function allRootFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getRootScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; - function allFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allFilesAreJsOrDts = allFilesAreJsOrDts; - var Project = (function () { - function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - this.projectKind = projectKind; - this.projectService = projectService; - this.documentRegistry = documentRegistry; - this.languageServiceEnabled = languageServiceEnabled; - this.compilerOptions = compilerOptions; - this.compileOnSaveEnabled = compileOnSaveEnabled; - this.rootFiles = []; - this.rootFilesMap = ts.createFileMap(); - this.lastReportedVersion = 0; - this.projectStructureVersion = 0; - this.projectStateVersion = 0; - this.typesVersion = 0; - if (!this.compilerOptions) { - this.compilerOptions = ts.getDefaultCompilerOptions(); - this.compilerOptions.allowNonTsExtensions = true; - this.compilerOptions.allowJs = true; + if (!options.convertTabsToSpaces) { + var tabs = Math.floor(indentation / options.tabSize); + var spaces = indentation - tabs * options.tabSize; + var tabString = void 0; + if (!internedTabsIndentation) { + internedTabsIndentation = []; } - else if (hasExplicitListOfFiles) { - this.compilerOptions.allowNonTsExtensions = true; + if (internedTabsIndentation[tabs] === undefined) { + internedTabsIndentation[tabs] = tabString = repeat("\t", tabs); } - if (languageServiceEnabled) { - this.enableLanguageService(); + else { + tabString = internedTabsIndentation[tabs]; + } + return spaces ? tabString + repeat(" ", spaces) : tabString; + } + else { + var spacesString = void 0; + var quotient = Math.floor(indentation / options.indentSize); + var remainder = indentation % options.indentSize; + if (!internedSpacesIndentation) { + internedSpacesIndentation = []; + } + if (internedSpacesIndentation[quotient] === undefined) { + spacesString = repeat(" ", options.indentSize * quotient); + internedSpacesIndentation[quotient] = spacesString; } else { - this.disableLanguageService(); + spacesString = internedSpacesIndentation[quotient]; } - this.builder = server.createBuilder(this); - this.markAsDirty(); + return remainder ? spacesString + repeat(" ", remainder) : spacesString; } - Project.prototype.isNonTsProject = function () { - this.updateGraph(); - return allFilesAreJsOrDts(this); - }; - Project.prototype.isJsOnlyProject = function () { - this.updateGraph(); - return hasOneOrMoreJsAndNoTsFiles(this); - }; - Project.prototype.getProjectErrors = function () { - return this.projectErrors; - }; - Project.prototype.getLanguageService = function (ensureSynchronized) { - if (ensureSynchronized === void 0) { ensureSynchronized = true; } - if (ensureSynchronized) { - this.updateGraph(); + function repeat(value, count) { + var s = ""; + for (var i = 0; i < count; i++) { + s += value; } - return this.languageService; - }; - Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { - if (!this.languageServiceEnabled) { - return []; + return s; + } + } + formatting.getIndentationString = getIndentationString; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var formatting; + (function (formatting) { + var SmartIndenter; + (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); + function getIndentation(position, sourceFile, options) { + if (position > sourceFile.text.length) { + return getBaseIndentation(options); } - this.updateGraph(); - return this.builder.getFilesAffectedBy(scriptInfo); - }; - Project.prototype.getProjectVersion = function () { - return this.projectStateVersion.toString(); - }; - Project.prototype.enableLanguageService = function () { - var lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); - lsHost.setCompilationSettings(this.compilerOptions); - this.languageService = ts.createLanguageService(lsHost, this.documentRegistry); - this.lsHost = lsHost; - this.languageServiceEnabled = true; - }; - Project.prototype.disableLanguageService = function () { - this.languageService = server.nullLanguageService; - this.lsHost = server.nullLanguageServiceHost; - this.languageServiceEnabled = false; - }; - Project.prototype.getSourceFile = function (path) { - if (!this.program) { - return undefined; + if (options.indentStyle === ts.IndentStyle.None) { + return 0; } - return this.program.getSourceFileByPath(path); - }; - Project.prototype.updateTypes = function () { - this.typesVersion++; - this.markAsDirty(); - this.updateGraph(); - }; - Project.prototype.close = function () { - if (this.program) { - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - var info = this.projectService.getScriptInfo(f.fileName); - info.detachFromProject(this); - } + var precedingToken = ts.findPrecedingToken(position, sourceFile); + if (!precedingToken) { + return getBaseIndentation(options); } - else { - for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { - var root = _c[_b]; - root.detachFromProject(this); - } + var precedingTokenIsLiteral = ts.isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind); + if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) { + return 0; } - this.rootFiles = undefined; - this.rootFilesMap = undefined; - this.program = undefined; - this.languageService.dispose(); - }; - Project.prototype.getCompilerOptions = function () { - return this.compilerOptions; - }; - Project.prototype.hasRoots = function () { - return this.rootFiles && this.rootFiles.length > 0; - }; - Project.prototype.getRootFiles = function () { - return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); - }; - Project.prototype.getRootFilesLSHost = function () { - var result = []; - if (this.rootFiles) { - for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { - var f = _a[_i]; - result.push(f.fileName); - } - if (this.typingFiles) { - for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { - var f = _c[_b]; - result.push(f); + var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; + if (options.indentStyle === ts.IndentStyle.Block) { + var current_1 = position; + while (current_1 > 0) { + var char = sourceFile.text.charCodeAt(current_1); + if (!ts.isWhiteSpace(char)) { + break; } + current_1--; } + var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); + return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - return result; - }; - Project.prototype.getRootScriptInfos = function () { - return this.rootFiles; - }; - Project.prototype.getScriptInfos = function () { - var _this = this; - return ts.map(this.program.getSourceFiles(), function (sourceFile) { - var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); - if (!scriptInfo) { - ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 188) { + var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; } - return scriptInfo; - }); - }; - Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { - if (!this.languageServiceEnabled) { - return undefined; - } - return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); - }; - Project.prototype.getFileNames = function () { - if (!this.program) { - return []; } - if (!this.languageServiceEnabled) { - var rootFiles = this.getRootFiles(); - if (this.compilerOptions) { - var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); - if (defaultLibrary) { - (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + var previous; + var current = precedingToken; + var currentStart; + var indentationDelta; + while (current) { + if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { + currentStart = getStartLineAndCharacterForNode(current, sourceFile); + if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { + indentationDelta = 0; + } + else { + indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } + break; } - return rootFiles; + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + options.indentSize; + } + previous = current; + current = current.parent; } - var sourceFiles = this.program.getSourceFiles(); - return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); - }; - Project.prototype.getAllEmittableFiles = function () { - if (!this.languageServiceEnabled) { - return []; + if (!current) { + return getBaseIndentation(options); } - var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); - var infos = this.getScriptInfos(); - var result = []; - for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { - var info = infos_2[_i]; - if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { - result.push(info.fileName); + return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); + } + SmartIndenter.getIndentation = getIndentation; + function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { + var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); + } + SmartIndenter.getIndentationForNode = getIndentationForNode; + function getBaseIndentation(options) { + return options.baseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; + function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { + var parent = current.parent; + var parentStart; + while (parent) { + var useActualIndentation = true; + if (ignoreActualIndentationRange) { + var start = current.getStart(sourceFile); + useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end; + } + if (useActualIndentation) { + var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + parentStart = getParentStart(parent, current, sourceFile); + var parentAndChildShareLine = parentStart.line === currentStart.line || + childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); + if (useActualIndentation) { + var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); + if (actualIndentation !== -1) { + return actualIndentation + indentationDelta; + } + } + if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { + indentationDelta += options.indentSize; } + current = parent; + currentStart = parentStart; + parent = current.parent; } - return result; - }; - Project.prototype.containsScriptInfo = function (info) { - return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); - }; - Project.prototype.containsFile = function (filename, requireOpen) { - var info = this.projectService.getScriptInfoForNormalizedPath(filename); - if (info && (info.isOpen || !requireOpen)) { - return this.containsScriptInfo(info); + return indentationDelta + getBaseIndentation(options); + } + function getParentStart(parent, child, sourceFile) { + var containingList = getContainingList(child, sourceFile); + if (containingList) { + return sourceFile.getLineAndCharacterOfPosition(containingList.pos); } - }; - Project.prototype.isRoot = function (info) { - return this.rootFilesMap && this.rootFilesMap.contains(info.path); - }; - Project.prototype.addRoot = function (info) { - if (!this.isRoot(info)) { - this.rootFiles.push(info); - this.rootFilesMap.set(info.path, info); - info.attachToProject(this); - this.markAsDirty(); + return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile)); + } + function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { + var commaItemInfo = ts.findListItemInfo(commaToken); + if (commaItemInfo && commaItemInfo.listItemIndex > 0) { + return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); } - }; - Project.prototype.removeFile = function (info, detachFromProject) { - if (detachFromProject === void 0) { detachFromProject = true; } - this.removeRootFileIfNecessary(info); - this.lsHost.notifyFileRemoved(info); - if (detachFromProject) { - info.detachFromProject(this); - } - this.markAsDirty(); - }; - Project.prototype.markAsDirty = function () { - this.projectStateVersion++; - }; - Project.prototype.updateGraph = function () { - if (!this.languageServiceEnabled) { - return true; - } - var hasChanges = this.updateGraphWorker(); - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; + else { + return -1; } - if (hasChanges) { - this.projectStructureVersion++; + } + function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { + var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && + (parent.kind === 256 || !parentAndChildShareLine); + if (!useActualIndentation) { + return -1; } - return !hasChanges; - }; - Project.prototype.setTypings = function (typings) { - if (ts.arrayIsEqualTo(this.typingFiles, typings)) { + return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); + } + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { + var nextToken = ts.findNextToken(precedingToken, current); + if (!nextToken) { return false; } - this.typingFiles = typings; - this.markAsDirty(); - return true; - }; - Project.prototype.updateGraphWorker = function () { - var oldProgram = this.program; - this.program = this.languageService.getProgram(); - var hasChanges = false; - if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { - hasChanges = true; - if (oldProgram) { - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - if (this.program.getSourceFileByPath(f.path)) { - continue; - } - var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); - if (scriptInfoToDetach) { - scriptInfoToDetach.detachFromProject(this); - } - } - } - } - this.builder.onProjectUpdateGraph(); - return hasChanges; - }; - Project.prototype.getScriptInfoLSHost = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); - if (scriptInfo) { - scriptInfo.attachToProject(this); - } - return scriptInfo; - }; - Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); - if (scriptInfo && !scriptInfo.isAttached(this)) { - return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); - } - return scriptInfo; - }; - Project.prototype.getScriptInfo = function (uncheckedFileName) { - return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - }; - Project.prototype.filesToString = function () { - if (!this.program) { - return ""; - } - var strBuilder = ""; - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var file = _a[_i]; - strBuilder += file.fileName + "\n"; + if (nextToken.kind === 16) { + return true; } - return strBuilder; - }; - Project.prototype.setCompilerOptions = function (compilerOptions) { - if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; - } - compilerOptions.allowNonTsExtensions = true; - this.compilerOptions = compilerOptions; - this.lsHost.setCompilationSettings(compilerOptions); - this.markAsDirty(); + else if (nextToken.kind === 17) { + var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; + return lineAtPosition === nextTokenStartLine; } - }; - Project.prototype.reloadScript = function (filename) { - var script = this.projectService.getScriptInfoForNormalizedPath(filename); - if (script) { - ts.Debug.assert(script.isAttached(this)); - script.reloadFromFile(); - return true; + return false; + } + function getStartLineAndCharacterForNode(n, sourceFile) { + return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); + } + function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { + if (parent.kind === 204 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); + ts.Debug.assert(elseKeyword !== undefined); + var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; + return elseKeywordStartLine === childStartLine; } return false; - }; - Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { - this.updateGraph(); - var info = { - projectName: this.getProjectName(), - version: this.projectStructureVersion, - isInferred: this.projectKind === ProjectKind.Inferred, - options: this.getCompilerOptions() - }; - if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { - if (this.projectStructureVersion == this.lastReportedVersion) { - return { info: info, projectErrors: this.projectErrors }; - } - var lastReportedFileNames = this.lastReportedFileNames; - var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); - var added = []; - var removed = []; - for (var id in currentFiles) { - if (!ts.hasProperty(lastReportedFileNames, id)) { - added.push(id); + } + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getContainingList(node, sourceFile) { + if (node.parent) { + switch (node.parent.kind) { + case 156: + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { + return node.parent.typeArguments; + } + break; + case 172: + return node.parent.properties; + case 171: + return node.parent.elements; + case 221: + case 180: + case 181: + case 148: + case 147: + case 152: + case 153: { + var start = node.getStart(sourceFile); + if (node.parent.typeParameters && + ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { + return node.parent.typeParameters; + } + if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { + return node.parent.parameters; + } + break; } - } - for (var id in lastReportedFileNames) { - if (!ts.hasProperty(currentFiles, id)) { - removed.push(id); + case 176: + case 175: { + var start = node.getStart(sourceFile); + if (node.parent.typeArguments && + ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { + return node.parent.typeArguments; + } + if (node.parent.arguments && + ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { + return node.parent.arguments; + } + break; } } - this.lastReportedFileNames = currentFiles; - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, changes: { added: added, removed: removed }, projectErrors: this.projectErrors }; - } - else { - var projectFileNames = this.getFileNames(); - this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; } - }; - Project.prototype.getReferencedFiles = function (path) { - var _this = this; - if (!this.languageServiceEnabled) { - return []; + return undefined; + } + function getActualIndentationForListItem(node, sourceFile, options) { + var containingList = getContainingList(node, sourceFile); + return containingList ? getActualIndentationFromList(containingList) : -1; + function getActualIndentationFromList(list) { + var index = ts.indexOf(list, node); + return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1; } - var sourceFile = this.getSourceFile(path); - if (!sourceFile) { - return []; + } + function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { + if (node.kind === 19) { + return -1; } - var referencedFiles = ts.createMap(); - if (sourceFile.imports && sourceFile.imports.length > 0) { - var checker = this.program.getTypeChecker(); - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importName = _a[_i]; - var symbol = checker.getSymbolAtLocation(importName); - if (symbol && symbol.declarations && symbol.declarations[0]) { - var declarationSourceFile = symbol.declarations[0].getSourceFile(); - if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; - } - } + if (node.parent && (node.parent.kind === 175 || + node.parent.kind === 176) && + node.parent.expression !== node) { + var fullCallOrNewExpression = node.parent.expression; + var startingExpression = getStartingExpression(fullCallOrNewExpression); + if (fullCallOrNewExpression === startingExpression) { + return -1; } - } - var currentDirectory = ts.getDirectoryPath(path); - var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); - if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var referencedFile = _c[_b]; - var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; + var fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end); + var startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end); + if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) { + return -1; } + return findColumnForFirstNonWhitespaceCharacterInLine(fullCallOrNewExpressionEnd, sourceFile, options); } - if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; - if (!resolvedTypeReferenceDirective) { - continue; + return -1; + function getStartingExpression(node) { + while (true) { + switch (node.kind) { + case 175: + case 176: + case 173: + case 174: + node = node.expression; + break; + default: + return node; } - var fileName = resolvedTypeReferenceDirective.resolvedFileName; - var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; } } - var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); - return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); - }; - Project.prototype.removeRootFileIfNecessary = function (info) { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } - }; - return Project; - }()); - server.Project = Project; - var InferredProject = (function (_super) { - __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.directoriesWatchedForTsconfig = []; - _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); - InferredProject.NextId++; - return _this; - } - InferredProject.prototype.getProjectName = function () { - return this.inferredProjectName; - }; - InferredProject.prototype.getProjectRootPath = function () { - if (this.projectService.useSingleInferredProject) { - return undefined; - } - var rootFiles = this.getRootFiles(); - return ts.getDirectoryPath(rootFiles[0]); - }; - InferredProject.prototype.close = function () { - _super.prototype.close.call(this); - for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { - var directory = _a[_i]; - this.projectService.stopWatchingDirectory(directory); - } - }; - InferredProject.prototype.getTypingOptions = function () { - return { - enableAutoDiscovery: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - }; - return InferredProject; - }(Project)); - InferredProject.NextId = 1; - server.InferredProject = InferredProject; - var ConfiguredProject = (function (_super) { - __extends(ConfiguredProject, _super); - function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { - var _this = _super.call(this, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.configFileName = configFileName; - _this.wildcardDirectories = wildcardDirectories; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.openRefCount = 0; - return _this; } - ConfiguredProject.prototype.getProjectRootPath = function () { - return ts.getDirectoryPath(this.configFileName); - }; - ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; - }; - ConfiguredProject.prototype.setTypingOptions = function (newTypingOptions) { - this.typingOptions = newTypingOptions; - }; - ConfiguredProject.prototype.getTypingOptions = function () { - return this.typingOptions; - }; - ConfiguredProject.prototype.getProjectName = function () { - return this.configFileName; - }; - ConfiguredProject.prototype.watchConfigFile = function (callback) { - var _this = this; - this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, function (_) { return callback(_this); }); - }; - ConfiguredProject.prototype.watchTypeRoots = function (callback) { - var _this = this; - var roots = this.getEffectiveTypeRoots(); - var watchers = []; - for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { - var root = roots_1[_i]; - this.projectService.logger.info("Add type root watcher for: " + root); - watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); - } - this.typeRootsWatchers = watchers; - }; - ConfiguredProject.prototype.watchConfigDirectory = function (callback) { - var _this = this; - if (this.directoryWatcher) { - return; - } - var directoryToWatch = ts.getDirectoryPath(this.configFileName); - this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); - this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); - }; - ConfiguredProject.prototype.watchWildcards = function (callback) { - var _this = this; - if (!this.wildcardDirectories) { - return; - } - var configDirectoryPath = ts.getDirectoryPath(this.configFileName); - this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { - if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { - var recursive = (flag & 1) !== 0; - _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); + function deriveActualIndentationFromList(list, index, sourceFile, options) { + ts.Debug.assert(index >= 0 && index < list.length); + var node = list[index]; + var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); + for (var i = index - 1; i >= 0; i--) { + if (list[i].kind === 25) { + continue; } - return watchers; - }, {}); - }; - ConfiguredProject.prototype.stopWatchingDirectory = function () { - if (this.directoryWatcher) { - this.directoryWatcher.close(); - this.directoryWatcher = undefined; - } - }; - ConfiguredProject.prototype.close = function () { - _super.prototype.close.call(this); - if (this.projectFileWatcher) { - this.projectFileWatcher.close(); - } - if (this.typeRootsWatchers) { - for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { - var watcher = _a[_i]; - watcher.close(); + var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; + if (prevEndLine !== lineAndCharacter.line) { + return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options); } - this.typeRootsWatchers = undefined; - } - for (var id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); + lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - this.directoriesWatchedForWildcards = undefined; - this.stopWatchingDirectory(); - }; - ConfiguredProject.prototype.addOpenRef = function () { - this.openRefCount++; - }; - ConfiguredProject.prototype.deleteOpenRef = function () { - this.openRefCount--; - return this.openRefCount; - }; - ConfiguredProject.prototype.getEffectiveTypeRoots = function () { - return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; - }; - return ConfiguredProject; - }(Project)); - server.ConfiguredProject = ConfiguredProject; - var ExternalProject = (function (_super) { - __extends(ExternalProject, _super); - function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { - var _this = _super.call(this, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.externalProjectName = externalProjectName; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.projectFilePath = projectFilePath; - return _this; + return -1; } - ExternalProject.prototype.getProjectRootPath = function () { - if (this.projectFilePath) { - return ts.getDirectoryPath(this.projectFilePath); - } - return ts.getDirectoryPath(ts.normalizeSlashes(this.externalProjectName)); - }; - ExternalProject.prototype.getTypingOptions = function () { - return this.typingOptions; - }; - ExternalProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; - }; - ExternalProject.prototype.setTypingOptions = function (newTypingOptions) { - if (!newTypingOptions) { - newTypingOptions = { - enableAutoDiscovery: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - } - else { - if (newTypingOptions.enableAutoDiscovery === undefined) { - newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this); + function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { + var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); + return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); + } + function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) { + var character = 0; + var column = 0; + for (var pos = startPos; pos < endPos; pos++) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpaceSingleLine(ch)) { + break; } - if (!newTypingOptions.include) { - newTypingOptions.include = []; + if (ch === 9) { + column += options.tabSize + (column % options.tabSize); } - if (!newTypingOptions.exclude) { - newTypingOptions.exclude = []; + else { + column++; } + character++; } - this.typingOptions = newTypingOptions; - }; - ExternalProject.prototype.getProjectName = function () { - return this.externalProjectName; - }; - return ExternalProject; - }(Project)); - server.ExternalProject = ExternalProject; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; - function combineProjectOutput(projects, action, comparer, areEqual) { - var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); - return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; - } - server.combineProjectOutput = combineProjectOutput; - var fileNamePropertyReader = { - getFileName: function (x) { return x; }, - getScriptKind: function (_) { return undefined; }, - hasMixedContent: function (_) { return false; } - }; - var externalFilePropertyReader = { - getFileName: function (x) { return x.fileName; }, - getScriptKind: function (x) { return x.scriptKind; }, - hasMixedContent: function (x) { return x.hasMixedContent; } - }; - function findProjectByName(projectName, projects) { - for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { - var proj = projects_1[_i]; - if (proj.getProjectName() === projectName) { - return proj; - } - } - } - function createFileNotFoundDiagnostic(fileName) { - return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); - } - function isRootFileInInferredProject(info) { - if (info.containingProjects.length === 0) { - return false; + return { column: column, character: character }; } - return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); - } - var DirectoryWatchers = (function () { - function DirectoryWatchers(projectService) { - this.projectService = projectService; - this.directoryWatchersForTsconfig = ts.createMap(); - this.directoryWatchersRefCount = ts.createMap(); + SmartIndenter.findFirstNonWhitespaceCharacterAndColumn = findFirstNonWhitespaceCharacterAndColumn; + function findFirstNonWhitespaceColumn(startPos, endPos, sourceFile, options) { + return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } - DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { - this.projectService.logger.info("Close directory watcher for: " + directory); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; - } - }; - DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { - var currentPath = ts.getDirectoryPath(fileName); - var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { - this.projectService.logger.info("Add watcher for: " + currentPath); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; - } - else { - this.directoryWatchersRefCount[currentPath] += 1; - } - project.directoriesWatchedForTsconfig.push(currentPath); - currentPath = parentPath; - parentPath = ts.getDirectoryPath(parentPath); + SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; + function nodeContentIsAlwaysIndented(kind) { + switch (kind) { + case 203: + case 222: + case 193: + case 223: + case 225: + case 224: + case 171: + case 200: + case 227: + case 172: + case 160: + case 162: + case 228: + case 250: + case 249: + case 179: + case 173: + case 175: + case 176: + case 201: + case 219: + case 236: + case 212: + case 189: + case 169: + case 168: + case 244: + case 243: + case 248: + case 147: + case 152: + case 153: + case 143: + case 157: + case 158: + case 165: + case 177: + case 185: + case 238: + case 234: + case 239: + case 235: + return true; } - }; - return DirectoryWatchers; - }()); - var ProjectService = (function () { - function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { - if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } - this.host = host; - this.logger = logger; - this.cancellationToken = cancellationToken; - this.useSingleInferredProject = useSingleInferredProject; - this.typingsInstaller = typingsInstaller; - this.eventHandler = eventHandler; - this.filenameToScriptInfo = ts.createFileMap(); - this.externalProjectToConfiguredProjectMap = ts.createMap(); - this.externalProjects = []; - this.inferredProjects = []; - this.configuredProjects = []; - this.openFiles = []; - this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.directoryWatchers = new DirectoryWatchers(this); - this.throttledOperations = new server.ThrottledOperations(host); - this.typingsInstaller.attach(this); - this.typingsCache = new server.TypingsCache(this.typingsInstaller); - this.hostConfiguration = { - formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), - hostInfo: "Unknown host" - }; - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + return false; } - ProjectService.prototype.getChangedFiles_TestOnly = function () { - return this.changedFiles; - }; - ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { - this.ensureInferredProjectsUpToDate(); - }; - ProjectService.prototype.updateTypingsForProject = function (response) { - var project = this.findProject(response.projectName); - if (!project) { - return; + function nodeWillIndentChild(parent, child, indentByDefault) { + var childKind = child ? child.kind : 0; + switch (parent.kind) { + case 205: + case 206: + case 208: + case 209: + case 207: + case 204: + case 221: + case 180: + case 148: + case 181: + case 149: + case 150: + case 151: + return childKind !== 200; + case 237: + return childKind !== 238; + case 231: + return childKind !== 232 || + (child.namedBindings && child.namedBindings.kind !== 234); + case 242: + return childKind !== 245; } - switch (response.kind) { - case "set": - this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); - project.updateGraph(); - break; - case "invalidate": - this.typingsCache.invalidateCachedTypingsForProject(project); - break; + return indentByDefault; + } + SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; + function shouldIndentChildNode(parent, child) { + return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, false); + } + SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; + })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var codeFixes = ts.createMap(); + function registerCodeFix(action) { + ts.forEach(action.errorCodes, function (error) { + var fixes = codeFixes[error]; + if (!fixes) { + fixes = []; + codeFixes[error] = fixes; } - }; - ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = projectCompilerOptions; - this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; - for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - proj.setCompilerOptions(projectCompilerOptions); - proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + fixes.push(action); + }); + } + codefix.registerCodeFix = registerCodeFix; + function getSupportedErrorCodes() { + return Object.keys(codeFixes); + } + codefix.getSupportedErrorCodes = getSupportedErrorCodes; + function getFixes(context) { + var fixes = codeFixes[context.errorCode]; + var allActions = []; + ts.forEach(fixes, function (f) { + var actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); } - this.updateProjectGraphs(this.inferredProjects); - }; - ProjectService.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchers.stopWatchingDirectory(directory); - }; - ProjectService.prototype.findProject = function (projectName) { - if (projectName === undefined) { + }); + return allActions; + } + codefix.getFixes = getFixes; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +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; } - if (server.isInferredProjectName(projectName)) { - this.ensureInferredProjectsUpToDate(); - return findProjectByName(projectName, this.inferredProjects); + 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 } }] }] + }]; + } + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 98) { + return undefined; } - return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); - }; - ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { - if (refreshInferredProjects) { - this.ensureInferredProjectsUpToDate(); + var constructor = ts.getContainingFunction(token); + var superCall = findSuperCall(constructor.body); + if (!superCall) { + return undefined; } - var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - return scriptInfo && scriptInfo.getDefaultProject(); - }; - ProjectService.prototype.ensureInferredProjectsUpToDate = function () { - if (this.changedFiles) { - var projectsToUpdate = void 0; - if (this.changedFiles.length === 1) { - projectsToUpdate = this.changedFiles[0].containingProjects; - } - else { - projectsToUpdate = []; - for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { - var f = _a[_i]; - projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + if (superCall.expression && superCall.expression.kind == 175) { + var arguments_1 = superCall.expression.arguments; + for (var i = 0; i < arguments_1.length; i++) { + if (arguments_1[i].expression === token) { + return undefined; } } - this.updateProjectGraphs(projectsToUpdate); - this.changedFiles = undefined; - } - }; - ProjectService.prototype.findContainingExternalProject = function (fileName) { - for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - if (proj.containsFile(fileName)) { - return proj; - } } - return undefined; - }; - ProjectService.prototype.getFormatCodeOptions = function (file) { - var formatCodeSettings; - if (file) { - var info = this.getScriptInfoForNormalizedPath(file); - if (info) { - formatCodeSettings = info.getFormatCodeSettings(); + var newPosition = getOpenBraceEnd(constructor, sourceFile); + var changes = [{ + fileName: sourceFile.fileName, textChanges: [{ + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } + }] + }]; + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + changes: changes + }]; + function findSuperCall(n) { + if (n.kind === 203 && ts.isSuperCall(n.expression)) { + return n; } - } - return formatCodeSettings || this.hostConfiguration.formatCodeOptions; - }; - ProjectService.prototype.updateProjectGraphs = function (projects) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { - var p = projects_2[_i]; - if (!p.updateGraph()) { - shouldRefreshInferredProjects = true; + if (ts.isFunctionLike(n)) { + return undefined; } + return ts.forEachChild(n, findSuperCall); } - if (shouldRefreshInferredProjects) { - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.onSourceFileChanged = function (fileName) { - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - this.logger.info("Error: got watch notification for unknown file: " + fileName); - return; - } - if (!this.host.fileExists(fileName)) { - this.handleDeletedFile(info); + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.servicesVersion = "0.5"; + function createNode(kind, pos, end, parent) { + var node = kind >= 140 ? new NodeObject(kind, pos, end) : + kind === 70 ? new IdentifierObject(70, pos, end) : + new TokenObject(kind, pos, end); + node.parent = parent; + return node; + } + var NodeObject = (function () { + function NodeObject(kind, pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0; + this.transformFlags = undefined; + this.excludeTransformFlags = undefined; + this.parent = undefined; + this.kind = kind; + } + NodeObject.prototype.getSourceFile = function () { + return ts.getSourceFileOfNode(this); + }; + NodeObject.prototype.getStart = function (sourceFile, includeJsDocComment) { + return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment); + }; + NodeObject.prototype.getFullStart = function () { + return this.pos; + }; + NodeObject.prototype.getEnd = function () { + return this.end; + }; + NodeObject.prototype.getWidth = function (sourceFile) { + return this.getEnd() - this.getStart(sourceFile); + }; + NodeObject.prototype.getFullWidth = function () { + return this.end - this.pos; + }; + NodeObject.prototype.getLeadingTriviaWidth = function (sourceFile) { + return this.getStart(sourceFile) - this.pos; + }; + NodeObject.prototype.getFullText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); + }; + NodeObject.prototype.getText = function (sourceFile) { + if (!sourceFile) { + sourceFile = this.getSourceFile(); + } + return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd()); + }; + NodeObject.prototype.addSyntheticNodes = function (nodes, pos, end, useJSDocScanner) { + ts.scanner.setTextPos(pos); + while (pos < end) { + var token = useJSDocScanner ? ts.scanner.scanJSDocToken() : ts.scanner.scan(); + var textPos = ts.scanner.getTextPos(); + if (textPos <= end) { + nodes.push(createNode(token, pos, textPos, this)); } - else { - if (info && (!info.isOpen)) { - info.reloadFromFile(); - this.updateProjectGraphs(info.containingProjects); - } + pos = textPos; + } + return pos; + }; + NodeObject.prototype.createSyntaxList = function (nodes) { + var list = createNode(286, nodes.pos, nodes.end, this); + list._children = []; + var pos = nodes.pos; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; + if (pos < node.pos) { + pos = this.addSyntheticNodes(list._children, pos, node.pos); } - }; - ProjectService.prototype.handleDeletedFile = function (info) { - this.logger.info(info.fileName + " deleted"); - info.stopWatcher(); - if (!info.isOpen) { - this.filenameToScriptInfo.remove(info.path); - this.lastDeletedFile = info; - var containingProjects = info.containingProjects.slice(); - info.detachAllProjects(); - this.updateProjectGraphs(containingProjects); - this.lastDeletedFile = undefined; - if (!this.eventHandler) { - return; + list._children.push(node); + pos = node.end; + } + if (pos < nodes.end) { + this.addSyntheticNodes(list._children, pos, nodes.end); + } + return list; + }; + NodeObject.prototype.createChildren = function (sourceFile) { + var _this = this; + var children; + if (this.kind >= 140) { + ts.scanner.setText((sourceFile || this.getSourceFile()).text); + children = []; + var pos_3 = this.pos; + var useJSDocScanner_1 = this.kind >= 273 && this.kind <= 285; + var processNode = function (node) { + var isJSDocTagNode = ts.isJSDocTag(node); + if (!isJSDocTagNode && pos_3 < node.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, node.pos, useJSDocScanner_1); } - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var openFile = _a[_i]; - this.eventHandler({ eventName: "context", data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } }); + children.push(node); + if (!isJSDocTagNode) { + pos_3 = node.end; } - } - this.printProjects(); - }; - ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { - var _this = this; - this.logger.info("Type root file " + fileName + " changed"); - this.throttledOperations.schedule(project.configFileName + " * type root", 250, function () { - project.updateTypes(); - _this.updateConfiguredProject(project); - _this.refreshInferredProjects(); - }); - }; - ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { - var _this = this; - if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions())) { - return; - } - this.logger.info("Detected source file changes: " + fileName); - this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project); }); - }; - ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project) { - var _this = this; - var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors); - var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); - var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); - if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { - this.logger.info("Updating configured project"); - this.updateConfiguredProject(project); - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { - this.logger.info("Config file changed: " + project.configFileName); - this.updateConfiguredProject(project); - this.refreshInferredProjects(); - }; - ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { - this.logger.info(fileName + " is not tsconfig.json"); - return; - } - var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; - this.reportConfigFileDiagnostics(fileName, configFileErrors); - this.logger.info("Detected newly added tsconfig file: " + fileName); - this.reloadProjects(); - }; - ProjectService.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - ProjectService.prototype.removeProject = function (project) { - this.logger.info("remove project: " + project.getRootFiles().toString()); - project.close(); - switch (project.projectKind) { - case server.ProjectKind.External: - server.removeItemFromSet(this.externalProjects, project); - break; - case server.ProjectKind.Configured: - server.removeItemFromSet(this.configuredProjects, project); - break; - case server.ProjectKind.Inferred: - server.removeItemFromSet(this.inferredProjects, project); - break; - } - }; - ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { - var externalProject = this.findContainingExternalProject(info.fileName); - if (externalProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); + }; + var processNodes = function (nodes) { + if (pos_3 < nodes.pos) { + pos_3 = _this.addSyntheticNodes(children, pos_3, nodes.pos, useJSDocScanner_1); } - return; - } - var foundConfiguredProject = false; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - foundConfiguredProject = true; - if (addToListOfOpenFiles) { - (p).addOpenRef(); - } + children.push(_this.createSyntaxList(nodes)); + pos_3 = nodes.end; + }; + if (this.jsDocComments) { + for (var _i = 0, _a = this.jsDocComments; _i < _a.length; _i++) { + var jsDocComment = _a[_i]; + processNode(jsDocComment); } } - if (foundConfiguredProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } - return; - } - if (info.containingProjects.length === 0) { - var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); - if (!this.useSingleInferredProject) { - for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { - var f = _c[_b]; - if (f.containingProjects.length === 0) { - continue; - } - var defaultProject = f.getDefaultProject(); - if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - this.removeProject(defaultProject); - f.attachToProject(inferredProject); - } - } - } - } - if (addToListOfOpenFiles) { - this.openFiles.push(info); + pos_3 = this.pos; + ts.forEachChild(this, processNode, processNodes); + if (pos_3 < this.end) { + this.addSyntheticNodes(children, pos_3, this.end); } - }; - ProjectService.prototype.closeOpenFile = function (info) { - info.reloadFromFile(); - server.removeItemFromSet(this.openFiles, info); - info.isOpen = false; - var projectsToRemove; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - if (p.deleteOpenRef() === 0) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } - } - else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } + ts.scanner.setText(undefined); + } + this._children = children || ts.emptyArray; + }; + NodeObject.prototype.getChildCount = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children.length; + }; + NodeObject.prototype.getChildAt = function (index, sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children[index]; + }; + NodeObject.prototype.getChildren = function (sourceFile) { + if (!this._children) + this.createChildren(sourceFile); + return this._children; + }; + NodeObject.prototype.getFirstToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + if (!children.length) { + return undefined; + } + var child = children[0]; + return child.kind < 140 ? child : child.getFirstToken(sourceFile); + }; + NodeObject.prototype.getLastToken = function (sourceFile) { + var children = this.getChildren(sourceFile); + var child = ts.lastOrUndefined(children); + if (!child) { + return undefined; + } + return child.kind < 140 ? child : child.getLastToken(sourceFile); + }; + return NodeObject; + }()); + var TokenOrIdentifierObject = (function () { + function TokenOrIdentifierObject(pos, end) { + this.pos = pos; + this.end = end; + this.flags = 0; + this.parent = undefined; + } + TokenOrIdentifierObject.prototype.getSourceFile = function () { + return ts.getSourceFileOfNode(this); + }; + TokenOrIdentifierObject.prototype.getStart = function (sourceFile, includeJsDocComment) { + return ts.getTokenPosOfNode(this, sourceFile, includeJsDocComment); + }; + TokenOrIdentifierObject.prototype.getFullStart = function () { + return this.pos; + }; + TokenOrIdentifierObject.prototype.getEnd = function () { + return this.end; + }; + TokenOrIdentifierObject.prototype.getWidth = function (sourceFile) { + return this.getEnd() - this.getStart(sourceFile); + }; + TokenOrIdentifierObject.prototype.getFullWidth = function () { + return this.end - this.pos; + }; + TokenOrIdentifierObject.prototype.getLeadingTriviaWidth = function (sourceFile) { + return this.getStart(sourceFile) - this.pos; + }; + TokenOrIdentifierObject.prototype.getFullText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); + }; + TokenOrIdentifierObject.prototype.getText = function (sourceFile) { + return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); + }; + TokenOrIdentifierObject.prototype.getChildCount = function () { + return 0; + }; + TokenOrIdentifierObject.prototype.getChildAt = function () { + return undefined; + }; + TokenOrIdentifierObject.prototype.getChildren = function () { + return ts.emptyArray; + }; + TokenOrIdentifierObject.prototype.getFirstToken = function () { + return undefined; + }; + TokenOrIdentifierObject.prototype.getLastToken = function () { + return undefined; + }; + return TokenOrIdentifierObject; + }()); + var SymbolObject = (function () { + function SymbolObject(flags, name) { + this.flags = flags; + this.name = name; + } + SymbolObject.prototype.getFlags = function () { + return this.flags; + }; + SymbolObject.prototype.getName = function () { + return this.name; + }; + SymbolObject.prototype.getDeclarations = function () { + return this.declarations; + }; + SymbolObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); + } + return this.documentationComment; + }; + return SymbolObject; + }()); + var TokenObject = (function (_super) { + __extends(TokenObject, _super); + function TokenObject(kind, pos, end) { + var _this = _super.call(this, pos, end) || this; + _this.kind = kind; + return _this; + } + return TokenObject; + }(TokenOrIdentifierObject)); + var IdentifierObject = (function (_super) { + __extends(IdentifierObject, _super); + function IdentifierObject(_kind, pos, end) { + return _super.call(this, pos, end) || this; + } + return IdentifierObject; + }(TokenOrIdentifierObject)); + IdentifierObject.prototype.kind = 70; + var TypeObject = (function () { + function TypeObject(checker, flags) { + this.checker = checker; + this.flags = flags; + } + TypeObject.prototype.getFlags = function () { + return this.flags; + }; + TypeObject.prototype.getSymbol = function () { + return this.symbol; + }; + TypeObject.prototype.getProperties = function () { + return this.checker.getPropertiesOfType(this); + }; + TypeObject.prototype.getProperty = function (propertyName) { + return this.checker.getPropertyOfType(this, propertyName); + }; + TypeObject.prototype.getApparentProperties = function () { + return this.checker.getAugmentedPropertiesOfType(this); + }; + TypeObject.prototype.getCallSignatures = function () { + return this.checker.getSignaturesOfType(this, 0); + }; + TypeObject.prototype.getConstructSignatures = function () { + return this.checker.getSignaturesOfType(this, 1); + }; + TypeObject.prototype.getStringIndexType = function () { + return this.checker.getIndexTypeOfType(this, 0); + }; + TypeObject.prototype.getNumberIndexType = function () { + return this.checker.getIndexTypeOfType(this, 1); + }; + TypeObject.prototype.getBaseTypes = function () { + return this.flags & (32768 | 65536) + ? this.checker.getBaseTypes(this) + : undefined; + }; + TypeObject.prototype.getNonNullableType = function () { + return this.checker.getNonNullableType(this); + }; + return TypeObject; + }()); + var SignatureObject = (function () { + function SignatureObject(checker) { + this.checker = checker; + } + SignatureObject.prototype.getDeclaration = function () { + return this.declaration; + }; + SignatureObject.prototype.getTypeParameters = function () { + return this.typeParameters; + }; + SignatureObject.prototype.getParameters = function () { + return this.parameters; + }; + SignatureObject.prototype.getReturnType = function () { + return this.checker.getReturnTypeOfSignature(this); + }; + SignatureObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; + } + return this.documentationComment; + }; + return SignatureObject; + }()); + var SourceFileObject = (function (_super) { + __extends(SourceFileObject, _super); + function SourceFileObject(kind, pos, end) { + return _super.call(this, kind, pos, end) || this; + } + SourceFileObject.prototype.update = function (newText, textChangeRange) { + return ts.updateSourceFile(this, newText, textChangeRange); + }; + SourceFileObject.prototype.getLineAndCharacterOfPosition = function (position) { + return ts.getLineAndCharacterOfPosition(this, position); + }; + SourceFileObject.prototype.getLineStarts = function () { + return ts.getLineStarts(this); + }; + SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { + return ts.getPositionOfLineAndCharacter(this, line, character); + }; + SourceFileObject.prototype.getNamedDeclarations = function () { + if (!this.namedDeclarations) { + this.namedDeclarations = this.computeNamedDeclarations(); + } + return this.namedDeclarations; + }; + SourceFileObject.prototype.computeNamedDeclarations = function () { + var result = ts.createMap(); + ts.forEachChild(this, visit); + return result; + function addDeclaration(declaration) { + var name = getDeclarationName(declaration); + if (name) { + ts.multiMapAdd(result, name, declaration); } - if (projectsToRemove) { - for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { - var project = projectsToRemove_1[_b]; - this.removeProject(project); - } - var orphanFiles = void 0; - for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { - var f = _d[_c]; - if (f.containingProjects.length === 0) { - (orphanFiles || (orphanFiles = [])).push(f); - } + } + function getDeclarations(name) { + return result[name] || (result[name] = []); + } + function getDeclarationName(declaration) { + if (declaration.name) { + var result_6 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_6 !== undefined) { + return result_6; } - if (orphanFiles) { - for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { - var f = orphanFiles_1[_e]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); + if (declaration.name.kind === 141) { + var expr = declaration.name.expression; + if (expr.kind === 173) { + return expr.name.text; } + return getTextOfIdentifierOrLiteral(expr); } } - if (info.containingProjects.length === 0) { - this.filenameToScriptInfo.remove(info.path); - } - }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { - var searchPath = ts.getDirectoryPath(fileName); - this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); - if (!configFileName) { - this.logger.info("No config files found."); - return {}; - } - this.logger.info("Config file name: " + configFileName); - var project = this.findConfiguredProjectByProjectName(configFileName); - if (!project) { - var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; - if (!success) { - return { configFileName: configFileName, configFileErrors: errors }; - } - this.logger.info("Opened configuration file " + configFileName); - if (errors && errors.length > 0) { - return { configFileName: configFileName, configFileErrors: errors }; - } - } - else { - this.updateConfiguredProject(project); - } - return { configFileName: configFileName }; - }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { - var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); - if (this.host.fileExists(tsconfigFileName)) { - return tsconfigFileName; - } - var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); - if (this.host.fileExists(jsconfigFileName)) { - return jsconfigFileName; - } - var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } return undefined; - }; - ProjectService.prototype.printProjects = function () { - if (!this.logger.hasLevel(server.LogLevel.verbose)) { - return; - } - this.logger.startGroup(); - var counter = 0; - counter = printProjects(this.logger, this.externalProjects, counter); - counter = printProjects(this.logger, this.configuredProjects, counter); - counter = printProjects(this.logger, this.inferredProjects, counter); - this.logger.info("Open files: "); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var rootFile = _a[_i]; - this.logger.info(rootFile.fileName); - } - this.logger.endGroup(); - function printProjects(logger, projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; - project.updateGraph(); - logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - logger.info(project.filesToString()); - logger.info("-----------------------------------------------"); - counter++; + } + function getTextOfIdentifierOrLiteral(node) { + if (node) { + if (node.kind === 70 || + node.kind === 9 || + node.kind === 8) { + return node.text; } - return counter; - } - }; - ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { - return findProjectByName(configFileName, this.configuredProjects); - }; - ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { - return findProjectByName(projectFileName, this.externalProjects); - }; - ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { - configFilename = ts.normalizePath(configFilename); - var configFileContent = this.host.readFile(configFilename); - var errors; - var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); - var config = result.config; - if (result.error) { - var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; - config = sanitizedConfig; - errors = diagnostics.length ? diagnostics : [result.error]; - } - var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename); - if (parsedCommandLine.errors.length) { - errors = ts.concatenate(errors, parsedCommandLine.errors); - } - ts.Debug.assert(!!parsedCommandLine.fileNames); - if (parsedCommandLine.fileNames.length === 0) { - (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); - return { success: false, configFileErrors: errors }; - } - var projectOptions = { - files: parsedCommandLine.fileNames, - compilerOptions: parsedCommandLine.options, - configHasFilesProperty: config["files"] !== undefined, - wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), - typingOptions: parsedCommandLine.typingOptions, - compileOnSave: parsedCommandLine.compileOnSave - }; - return { success: true, projectOptions: projectOptions, configFileErrors: errors }; - }; - ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { - if (options && options.disableSizeLimit || !this.host.getFileSize) { - return false; } - var totalNonTsFileSize = 0; - for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { - var f = fileNames_3[_i]; - var fileName = propertyReader.getFileName(f); - if (ts.hasTypeScriptFileExtension(fileName)) { - continue; - } - totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { - return true; + return undefined; + } + function visit(node) { + switch (node.kind) { + case 221: + case 180: + case 148: + case 147: + var functionDeclaration = node; + var declarationName = getDeclarationName(functionDeclaration); + if (declarationName) { + var declarations = getDeclarations(declarationName); + var lastDeclaration = ts.lastOrUndefined(declarations); + if (lastDeclaration && functionDeclaration.parent === lastDeclaration.parent && functionDeclaration.symbol === lastDeclaration.symbol) { + if (functionDeclaration.body && !lastDeclaration.body) { + declarations[declarations.length - 1] = functionDeclaration; + } + } + else { + declarations.push(functionDeclaration); + } + ts.forEachChild(node, visit); + } + break; + case 222: + case 193: + case 223: + case 224: + case 225: + case 226: + case 230: + case 239: + case 235: + case 230: + case 232: + case 233: + case 150: + case 151: + case 160: + addDeclaration(node); + ts.forEachChild(node, visit); + break; + case 143: + if (!ts.hasModifier(node, 92)) { + break; + } + case 219: + case 170: { + var decl = node; + if (ts.isBindingPattern(decl.name)) { + ts.forEachChild(decl.name, visit); + break; + } + if (decl.initializer) + visit(decl.initializer); } + case 255: + case 146: + case 145: + addDeclaration(node); + break; + case 237: + if (node.exportClause) { + ts.forEach(node.exportClause.elements, visit); + } + break; + case 231: + var importClause = node.importClause; + if (importClause) { + if (importClause.name) { + addDeclaration(importClause); + } + if (importClause.namedBindings) { + if (importClause.namedBindings.kind === 233) { + addDeclaration(importClause.namedBindings); + } + else { + ts.forEach(importClause.namedBindings.elements, visit); + } + } + } + break; + default: + ts.forEachChild(node, visit); } - return false; - }; - ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, options, !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); - this.externalProjects.push(project); - return project; - }; - ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ - eventName: "configFileDiag", - data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } - }); - }; - ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { - var _this = this; - var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); - var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors); - project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); - if (!sizeLimitExceeded) { - this.watchConfigDirectoryForProject(project, projectOptions); - } - project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); - project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); - this.configuredProjects.push(project); - return project; - }; - ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { - var _this = this; - if (!options.configHasFilesProperty) { - project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + } + }; + return SourceFileObject; + }(NodeObject)); + function getServicesObjectAllocator() { + return { + getNodeConstructor: function () { return NodeObject; }, + getTokenConstructor: function () { return TokenObject; }, + getIdentifierConstructor: function () { return IdentifierObject; }, + getSourceFileConstructor: function () { return SourceFileObject; }, + getSymbolConstructor: function () { return SymbolObject; }, + getTypeConstructor: function () { return TypeObject; }, + getSignatureConstructor: function () { return SignatureObject; }, + }; + } + function toEditorSettings(optionsAsMap) { + var allPropertiesAreCamelCased = true; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key) && !isCamelCase(key)) { + allPropertiesAreCamelCased = false; + break; + } + } + if (allPropertiesAreCamelCased) { + return optionsAsMap; + } + var settings = {}; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key)) { + var newKey = isCamelCase(key) ? key : key.charAt(0).toLowerCase() + key.substr(1); + settings[newKey] = optionsAsMap[key]; + } + } + return settings; + } + ts.toEditorSettings = toEditorSettings; + function isCamelCase(s) { + return !s.length || s.charAt(0) === s.charAt(0).toLowerCase(); + } + function displayPartsToString(displayParts) { + if (displayParts) { + return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); + } + return ""; + } + ts.displayPartsToString = displayPartsToString; + function getDefaultCompilerOptions() { + return { + target: 1, + jsx: 1 + }; + } + ts.getDefaultCompilerOptions = getDefaultCompilerOptions; + function getSupportedCodeFixes() { + return ts.codefix.getSupportedErrorCodes(); + } + ts.getSupportedCodeFixes = getSupportedCodeFixes; + var HostCache = (function () { + function HostCache(host, getCanonicalFileName) { + this.host = host; + this.getCanonicalFileName = getCanonicalFileName; + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = ts.createFileMap(); + var rootFileNames = host.getScriptFileNames(); + for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { + var fileName = rootFileNames_1[_i]; + this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); + } + this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); + } + HostCache.prototype.compilationSettings = function () { + return this._compilationSettings; + }; + HostCache.prototype.createEntry = function (fileName, path) { + var entry; + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (scriptSnapshot) { + entry = { + hostFileName: fileName, + version: this.host.getScriptVersion(fileName), + scriptSnapshot: scriptSnapshot, + scriptKind: ts.getScriptKind(fileName, this.host) + }; + } + this.fileNameToEntry.set(path, entry); + return entry; + }; + HostCache.prototype.getEntry = function (path) { + return this.fileNameToEntry.get(path); + }; + HostCache.prototype.contains = function (path) { + return this.fileNameToEntry.contains(path); + }; + HostCache.prototype.getOrCreateEntry = function (fileName) { + var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); + return this.getOrCreateEntryByPath(fileName, path); + }; + HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) { + return this.contains(path) + ? this.getEntry(path) + : this.createEntry(fileName, path); + }; + HostCache.prototype.getRootFileNames = function () { + var fileNames = []; + this.fileNameToEntry.forEachValue(function (_path, value) { + if (value) { + fileNames.push(value.hostFileName); } - }; - ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typingOptions, configFileErrors) { - var errors; - for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { - var f = files_4[_i]; - var rootFilename = propertyReader.getFileName(f); - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f); - if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); - project.addRoot(info); + }); + return fileNames; + }; + HostCache.prototype.getVersion = function (path) { + var file = this.getEntry(path); + return file && file.version; + }; + HostCache.prototype.getScriptSnapshot = function (path) { + var file = this.getEntry(path); + return file && file.scriptSnapshot; + }; + return HostCache; + }()); + var SyntaxTreeCache = (function () { + function SyntaxTreeCache(host) { + this.host = host; + } + SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) { + var scriptSnapshot = this.host.getScriptSnapshot(fileName); + if (!scriptSnapshot) { + throw new Error("Could not find file: '" + fileName + "'."); + } + var scriptKind = ts.getScriptKind(fileName, this.host); + var version = this.host.getScriptVersion(fileName); + var sourceFile; + if (this.currentFileName !== fileName) { + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4, version, true, scriptKind); + } + else if (this.currentFileVersion !== version) { + var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); + sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange); + } + if (sourceFile) { + this.currentFileVersion = version; + this.currentFileName = fileName; + this.currentFileScriptSnapshot = scriptSnapshot; + this.currentSourceFile = sourceFile; + } + return this.currentSourceFile; + }; + return SyntaxTreeCache; + }()); + function setSourceFileFields(sourceFile, scriptSnapshot, version) { + sourceFile.version = version; + sourceFile.scriptSnapshot = scriptSnapshot; + } + function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) { + var text = scriptSnapshot.getText(0, scriptSnapshot.getLength()); + var sourceFile = ts.createSourceFile(fileName, text, scriptTarget, setNodeParents, scriptKind); + setSourceFileFields(sourceFile, scriptSnapshot, version); + return sourceFile; + } + ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; + ts.disableIncrementalParsing = false; + function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { + if (textChangeRange) { + if (version !== sourceFile.version) { + if (!ts.disableIncrementalParsing) { + var newText = void 0; + var prefix = textChangeRange.span.start !== 0 + ? sourceFile.text.substr(0, textChangeRange.span.start) + : ""; + var suffix = ts.textSpanEnd(textChangeRange.span) !== sourceFile.text.length + ? sourceFile.text.substr(ts.textSpanEnd(textChangeRange.span)) + : ""; + if (textChangeRange.newLength === 0) { + newText = prefix && suffix ? prefix + suffix : prefix || suffix; } else { - (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); - } - } - project.setProjectErrors(ts.concatenate(configFileErrors, errors)); - project.setTypingOptions(typingOptions); - project.updateGraph(); - }; - ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { - var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); - var projectOptions = conversionResult.success - ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; - var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); - return { - success: conversionResult.success, - project: project, - errors: project.getProjectErrors() - }; - }; - ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors) { - var oldRootScriptInfos = project.getRootScriptInfos(); - var newRootScriptInfos = []; - var newRootScriptInfoMap = server.createNormalizedPathMap(); - var projectErrors; - var rootFilesChanged = false; - for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { - var f = newUncheckedFiles_1[_i]; - var newRootFile = propertyReader.getFileName(f); - if (!this.host.fileExists(newRootFile)) { - (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); - continue; + var changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength); + newText = prefix && suffix + ? prefix + changedText + suffix + : prefix + ? (prefix + changedText) + : (changedText + suffix); } - var normalizedPath = server.toNormalizedPath(newRootFile); - var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); - if (!scriptInfo || !project.isRoot(scriptInfo)) { - rootFilesChanged = true; - if (!scriptInfo) { - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f); - scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + var newSourceFile = ts.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); + setSourceFileFields(newSourceFile, scriptSnapshot, version); + newSourceFile.nameTable = undefined; + if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) { + if (sourceFile.scriptSnapshot.dispose) { + sourceFile.scriptSnapshot.dispose(); } + sourceFile.scriptSnapshot = undefined; } - newRootScriptInfos.push(scriptInfo); - newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); + return newSourceFile; } - if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { - var toAdd = void 0; - var toRemove = void 0; - for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { - var oldFile = oldRootScriptInfos_1[_a]; - if (!newRootScriptInfoMap.contains(oldFile.fileName)) { - (toRemove || (toRemove = [])).push(oldFile); - } - } - for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { - var newFile = newRootScriptInfos_1[_b]; - if (!project.isRoot(newFile)) { - (toAdd || (toAdd = [])).push(newFile); - } - } - if (toRemove) { - for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { - var f = toRemove_1[_c]; - project.removeFile(f); - } - } - if (toAdd) { - for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { - var f = toAdd_1[_d]; - if (f.isOpen && isRootFileInInferredProject(f)) { - var inferredProject = f.containingProjects[0]; - inferredProject.removeFile(f); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); - } - } - project.addRoot(f); - } + } + } + return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, true, sourceFile.scriptKind); + } + ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile; + var CancellationTokenObject = (function () { + function CancellationTokenObject(cancellationToken) { + this.cancellationToken = cancellationToken; + } + CancellationTokenObject.prototype.isCancellationRequested = function () { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + }; + CancellationTokenObject.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return CancellationTokenObject; + }()); + function createLanguageService(host, documentRegistry) { + if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } + var syntaxTreeCache = new SyntaxTreeCache(host); + var ruleProvider; + var program; + var lastProjectVersion; + var lastTypesRootVersion = 0; + var useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); + var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + var currentDirectory = host.getCurrentDirectory(); + if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { + ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); + } + function log(message) { + if (host.log) { + host.log(message); + } + } + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitivefileNames); + function getValidSourceFile(fileName) { + var sourceFile = program.getSourceFile(fileName); + if (!sourceFile) { + throw new Error("Could not find file: '" + fileName + "'."); + } + return sourceFile; + } + function getRuleProvider(options) { + if (!ruleProvider) { + ruleProvider = new ts.formatting.RulesProvider(); + } + ruleProvider.ensureUpToDate(options); + return ruleProvider; + } + function synchronizeHostData() { + if (host.getProjectVersion) { + var hostProjectVersion = host.getProjectVersion(); + if (hostProjectVersion) { + if (lastProjectVersion === hostProjectVersion) { + return; } + lastProjectVersion = hostProjectVersion; } - project.setCompilerOptions(newOptions); - project.setTypingOptions(newTypingOptions); - if (compileOnSave !== undefined) { - project.compileOnSaveEnabled = compileOnSave; + } + var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; + if (lastTypesRootVersion !== typeRootsVersion) { + log("TypeRoots version has changed; provide new program"); + program = undefined; + lastTypesRootVersion = typeRootsVersion; + } + var hostCache = new HostCache(host, getCanonicalFileName); + if (programUpToDate()) { + return; + } + var oldSettings = program && program.getCompilerOptions(); + var newSettings = hostCache.compilationSettings(); + var shouldCreateNewSourceFiles = oldSettings && + (oldSettings.target !== newSettings.target || + oldSettings.module !== newSettings.module || + oldSettings.moduleResolution !== newSettings.moduleResolution || + oldSettings.noResolve !== newSettings.noResolve || + oldSettings.jsx !== newSettings.jsx || + oldSettings.allowJs !== newSettings.allowJs || + oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.baseUrl !== newSettings.baseUrl || + !ts.equalOwnProperties(oldSettings.paths, newSettings.paths)); + var compilerHost = { + getSourceFile: getOrCreateSourceFile, + getSourceFileByPath: getOrCreateSourceFileByPath, + getCancellationToken: function () { return cancellationToken; }, + getCanonicalFileName: getCanonicalFileName, + useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, + getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, + getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, + writeFile: function () { }, + getCurrentDirectory: function () { return currentDirectory; }, + fileExists: function (fileName) { + return hostCache.getOrCreateEntry(fileName) !== undefined; + }, + readFile: function (fileName) { + var entry = hostCache.getOrCreateEntry(fileName); + return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength()); + }, + directoryExists: function (directoryName) { + return ts.directoryProbablyExists(directoryName, host); + }, + getDirectories: function (path) { + return host.getDirectories ? host.getDirectories(path) : []; } - project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); - project.updateGraph(); }; - ProjectService.prototype.updateConfiguredProject = function (project) { - if (!this.host.fileExists(project.configFileName)) { - this.logger.info("Config file deleted"); - this.removeProject(project); - return; + if (host.trace) { + compilerHost.trace = function (message) { return host.trace(message); }; + } + if (host.resolveModuleNames) { + compilerHost.resolveModuleNames = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + if (host.resolveTypeReferenceDirectives) { + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile) { + return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile); + }; + } + var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); + var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); + if (program) { + var oldSourceFiles = program.getSourceFiles(); + var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldSettings); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; + if (!newProgram.getSourceFile(oldSourceFile.fileName) || shouldCreateNewSourceFiles) { + documentRegistry.releaseDocumentWithKey(oldSourceFile.path, oldSettingsKey); + } } - var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - if (!success) { - this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); - return configFileErrors; + } + hostCache = undefined; + program = newProgram; + program.getTypeChecker(); + return; + function getOrCreateSourceFile(fileName) { + return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName)); + } + function getOrCreateSourceFileByPath(fileName, path) { + ts.Debug.assert(hostCache !== undefined); + var hostFileInformation = hostCache.getOrCreateEntryByPath(fileName, path); + if (!hostFileInformation) { + return undefined; } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { - project.setCompilerOptions(projectOptions.compilerOptions); - if (!project.languageServiceEnabled) { - return; + if (!shouldCreateNewSourceFiles) { + var oldSourceFile = program && program.getSourceFileByPath(path); + if (oldSourceFile) { + ts.Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path); + return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } - project.disableLanguageService(); - project.stopWatchingDirectory(); } - else { - if (!project.languageServiceEnabled) { - project.enableLanguageService(); - } - this.watchConfigDirectoryForProject(project, projectOptions); - this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors); + return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + } + function sourceFileUpToDate(sourceFile) { + if (!sourceFile) { + return false; } - }; - ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { - var _this = this; - var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; - var project = useExistingProject - ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); - project.addRoot(root); - this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); - project.updateGraph(); - if (!useExistingProject) { - this.inferredProjects.push(project); + var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile.version === hostCache.getVersion(path); + } + function programUpToDate() { + if (!program) { + return false; } - return project; - }; - ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { - return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); - }; - ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { - return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - }; - ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { - var _this = this; - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - var content = void 0; - if (this.host.fileExists(fileName)) { - content = fileContent || (hasMixedContent ? "" : this.host.readFile(fileName)); - } - if (!content) { - if (openedByClient) { - content = ""; - } - } - if (content !== undefined) { - info = new server.ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent); - this.filenameToScriptInfo.set(info.path, info); - if (!info.isOpen && !hasMixedContent) { - info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); - } - } + var rootFileNames = hostCache.getRootFileNames(); + if (program.getSourceFiles().length !== rootFileNames.length) { + return false; } - if (info) { - if (fileContent !== undefined) { - info.reload(fileContent); - } - if (openedByClient) { - info.isOpen = true; - } - } - return info; - }; - ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { - return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); - }; - ProjectService.prototype.getScriptInfoForPath = function (fileName) { - return this.filenameToScriptInfo.get(fileName); - }; - ProjectService.prototype.setHostConfiguration = function (args) { - if (args.file) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); - if (info) { - info.setFormatOptions(args.formatOptions); - this.logger.info("Host configuration update for file " + args.file); - } - } - else { - if (args.hostInfo !== undefined) { - this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); - } - if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions); - this.logger.info("Format host information updated"); - } - } - }; - ProjectService.prototype.closeLog = function () { - this.logger.close(); - }; - ProjectService.prototype.reloadProjects = function () { - this.logger.info("reload projects."); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - this.openOrUpdateConfiguredProjectForFile(info.fileName); - } - this.refreshInferredProjects(); - }; - ProjectService.prototype.refreshInferredProjects = function () { - this.logger.info("updating project structure from ..."); - this.printProjects(); - var orphantedFiles = []; - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - if (info.containingProjects.length === 0) { - orphantedFiles.push(info); - } - else { - if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { - var inferredProject = info.containingProjects[0]; - ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); - inferredProject.removeFile(info); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); - } - } - } - } - for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { - var f = orphantedFiles_1[_b]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); - } - for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { - var p = _d[_c]; - p.updateGraph(); - } - this.printProjects(); - }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); - }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { - var _a = this.findContainingExternalProject(fileName) - ? {} - : this.openOrUpdateConfiguredProjectForFile(fileName), _b = _a.configFileName, configFileName = _b === void 0 ? undefined : _b, _c = _a.configFileErrors, configFileErrors = _c === void 0 ? undefined : _c; - var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); - this.assignScriptInfoToInferredProjectIfNecessary(info, true); - this.printProjects(); - return { configFileName: configFileName, configFileErrors: configFileErrors }; - }; - ProjectService.prototype.closeClientFile = function (uncheckedFileName) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - if (info) { - this.closeOpenFile(info); - info.isOpen = false; - } - this.printProjects(); - }; - ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_3 = function (proj) { - var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); - result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); - }; - for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { - var proj = currentProjects_1[_i]; - _loop_3(proj); - } - }; - ProjectService.prototype.synchronizeProjectList = function (knownProjects) { - var files = []; - this.collectChanges(knownProjects, this.externalProjects, files); - this.collectChanges(knownProjects, this.configuredProjects, files); - this.collectChanges(knownProjects, this.inferredProjects, files); - return files; - }; - ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { - var recordChangedFiles = changedFiles && !openFiles && !closedFiles; - if (openFiles) { - for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { - var file = openFiles_1[_i]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); - var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); + for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { + var fileName = rootFileNames_2[_i]; + if (!sourceFileUpToDate(program.getSourceFile(fileName))) { + return false; } } - if (changedFiles) { - for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { - var file = changedFiles_1[_a]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!!scriptInfo); - for (var i = file.changes.length - 1; i >= 0; i--) { - var change = file.changes[i]; - scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); - } - if (recordChangedFiles) { - if (!this.changedFiles) { - this.changedFiles = [scriptInfo]; - } - else if (this.changedFiles.indexOf(scriptInfo) < 0) { - this.changedFiles.push(scriptInfo); - } + return ts.compareDataObjects(program.getCompilerOptions(), hostCache.compilationSettings()); + } + } + function getProgram() { + synchronizeHostData(); + return program; + } + function cleanupSemanticCache() { + } + function dispose() { + if (program) { + ts.forEach(program.getSourceFiles(), function (f) { + return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); + }); + } + } + function getSyntacticDiagnostics(fileName) { + synchronizeHostData(); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + } + function getSemanticDiagnostics(fileName) { + synchronizeHostData(); + var targetSourceFile = getValidSourceFile(fileName); + var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); + if (!program.getCompilerOptions().declaration) { + return semanticDiagnostics; + } + var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); + return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + } + function getCompilerOptionsDiagnostics() { + synchronizeHostData(); + return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + } + function getCompletionsAtPosition(fileName, position) { + synchronizeHostData(); + return ts.Completions.getCompletionsAtPosition(host, program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position); + } + function getCompletionEntryDetails(fileName, position, entryName) { + synchronizeHostData(); + return ts.Completions.getCompletionEntryDetails(program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position, entryName); + } + function getCompletionEntrySymbol(fileName, position, entryName) { + synchronizeHostData(); + return ts.Completions.getCompletionEntrySymbol(program.getTypeChecker(), log, program.getCompilerOptions(), getValidSourceFile(fileName), position, entryName); + } + function getQuickInfoAtPosition(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); + if (node === sourceFile) { + return undefined; + } + if (ts.isLabelName(node)) { + return undefined; + } + var typeChecker = program.getTypeChecker(); + var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol || typeChecker.isUnknownSymbol(symbol)) { + switch (node.kind) { + case 70: + case 173: + case 140: + case 98: + case 166: + case 96: + var type = typeChecker.getTypeAtLocation(node); + if (type) { + return { + kind: ts.ScriptElementKind.unknown, + kindModifiers: ts.ScriptElementKindModifier.none, + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + }; } - } - } - if (closedFiles) { - for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { - var file = closedFiles_1[_b]; - this.closeClientFile(file); - } - } - if (openFiles || closedFiles) { - this.refreshInferredProjects(); - } - }; - ProjectService.prototype.closeConfiguredProject = function (configFile) { - var configuredProject = this.findConfiguredProjectByProjectName(configFile); - if (configuredProject && configuredProject.deleteOpenRef() === 0) { - this.removeProject(configuredProject); } + return undefined; + } + var displayPartsDocumentationsAndKind = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, ts.getContainerNode(node), node); + return { + kind: displayPartsDocumentationsAndKind.symbolKind, + kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), + textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), + displayParts: displayPartsDocumentationsAndKind.displayParts, + documentation: displayPartsDocumentationsAndKind.documentation }; - ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { - if (suppressRefresh === void 0) { suppressRefresh = false; } - var fileName = server.toNormalizedPath(uncheckedFileName); - var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; - if (configFiles) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { - var configFile = configFiles_1[_i]; - if (this.closeConfiguredProject(configFile)) { - shouldRefreshInferredProjects = true; - } - } - delete this.externalProjectToConfiguredProjectMap[fileName]; - if (shouldRefreshInferredProjects && !suppressRefresh) { - this.refreshInferredProjects(); - } + } + function getDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); + } + function getImplementationAtPosition(fileName, position) { + synchronizeHostData(); + return ts.GoToImplementation.getImplementationAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); + } + function getTypeDefinitionAtPosition(fileName, position) { + synchronizeHostData(); + return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); + } + function getOccurrencesAtPosition(fileName, position) { + var results = getOccurrencesAtPositionCore(fileName, position); + if (results) { + var sourceFile_2 = getCanonicalFileName(ts.normalizeSlashes(fileName)); + results = ts.filter(results, function (r) { return getCanonicalFileName(ts.normalizeSlashes(r.fileName)) === sourceFile_2; }); + } + return results; + } + function getDocumentHighlights(fileName, position, filesToSearch) { + synchronizeHostData(); + var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return program.getSourceFile(f); }); + var sourceFile = getValidSourceFile(fileName); + return ts.DocumentHighlights.getDocumentHighlights(program.getTypeChecker(), cancellationToken, sourceFile, position, sourceFilesToSearch); + } + function getOccurrencesAtPositionCore(fileName, position) { + synchronizeHostData(); + return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); + function convertDocumentHighlights(documentHighlights) { + if (!documentHighlights) { + return undefined; } - else { - var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); - if (externalProject) { - this.removeProject(externalProject); - if (!suppressRefresh) { - this.refreshInferredProjects(); - } + var result = []; + for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { + var entry = documentHighlights_1[_i]; + for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { + var highlightSpan = _b[_a]; + result.push({ + fileName: entry.fileName, + textSpan: highlightSpan.textSpan, + isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, + isDefinition: false + }); } } + return result; + } + } + function findRenameLocations(fileName, position, findInStrings, findInComments) { + var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments); + return ts.FindAllReferences.convertReferences(referencedSymbols); + } + function getReferencesAtPosition(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return ts.FindAllReferences.convertReferences(referencedSymbols); + } + function findReferences(fileName, position) { + var referencedSymbols = findReferencedSymbols(fileName, position, false, false); + return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); + } + function findReferencedSymbols(fileName, position, findInStrings, findInComments) { + synchronizeHostData(); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); + } + function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { + synchronizeHostData(); + var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); + return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); + } + function getEmitOutput(fileName, emitOnlyDtsFiles) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var outputFiles = []; + function writeFile(fileName, data, writeByteOrderMark) { + outputFiles.push({ + name: fileName, + writeByteOrderMark: writeByteOrderMark, + text: data + }); + } + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); + return { + outputFiles: outputFiles, + emitSkipped: emitOutput.emitSkipped }; - ProjectService.prototype.openExternalProject = function (proj) { - var tsConfigFiles; - var rootFiles = []; - for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { - var file = _a[_i]; - var normalized = server.toNormalizedPath(file.fileName); - if (ts.getBaseFileName(normalized) === "tsconfig.json") { - (tsConfigFiles || (tsConfigFiles = [])).push(normalized); - } - else { - rootFiles.push(file); - } - } - if (tsConfigFiles) { - tsConfigFiles.sort(); - } - var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); - var exisingConfigFiles; - if (externalProject) { - if (!tsConfigFiles) { - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, undefined); - return; - } - this.closeExternalProject(proj.projectFileName, true); + } + function getSignatureHelpItems(fileName, position) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + return ts.SignatureHelp.getSignatureHelpItems(program, sourceFile, position, cancellationToken); + } + function getNonBoundSourceFile(fileName) { + return syntaxTreeCache.getCurrentSourceFile(fileName); + } + function getSourceFile(fileName) { + return getNonBoundSourceFile(fileName); + } + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, startPos); + if (node === sourceFile) { + return; + } + switch (node.kind) { + case 173: + case 140: + case 9: + case 85: + case 100: + case 94: + case 96: + case 98: + case 166: + case 70: + break; + default: + return; + } + var nodeForStartPos = node; + while (true) { + if (ts.isRightSideOfPropertyAccess(nodeForStartPos) || ts.isRightSideOfQualifiedName(nodeForStartPos)) { + nodeForStartPos = nodeForStartPos.parent; } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { - if (!tsConfigFiles) { - this.closeExternalProject(proj.projectFileName, true); + else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { + if (nodeForStartPos.parent.parent.kind === 226 && + nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { + nodeForStartPos = nodeForStartPos.parent.parent.name; } else { - var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - var iNew = 0; - var iOld = 0; - while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { - var newConfig = tsConfigFiles[iNew]; - var oldConfig = oldConfigFiles[iOld]; - if (oldConfig < newConfig) { - this.closeConfiguredProject(oldConfig); - iOld++; - } - else if (oldConfig > newConfig) { - iNew++; - } - else { - (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); - iOld++; - iNew++; - } - } - for (var i = iOld; i < oldConfigFiles.length; i++) { - this.closeConfiguredProject(oldConfigFiles[i]); - } - } - } - if (tsConfigFiles) { - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; - for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { - var tsconfigFile = tsConfigFiles_1[_b]; - var project = this.findConfiguredProjectByProjectName(tsconfigFile); - if (!project) { - var result = this.openConfigFile(tsconfigFile); - project = result.success && result.project; - } - if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { - project.addOpenRef(); - } + break; } } else { - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions); + break; } - this.refreshInferredProjects(); - }; - return ProjectService; - }()); - server.ProjectService = ProjectService; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - function hrTimeToMilliseconds(time) { - var seconds = time[0]; - var nanoseconds = time[1]; - return ((1e9 * seconds) + nanoseconds) / 1000000.0; - } - function shouldSkipSematicCheck(project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { - return true; } - return false; + return ts.createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd()); } - function compareNumber(a, b) { - return a - b; + function getBreakpointStatementAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } - function compareFileStart(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file == b.file) { - var n = compareNumber(a.start.line, b.start.line); - if (n === 0) { - return compareNumber(a.start.offset, b.start.offset); - } - else - return n; - } - else { - return 1; - } + function getNavigationBarItems(fileName) { + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); } - function formatDiag(fileName, project, diag) { - var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); - return { - start: scriptInfo.positionToLineOffset(diag.start), - end: scriptInfo.positionToLineOffset(diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), - code: diag.code - }; + function getNavigationTree(fileName) { + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); } - function formatConfigFileDiag(diag) { - return { - start: undefined, - end: undefined, - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") - }; + function isTsOrTsxFile(fileName) { + var kind = ts.getScriptKind(fileName, host); + return kind === 3 || kind === 4; } - function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; - if (ts.textSpanEnd(edit.span) >= pos) { - return false; - } - } - return true; + function getSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + return []; + } + synchronizeHostData(); + return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } - var CommandNames; - (function (CommandNames) { - CommandNames.Brace = "brace"; - CommandNames.BraceFull = "brace-full"; - CommandNames.BraceCompletion = "braceCompletion"; - CommandNames.Change = "change"; - CommandNames.Close = "close"; - CommandNames.Completions = "completions"; - CommandNames.CompletionsFull = "completions-full"; - CommandNames.CompletionDetails = "completionEntryDetails"; - CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - CommandNames.Configure = "configure"; - CommandNames.Definition = "definition"; - CommandNames.DefinitionFull = "definition-full"; - CommandNames.Exit = "exit"; - CommandNames.Format = "format"; - CommandNames.Formatonkey = "formatonkey"; - CommandNames.FormatFull = "format-full"; - CommandNames.FormatonkeyFull = "formatonkey-full"; - CommandNames.FormatRangeFull = "formatRange-full"; - CommandNames.Geterr = "geterr"; - CommandNames.GeterrForProject = "geterrForProject"; - CommandNames.Implementation = "implementation"; - CommandNames.ImplementationFull = "implementation-full"; - CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - CommandNames.NavBar = "navbar"; - CommandNames.NavBarFull = "navbar-full"; - CommandNames.NavTree = "navtree"; - CommandNames.NavTreeFull = "navtree-full"; - CommandNames.Navto = "navto"; - CommandNames.NavtoFull = "navto-full"; - CommandNames.Occurrences = "occurrences"; - CommandNames.DocumentHighlights = "documentHighlights"; - CommandNames.DocumentHighlightsFull = "documentHighlights-full"; - CommandNames.Open = "open"; - CommandNames.Quickinfo = "quickinfo"; - CommandNames.QuickinfoFull = "quickinfo-full"; - CommandNames.References = "references"; - CommandNames.ReferencesFull = "references-full"; - CommandNames.Reload = "reload"; - CommandNames.Rename = "rename"; - CommandNames.RenameInfoFull = "rename-full"; - CommandNames.RenameLocationsFull = "renameLocations-full"; - CommandNames.Saveto = "saveto"; - CommandNames.SignatureHelp = "signatureHelp"; - CommandNames.SignatureHelpFull = "signatureHelp-full"; - CommandNames.TypeDefinition = "typeDefinition"; - CommandNames.ProjectInfo = "projectInfo"; - CommandNames.ReloadProjects = "reloadProjects"; - CommandNames.Unknown = "unknown"; - CommandNames.OpenExternalProject = "openExternalProject"; - CommandNames.OpenExternalProjects = "openExternalProjects"; - CommandNames.CloseExternalProject = "closeExternalProject"; - CommandNames.SynchronizeProjectList = "synchronizeProjectList"; - CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - CommandNames.Cleanup = "cleanup"; - CommandNames.OutliningSpans = "outliningSpans"; - CommandNames.TodoComments = "todoComments"; - CommandNames.Indentation = "indentation"; - CommandNames.DocCommentTemplate = "docCommentTemplate"; - CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; - CommandNames.BreakpointStatement = "breakpointStatement"; - CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - CommandNames.GetCodeFixes = "getCodeFixes"; - CommandNames.GetCodeFixesFull = "getCodeFixes-full"; - CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; - })(CommandNames = server.CommandNames || (server.CommandNames = {})); - function formatMessage(msg, logger, byteLength, newLine) { - var verboseLogging = logger.hasLevel(server.LogLevel.verbose); - var json = JSON.stringify(msg); - if (verboseLogging) { - logger.info(msg.type + ": " + json); + function getEncodedSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + return { spans: [], endOfLineState: 0 }; } - var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + synchronizeHostData(); + return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } - server.formatMessage = formatMessage; - var Session = (function () { - function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { - var _this = this; - this.host = host; - this.typingsInstaller = typingsInstaller; - this.byteLength = byteLength; - this.hrtime = hrtime; - this.logger = logger; - this.canUseEvents = canUseEvents; - this.changeSeq = 0; - this.handlers = ts.createMap((_a = {}, - _a[CommandNames.OpenExternalProject] = function (request) { - _this.projectService.openExternalProject(request.arguments); - return _this.requiredResponse(true); - }, - _a[CommandNames.OpenExternalProjects] = function (request) { - for (var _i = 0, _a = request.arguments.projects; _i < _a.length; _i++) { - var proj = _a[_i]; - _this.projectService.openExternalProject(proj); - } - return _this.requiredResponse(true); - }, - _a[CommandNames.CloseExternalProject] = function (request) { - _this.projectService.closeExternalProject(request.arguments.projectFileName); - return _this.requiredResponse(true); - }, - _a[CommandNames.SynchronizeProjectList] = function (request) { - var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); - if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { - return _this.requiredResponse(result); - } - var converted = ts.map(result, function (p) { - if (!p.projectErrors || p.projectErrors.length === 0) { - return p; + function getSyntacticClassifications(fileName, span) { + return ts.getSyntacticClassifications(cancellationToken, syntaxTreeCache.getCurrentSourceFile(fileName), span); + } + function getEncodedSyntacticClassifications(fileName, span) { + return ts.getEncodedSyntacticClassifications(cancellationToken, syntaxTreeCache.getCurrentSourceFile(fileName), span); + } + function getOutliningSpans(fileName) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return ts.OutliningElementsCollector.collectElements(sourceFile); + } + function getBraceMatchingAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var result = []; + var token = ts.getTouchingToken(sourceFile, position); + if (token.getStart(sourceFile) === position) { + var matchKind = getMatchingTokenKind(token); + if (matchKind) { + var parentElement = token.parent; + var childNodes = parentElement.getChildren(sourceFile); + for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { + var current = childNodes_1[_i]; + if (current.kind === matchKind) { + var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); + var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); + if (range1.start < range2.start) { + result.push(range1, range2); } - return { - info: p.info, - changes: p.changes, - files: p.files, - projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) - }; - }); - return _this.requiredResponse(converted); - }, - _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { - _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); - _this.changeSeq++; - return _this.requiredResponse(true); - }, - _a[CommandNames.Exit] = function () { - _this.exit(); - return _this.notRequired(); - }, - _a[CommandNames.Definition] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, true)); - }, - _a[CommandNames.DefinitionFull] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, false)); - }, - _a[CommandNames.TypeDefinition] = function (request) { - return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); - }, - _a[CommandNames.Implementation] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, true)); - }, - _a[CommandNames.ImplementationFull] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, false)); - }, - _a[CommandNames.References] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, true)); - }, - _a[CommandNames.ReferencesFull] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, false)); - }, - _a[CommandNames.Rename] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); - }, - _a[CommandNames.RenameLocationsFull] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); - }, - _a[CommandNames.RenameInfoFull] = function (request) { - return _this.requiredResponse(_this.getRenameInfo(request.arguments)); - }, - _a[CommandNames.Open] = function (request) { - var openArgs = request.arguments; - var scriptKind; - switch (openArgs.scriptKindName) { - case "TS": - scriptKind = 3; - break; - case "JS": - scriptKind = 1; - break; - case "TSX": - scriptKind = 4; - break; - case "JSX": - scriptKind = 2; - break; + else { + result.push(range2, range1); + } + break; } - _this.openClientFile(server.toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind); - return _this.notRequired(); - }, - _a[CommandNames.Quickinfo] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); - }, - _a[CommandNames.QuickinfoFull] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); - }, - _a[CommandNames.OutliningSpans] = function (request) { - return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); - }, - _a[CommandNames.TodoComments] = function (request) { - return _this.requiredResponse(_this.getTodoComments(request.arguments)); - }, - _a[CommandNames.Indentation] = function (request) { - return _this.requiredResponse(_this.getIndentation(request.arguments)); - }, - _a[CommandNames.NameOrDottedNameSpan] = function (request) { - return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); - }, - _a[CommandNames.BreakpointStatement] = function (request) { - return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); - }, - _a[CommandNames.BraceCompletion] = function (request) { - return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); - }, - _a[CommandNames.DocCommentTemplate] = function (request) { - return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); - }, - _a[CommandNames.Format] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); - }, - _a[CommandNames.Formatonkey] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); - }, - _a[CommandNames.FormatFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); - }, - _a[CommandNames.FormatonkeyFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); - }, - _a[CommandNames.FormatRangeFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); - }, - _a[CommandNames.Completions] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, true)); - }, - _a[CommandNames.CompletionsFull] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, false)); - }, - _a[CommandNames.CompletionDetails] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); - }, - _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { - return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); - }, - _a[CommandNames.CompileOnSaveEmitFile] = function (request) { - return _this.requiredResponse(_this.emitFile(request.arguments)); - }, - _a[CommandNames.SignatureHelp] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); - }, - _a[CommandNames.SignatureHelpFull] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { - return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); - }, - _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { - return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); - }, - _a[CommandNames.Cleanup] = function (request) { - _this.cleanup(); - return _this.requiredResponse(true); - }, - _a[CommandNames.SemanticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.Geterr] = function (request) { - var geterrArgs = request.arguments; - return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; - }, - _a[CommandNames.GeterrForProject] = function (request) { - var _a = request.arguments, file = _a.file, delay = _a.delay; - return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; - }, - _a[CommandNames.Change] = function (request) { - _this.change(request.arguments); - return _this.notRequired(); - }, - _a[CommandNames.Configure] = function (request) { - _this.projectService.setHostConfiguration(request.arguments); - _this.output(undefined, CommandNames.Configure, request.seq); - return _this.notRequired(); - }, - _a[CommandNames.Reload] = function (request) { - _this.reload(request.arguments, request.seq); - return _this.requiredResponse({ reloadFinished: true }); - }, - _a[CommandNames.Saveto] = function (request) { - var savetoArgs = request.arguments; - _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return _this.notRequired(); - }, - _a[CommandNames.Close] = function (request) { - var closeArgs = request.arguments; - _this.closeClientFile(closeArgs.file); - return _this.notRequired(); - }, - _a[CommandNames.Navto] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); - }, - _a[CommandNames.NavtoFull] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); - }, - _a[CommandNames.Brace] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); - }, - _a[CommandNames.BraceFull] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); - }, - _a[CommandNames.NavBar] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); - }, - _a[CommandNames.NavBarFull] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); - }, - _a[CommandNames.NavTree] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); - }, - _a[CommandNames.NavTreeFull] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); - }, - _a[CommandNames.Occurrences] = function (request) { - return _this.requiredResponse(_this.getOccurrences(request.arguments)); - }, - _a[CommandNames.DocumentHighlights] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); - }, - _a[CommandNames.DocumentHighlightsFull] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { - return _this.requiredResponse(_this.setCompilerOptionsForInferredProjects(request.arguments)); - }, - _a[CommandNames.ProjectInfo] = function (request) { - return _this.requiredResponse(_this.getProjectInfo(request.arguments)); - }, - _a[CommandNames.ReloadProjects] = function (request) { - _this.projectService.reloadProjects(); - return _this.notRequired(); - }, - _a[CommandNames.GetCodeFixes] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); - }, - _a[CommandNames.GetCodeFixesFull] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); - }, - _a[CommandNames.GetSupportedCodeFixes] = function (request) { - return _this.requiredResponse(_this.getSupportedCodeFixes()); - }, - _a)); - this.eventHander = canUseEvents - ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) - : undefined; - this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); - this.gcTimer = new server.GcTimer(host, 7000, logger); - var _a; - } - Session.prototype.defaultEventHandler = function (event) { - var _this = this; - switch (event.eventName) { - case "context": - var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); - break; - case "configFileDiag": - var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; - this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); - } - }; - Session.prototype.logError = function (err, cmd) { - var msg = "Exception on executing command " + cmd; - if (err.message) { - msg += ":\n" + err.message; - if (err.stack) { - msg += "\n" + err.stack; } } - this.logger.msg(msg, server.Msg.Err); - }; - Session.prototype.send = function (msg) { - if (msg.type === "event" && !this.canUseEvents) { - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); - } - return; + } + return result; + function getMatchingTokenKind(token) { + switch (token.kind) { + case 16: return 17; + case 18: return 19; + case 20: return 21; + case 26: return 28; + case 17: return 16; + case 19: return 18; + case 21: return 20; + case 28: return 26; } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); - }; - Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { - var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); - var ev = { - seq: 0, - type: "event", - event: "configFileDiag", - body: { - triggerFile: triggerFile, - configFile: configFile, - diagnostics: bakedDiags - } - }; - this.send(ev); - }; - Session.prototype.event = function (info, eventName) { - var ev = { - seq: 0, - type: "event", - event: eventName, - body: info - }; - this.send(ev); - }; - Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { - if (reqSeq === void 0) { reqSeq = 0; } - var res = { - seq: 0, - type: "response", - command: cmdName, - request_seq: reqSeq, - success: !errorMsg + return undefined; + } + } + function getIndentationAtPosition(fileName, position, editorOptions) { + var start = ts.timestamp(); + var settings = toEditorSettings(editorOptions); + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + log("getIndentationAtPosition: getCurrentSourceFile: " + (ts.timestamp() - start)); + start = ts.timestamp(); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, settings); + log("getIndentationAtPosition: computeIndentation : " + (ts.timestamp() - start)); + return result; + } + function getFormattingEditsForRange(fileName, start, end, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var settings = toEditorSettings(options); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(settings), settings); + } + function getFormattingEditsForDocument(fileName, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var settings = toEditorSettings(options); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(settings), settings); + } + function getFormattingEditsAfterKeystroke(fileName, position, key, options) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var settings = toEditorSettings(options); + if (key === "}") { + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === ";") { + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); + } + else if (key === "\n") { + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); + } + return []; + } + function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var span = { start: start, length: end - start }; + var newLineChar = ts.getNewLineOrDefaultFromHost(host); + var allFixes = []; + ts.forEach(errorCodes, function (error) { + cancellationToken.throwIfCancellationRequested(); + var context = { + errorCode: error, + sourceFile: sourceFile, + span: span, + program: program, + newLineCharacter: newLineChar }; - if (!errorMsg) { - res.body = info; - } - else { - res.message = errorMsg; - } - this.send(res); - }; - Session.prototype.semanticCheck = function (file, project) { - try { - var diags = []; - if (!shouldSkipSematicCheck(project)) { - diags = project.getLanguageService().getSemanticDiagnostics(file); - } - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); - } - catch (err) { - this.logError(err, "semantic check"); + var fixes = ts.codefix.getFixes(context); + if (fixes) { + allFixes = allFixes.concat(fixes); } - }; - Session.prototype.syntacticCheck = function (file, project) { - try { - var diags = project.getLanguageService().getSyntacticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); - } - } - catch (err) { - this.logError(err, "syntactic check"); - } - }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { - var _this = this; - if (ms === void 0) { ms = 1500; } - this.host.setTimeout(function () { - if (matchSeq(seq)) { - _this.projectService.refreshInferredProjects(); - } - }, ms); - }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { - var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } - if (requireOpen === void 0) { requireOpen = true; } - if (followMs > ms) { - followMs = ms; - } - if (this.errorTimer) { - this.host.clearTimeout(this.errorTimer); - } - if (this.immediateId) { - this.host.clearImmediate(this.immediateId); - this.immediateId = undefined; - } - var index = 0; - var checkOne = function () { - if (matchSeq(seq)) { - var checkSpec_1 = checkList[index]; - index++; - if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { - _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = _this.host.setImmediate(function () { - _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = undefined; - if (checkList.length > index) { - _this.errorTimer = _this.host.setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; - } - }); - } - } - }; - if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = this.host.setTimeout(checkOne, ms); - } - }; - Session.prototype.cleanProjects = function (caption, projects) { - if (!projects) { - return; - } - this.logger.info("cleaning " + caption); - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var p = projects_4[_i]; - p.getLanguageService(false).cleanupSemanticCache(); - } - }; - Session.prototype.cleanup = function () { - this.cleanProjects("inferred projects", this.projectService.inferredProjects); - this.cleanProjects("configured projects", this.projectService.configuredProjects); - this.cleanProjects("external projects", this.projectService.externalProjects); - if (this.host.gc) { - this.logger.info("host.gc()"); - this.host.gc(); - } - }; - Session.prototype.getEncodedSemanticClassifications = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEncodedSemanticClassifications(file, args); - }; - Session.prototype.getProject = function (projectFileName) { - return projectFileName && this.projectService.findProject(projectFileName); - }; - Session.prototype.getCompilerOptionsDiagnostics = function (args) { - var project = this.getProject(args.projectFileName); - return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); - }; - Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { - var _this = this; - return diagnostics.map(function (d) { return ({ - message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), - start: d.start, - length: d.length, - category: ts.DiagnosticCategory[d.category].toLowerCase(), - code: d.code, - startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), - endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) - }); }); - }; - Session.prototype.getDiagnosticsWorker = function (args, selector, includeLinePosition) { - var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (shouldSkipSematicCheck(project)) { - return []; - } - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var diagnostics = selector(project, file); - return includeLinePosition - ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) - : diagnostics.map(function (d) { return formatDiag(file, project, d); }); - }; - Session.prototype.getDefinition = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - if (simplifiedResult) { - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); - } - else { - return definitions; - } - }; - Session.prototype.getTypeDefinition = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); - }; - Session.prototype.getImplementation = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var implementations = project.getLanguageService().getImplementationAtPosition(file, position); - if (!implementations) { - return []; - } - if (simplifiedResult) { - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: scriptInfo.positionToLineOffset(impl.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) - }); }); - } - else { - return implementations; - } - }; - Session.prototype.getOccurrences = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); - if (!occurrences) { - return undefined; - } - return occurrences.map(function (occurrence) { - var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; - var scriptInfo = project.getScriptInfo(fileName); - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { - start: start, - end: end, - file: fileName, - isWriteAccess: isWriteAccess - }; - }); - }; - Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); - }; - Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); - }; - Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); - if (!documentHighlights) { - return undefined; - } - if (simplifiedResult) { - return documentHighlights.map(convertToDocumentHighlightsItem); - } - else { - return documentHighlights; - } - function convertToDocumentHighlightsItem(documentHighlights) { - var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; - var scriptInfo = project.getScriptInfo(fileName); - return { - file: fileName, - highlightSpans: highlightSpans.map(convertHighlightSpan) - }; - function convertHighlightSpan(highlightSpan) { - var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { start: start, end: end, kind: kind }; - } - } - }; - Session.prototype.setCompilerOptionsForInferredProjects = function (args) { - this.projectService.setCompilerOptionsForInferredProjects(args.options); - }; - Session.prototype.getProjectInfo = function (args) { - return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); - }; - Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { - var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; - var projectInfo = { - configFileName: project.getProjectName(), - languageServiceDisabled: !project.languageServiceEnabled, - fileNames: needFileNameList ? project.getFileNames() : undefined - }; - return projectInfo; - }; - Session.prototype.getRenameInfo = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return project.getLanguageService().getRenameInfo(file, position); - }; - Session.prototype.getProjects = function (args) { - var projects; - if (args.projectFileName) { - var project = this.getProject(args.projectFileName); - if (project) { - projects = [project]; - } - } - else { - var scriptInfo = this.projectService.getScriptInfo(args.file); - projects = scriptInfo.containingProjects; - } - projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); - if (!projects || !projects.length) { - return server.Errors.ThrowNoProject(); - } - return projects; - }; - Session.prototype.getRenameLocations = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var info = this.projectService.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, info); - var projects = this.getProjects(args); - if (simplifiedResult) { - var defaultProject = projects[0]; - var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; + }); + return allFixes; + } + function getDocCommentTemplateAtPosition(fileName, position) { + return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); + } + function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { + if (openingBrace === 60) { + return false; + } + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position)) { + return false; + } + if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { + return openingBrace === 123; + } + if (ts.isInTemplateString(sourceFile, position)) { + return false; + } + return true; + } + function getTodoComments(fileName, descriptors) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + cancellationToken.throwIfCancellationRequested(); + var fileContents = sourceFile.text; + var result = []; + if (descriptors.length > 0) { + var regExp = getTodoCommentsRegExp(); + var matchArray = void 0; + while (matchArray = regExp.exec(fileContents)) { + cancellationToken.throwIfCancellationRequested(); + var firstDescriptorCaptureIndex = 3; + ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); + var preamble = matchArray[1]; + var matchPosition = matchArray.index + preamble.length; + var token = ts.getTokenAtPosition(sourceFile, matchPosition); + if (!ts.isInsideComment(sourceFile, token, matchPosition)) { + continue; } - var fileSpans = server.combineProjectOutput(projects, function (project) { - var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); - if (!renameLocations) { - return []; - } - return renameLocations.map(function (location) { - var locationScriptInfo = project.getScriptInfo(location.fileName); - return { - file: location.fileName, - start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)) - }; - }); - }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); - var locs = fileSpans.reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; - } - } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); + var descriptor = undefined; + for (var i = 0, n = descriptors.length; i < n; i++) { + if (matchArray[i + firstDescriptorCaptureIndex]) { + descriptor = descriptors[i]; } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: locs }; - } - else { - return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); - } - function renameLocationIsEqualTo(a, b) { - if (a === b) { - return true; } - if (!a || !b) { - return false; + ts.Debug.assert(descriptor !== undefined); + if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { + continue; } - return a.fileName === b.fileName && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; + var message = matchArray[2]; + result.push({ + descriptor: descriptor, + message: message, + position: matchPosition + }); } - function compareRenameLocation(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file > b.file) { - return 1; + } + return result; + function escapeRegExp(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); + } + function getTodoCommentsRegExp() { + var singleLineCommentStart = /(?:\/\/+\s*)/.source; + var multiLineCommentStart = /(?:\/\*+\s*)/.source; + var anyNumberOfSpacesAndAsterisksAtStartOfLine = /(?:^(?:\s|\*)*)/.source; + var preamble = "(" + anyNumberOfSpacesAndAsterisksAtStartOfLine + "|" + singleLineCommentStart + "|" + multiLineCommentStart + ")"; + var literals = "(?:" + ts.map(descriptors, function (d) { return "(" + escapeRegExp(d.text) + ")"; }).join("|") + ")"; + var endOfLineOrEndOfComment = /(?:$|\*\/)/.source; + var messageRemainder = /(?:.*?)/.source; + var messagePortion = "(" + literals + messageRemainder + ")"; + var regExpString = preamble + messagePortion + endOfLineOrEndOfComment; + return new RegExp(regExpString, "gim"); + } + function isLetterOrDigit(char) { + return (char >= 97 && char <= 122) || + (char >= 65 && char <= 90) || + (char >= 48 && char <= 57); + } + } + function getRenameInfo(fileName, position) { + synchronizeHostData(); + var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); + return ts.Rename.getRenameInfo(program.getTypeChecker(), defaultLibFileName, getCanonicalFileName, getValidSourceFile(fileName), position); + } + return { + dispose: dispose, + cleanupSemanticCache: cleanupSemanticCache, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics, + getSyntacticClassifications: getSyntacticClassifications, + getSemanticClassifications: getSemanticClassifications, + getEncodedSyntacticClassifications: getEncodedSyntacticClassifications, + getEncodedSemanticClassifications: getEncodedSemanticClassifications, + getCompletionsAtPosition: getCompletionsAtPosition, + getCompletionEntryDetails: getCompletionEntryDetails, + getCompletionEntrySymbol: getCompletionEntrySymbol, + getSignatureHelpItems: getSignatureHelpItems, + getQuickInfoAtPosition: getQuickInfoAtPosition, + getDefinitionAtPosition: getDefinitionAtPosition, + getImplementationAtPosition: getImplementationAtPosition, + getTypeDefinitionAtPosition: getTypeDefinitionAtPosition, + getReferencesAtPosition: getReferencesAtPosition, + findReferences: findReferences, + getOccurrencesAtPosition: getOccurrencesAtPosition, + getDocumentHighlights: getDocumentHighlights, + getNameOrDottedNameSpan: getNameOrDottedNameSpan, + getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, + getNavigateToItems: getNavigateToItems, + getRenameInfo: getRenameInfo, + findRenameLocations: findRenameLocations, + getNavigationBarItems: getNavigationBarItems, + getNavigationTree: getNavigationTree, + getOutliningSpans: getOutliningSpans, + getTodoComments: getTodoComments, + getBraceMatchingAtPosition: getBraceMatchingAtPosition, + getIndentationAtPosition: getIndentationAtPosition, + getFormattingEditsForRange: getFormattingEditsForRange, + getFormattingEditsForDocument: getFormattingEditsForDocument, + getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, + getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, + isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getCodeFixesAtPosition: getCodeFixesAtPosition, + getEmitOutput: getEmitOutput, + getNonBoundSourceFile: getNonBoundSourceFile, + getSourceFile: getSourceFile, + getProgram: getProgram + }; + } + ts.createLanguageService = createLanguageService; + function getNameTable(sourceFile) { + if (!sourceFile.nameTable) { + initializeNameTable(sourceFile); + } + return sourceFile.nameTable; + } + ts.getNameTable = getNameTable; + function initializeNameTable(sourceFile) { + var nameTable = ts.createMap(); + walk(sourceFile); + sourceFile.nameTable = nameTable; + function walk(node) { + switch (node.kind) { + case 70: + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; + break; + case 9: + case 8: + if (ts.isDeclarationName(node) || + node.parent.kind === 241 || + isArgumentOfElementAccessExpression(node) || + ts.isLiteralComputedPropertyDeclarationName(node)) { + nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; } - else { - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; - } - else { - return b.start.offset - a.start.offset; + break; + default: + ts.forEachChild(node, walk); + if (node.jsDocComments) { + for (var _i = 0, _a = node.jsDocComments; _i < _a.length; _i++) { + var jsDocComment = _a[_i]; + ts.forEachChild(jsDocComment, walk); } } - } - }; - Session.prototype.getReferences = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var projects = this.getProjects(args); - var defaultProject = projects[0]; - var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - if (simplifiedResult) { - var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; - var nameText = scriptInfo.snap().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var refs = server.combineProjectOutput(projects, function (project) { - var references = project.getLanguageService().getReferencesAtPosition(file, position); - if (!references) { - return []; - } - return references.map(function (ref) { - var refScriptInfo = project.getScriptInfo(ref.fileName); + } + } + } + function isArgumentOfElementAccessExpression(node) { + return node && + node.parent && + node.parent.kind === 174 && + node.parent.argumentExpression === node; + } + function getDefaultLibFilePath(options) { + if (typeof __dirname !== "undefined") { + return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); + } + throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); + } + ts.getDefaultLibFilePath = getDefaultLibFilePath; + function initializeServices() { + ts.objectAllocator = getServicesObjectAllocator(); + } + initializeServices(); +})(ts || (ts = {})); +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } + } + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + }()); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof result === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: result }) : result; + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (_dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + }()); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + return LanguageServiceShimObject; + }(ShimBase)); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; + } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; + } + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typingOptions: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; + } + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typingOptions: configFile.typingOptions, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); + }); + }; + return CoreServicesShimObject; + }(ShimBase)); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); + } + catch (err) { + logInternalError(logger, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0, n = this._shims.length; i < n; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; + return; + } + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + }()); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } +})(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "2.1"; +var ts; +(function (ts) { + var server; + (function (server) { + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(server.LogLevel || (server.LogLevel = {})); + var 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, typingOptions, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + 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, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: 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 throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + 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 ScriptInfo = (function () { + function ScriptInfo(host, fileName, content, scriptKind, isOpen, hasMixedContent) { + if (isOpen === void 0) { isOpen = false; } + if (hasMixedContent === void 0) { hasMixedContent = false; } + this.host = host; + this.fileName = fileName; + this.scriptKind = scriptKind; + this.isOpen = isOpen; + this.hasMixedContent = hasMixedContent; + this.containingProjects = []; + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.svc = server.ScriptVersionCache.fromString(host, content); + this.scriptKind = scriptKind + ? scriptKind + : ts.getScriptKindFromFileName(fileName); + } + ScriptInfo.prototype.getFormatCodeSettings = function () { + return this.formatCodeSettings; + }; + ScriptInfo.prototype.attachToProject = function (project) { + var isNew = !this.isAttached(project); + if (isNew) { + this.containingProjects.push(project); + } + return isNew; + }; + ScriptInfo.prototype.isAttached = function (project) { + switch (this.containingProjects.length) { + case 0: return false; + case 1: return this.containingProjects[0] === project; + case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; + default: return ts.contains(this.containingProjects, project); + } + }; + ScriptInfo.prototype.detachFromProject = function (project) { + switch (this.containingProjects.length) { + case 0: + return; + case 1: + if (this.containingProjects[0] === project) { + this.containingProjects.pop(); + } + break; + case 2: + if (this.containingProjects[0] === project) { + this.containingProjects[0] = this.containingProjects.pop(); + } + else if (this.containingProjects[1] === project) { + this.containingProjects.pop(); + } + break; + default: + server.removeItemFromSet(this.containingProjects, project); + break; + } + }; + ScriptInfo.prototype.detachAllProjects = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.removeFile(this, false); + } + this.containingProjects.length = 0; + }; + ScriptInfo.prototype.getDefaultProject = function () { + if (this.containingProjects.length === 0) { + return server.Errors.ThrowNoProject(); + } + return this.containingProjects[0]; + }; + ScriptInfo.prototype.setFormatOptions = function (formatSettings) { + if (formatSettings) { + if (!this.formatCodeSettings) { + this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); + } + server.mergeMaps(this.formatCodeSettings, formatSettings); + } + }; + ScriptInfo.prototype.setWatcher = function (watcher) { + this.stopWatcher(); + this.fileWatcher = watcher; + }; + ScriptInfo.prototype.stopWatcher = function () { + if (this.fileWatcher) { + this.fileWatcher.close(); + this.fileWatcher = undefined; + } + }; + ScriptInfo.prototype.getLatestVersion = function () { + return this.svc.latestVersion().toString(); + }; + ScriptInfo.prototype.reload = function (script) { + this.svc.reload(script); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.saveTo = function (fileName) { + var snap = this.snap(); + this.host.writeFile(fileName, snap.getText(0, snap.getLength())); + }; + ScriptInfo.prototype.reloadFromFile = function (tempFileName) { + if (this.hasMixedContent) { + this.reload(""); + } + else { + this.svc.reloadFromFile(tempFileName || this.fileName); + this.markContainingProjectsAsDirty(); + } + }; + ScriptInfo.prototype.snap = function () { + return this.svc.getSnapshot(); + }; + ScriptInfo.prototype.getLineInfo = function (line) { + var snap = this.snap(); + return snap.index.lineNumberToInfo(line); + }; + ScriptInfo.prototype.editContent = function (start, end, newText) { + this.svc.edit(start, end - start, newText); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.markContainingProjectsAsDirty = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.markAsDirty(); + } + }; + ScriptInfo.prototype.lineToTextSpan = function (line) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line + 1); + var len; + if (lineInfo.leaf) { + len = lineInfo.leaf.text.length; + } + else { + var nextLineInfo = index.lineNumberToInfo(line + 2); + len = nextLineInfo.offset - lineInfo.offset; + } + return ts.createTextSpan(lineInfo.offset, len); + }; + ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line); + return (lineInfo.offset + offset - 1); + }; + ScriptInfo.prototype.positionToLineOffset = function (position) { + var index = this.snap().index; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; + }; + return ScriptInfo; + }()); + server.ScriptInfo = ScriptInfo; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LSHost = (function () { + function LSHost(host, project, cancellationToken) { + var _this = this; + this.host = host; + this.project = project; + this.cancellationToken = cancellationToken; + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(); + this.resolvedTypeReferenceDirectives = ts.createFileMap(); + if (host.trace) { + this.trace = function (s) { return host.trace(s); }; + } + this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); + if (primaryResult.resolvedModule) { + if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { + return primaryResult; + } + } + var secondaryLookupFailedLookupLocations = []; + var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; + if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { + var traceEnabled = ts.isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; + var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); + if (resolvedName) { + return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); + } + } + if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { + primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); + } + return primaryResult; + }; + } + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = cache.get(path); + var newResolutions = ts.createMap(); + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name_52 = names_3[_i]; + var resolution = newResolutions[name_52]; + if (!resolution) { + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(getResult(resolution)); + } + cache.set(path, newResolutions); + return resolvedModules; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + var result = getResult(resolution); + if (result) { + if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { + return false; + } + return true; + } + return resolution.failedLookupLocations.length === 0; + } + }; + LSHost.prototype.getProjectVersion = function () { + return this.project.getProjectVersion(); + }; + LSHost.prototype.getCompilationSettings = function () { + return this.compilationSettings; + }; + LSHost.prototype.useCaseSensitiveFileNames = function () { + return this.host.useCaseSensitiveFileNames; + }; + LSHost.prototype.getCancellationToken = function () { + return this.cancellationToken; + }; + LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); + }; + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }); + }; + LSHost.prototype.getDefaultLibFileName = function () { + var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); + return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); + }; + LSHost.prototype.getScriptSnapshot = function (filename) { + var scriptInfo = this.project.getScriptInfoLSHost(filename); + if (scriptInfo) { + return scriptInfo.snap(); + } + }; + LSHost.prototype.getScriptFileNames = function () { + return this.project.getRootFilesLSHost(); + }; + LSHost.prototype.getTypeRootsVersion = function () { + return this.project.typesVersion; + }; + LSHost.prototype.getScriptKind = function (fileName) { + var info = this.project.getScriptInfoLSHost(fileName); + return info && info.scriptKind; + }; + LSHost.prototype.getScriptVersion = function (filename) { + var info = this.project.getScriptInfoLSHost(filename); + return info && info.getLatestVersion(); + }; + LSHost.prototype.getCurrentDirectory = function () { + return this.host.getCurrentDirectory(); + }; + LSHost.prototype.resolvePath = function (path) { + return this.host.resolvePath(path); + }; + LSHost.prototype.fileExists = function (path) { + return this.host.fileExists(path); + }; + LSHost.prototype.readFile = function (fileName) { + return this.host.readFile(fileName); + }; + LSHost.prototype.directoryExists = function (path) { + return this.host.directoryExists(path); + }; + LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { + return this.host.readDirectory(path, extensions, exclude, include); + }; + LSHost.prototype.getDirectories = function (path) { + return this.host.getDirectories(path); + }; + LSHost.prototype.notifyFileRemoved = function (info) { + this.resolvedModuleNames.remove(info.path); + this.resolvedTypeReferenceDirectives.remove(info.path); + }; + LSHost.prototype.setCompilationSettings = function (opt) { + this.compilationSettings = opt; + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + }; + return LSHost; + }()); + server.LSHost = LSHost; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.nullTypingsInstaller = { + enqueueInstallTypingsRequest: function () { }, + attach: function () { }, + onProjectClosed: function () { }, + globalTypingsCacheLocation: undefined + }; + var TypingsCacheEntry = (function () { + function TypingsCacheEntry() { + } + return TypingsCacheEntry; + }()); + function setIsEqualTo(arr1, arr2) { + if (arr1 === arr2) { + return true; + } + if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { + return true; + } + var set = ts.createMap(); + var unique = 0; + for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { + var v = arr1_1[_i]; + if (set[v] !== true) { + set[v] = true; + unique++; + } + } + for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { + var v = arr2_1[_a]; + if (!ts.hasProperty(set, v)) { + return false; + } + if (set[v] === true) { + set[v] = false; + unique--; + } + } + return unique === 0; + } + function typingOptionsChanged(opt1, opt2) { + return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery || + !setIsEqualTo(opt1.include, opt2.include) || + !setIsEqualTo(opt1.exclude, opt2.exclude); + } + function compilerOptionsChanged(opt1, opt2) { + return opt1.allowJs != opt2.allowJs; + } + function toTypingsArray(arr) { + arr.sort(); + return arr; + } + var TypingsCache = (function () { + function TypingsCache(installer) { + this.installer = installer; + this.perProjectCache = ts.createMap(); + } + TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return server.emptyArray; + } + var entry = this.perProjectCache[project.getProjectName()]; + var result = entry ? entry.typings : server.emptyArray; + if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { + this.perProjectCache[project.getProjectName()] = { + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + typings: result, + poisoned: true + }; + this.installer.enqueueInstallTypingsRequest(project, typingOptions); + } + return result; + }; + TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions.enableAutoDiscovery) { + return; + } + this.installer.enqueueInstallTypingsRequest(project, typingOptions); + }; + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { + this.perProjectCache[projectName] = { + compilerOptions: compilerOptions, + typingOptions: typingOptions, + typings: toTypingsArray(newTypings), + poisoned: false + }; + }; + TypingsCache.prototype.onProjectClosed = function (project) { + delete this.perProjectCache[project.getProjectName()]; + this.installer.onProjectClosed(project); + }; + return TypingsCache; + }()); + server.TypingsCache = TypingsCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var crypto = require("crypto"); + 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 !== 226 || statement.name.kind !== 9) { + return false; + } + } + return true; + }; + BuilderFileInfo.prototype.computeHash = function (text) { + return crypto.createHash("md5") + .update(text) + .digest("base64"); + }; + 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; + this.fileInfos = ts.createFileMap(); + } + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.fileInfos.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.fileInfos.getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.fileInfos.set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.fileInfos.remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.fileInfos.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.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.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) { + (function (ProjectKind) { + ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; + ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; + ProjectKind[ProjectKind["External"] = 2] = "External"; + })(server.ProjectKind || (server.ProjectKind = {})); + var ProjectKind = server.ProjectKind; + function remove(items, item) { + var index = items.indexOf(item); + if (index >= 0) { + items.splice(index, 1); + } + } + function countEachFileTypes(infos) { + var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + switch (info.scriptKind) { + case 1: + result.js += 1; + break; + case 2: + result.jsx += 1; + break; + case 3: + ts.fileExtensionIs(info.fileName, ".d.ts") + ? result.dts += 1 + : result.ts += 1; + break; + case 4: + result.tsx += 1; + break; + } + } + return result; + } + function hasOneOrMoreJsAndNoTsFiles(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; + } + function allRootFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getRootScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; + function allFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var Project = (function () { + function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + this.projectKind = projectKind; + this.projectService = projectService; + this.documentRegistry = documentRegistry; + this.languageServiceEnabled = languageServiceEnabled; + this.compilerOptions = compilerOptions; + this.compileOnSaveEnabled = compileOnSaveEnabled; + this.rootFiles = []; + this.rootFilesMap = ts.createFileMap(); + this.lastReportedVersion = 0; + this.projectStructureVersion = 0; + this.projectStateVersion = 0; + this.typesVersion = 0; + if (!this.compilerOptions) { + this.compilerOptions = ts.getDefaultCompilerOptions(); + this.compilerOptions.allowNonTsExtensions = true; + this.compilerOptions.allowJs = true; + } + else if (hasExplicitListOfFiles) { + this.compilerOptions.allowNonTsExtensions = true; + } + if (languageServiceEnabled) { + this.enableLanguageService(); + } + else { + this.disableLanguageService(); + } + this.builder = server.createBuilder(this); + this.markAsDirty(); + } + Project.prototype.isNonTsProject = function () { + this.updateGraph(); + return allFilesAreJsOrDts(this); + }; + Project.prototype.isJsOnlyProject = function () { + this.updateGraph(); + return hasOneOrMoreJsAndNoTsFiles(this); + }; + Project.prototype.getProjectErrors = function () { + return this.projectErrors; + }; + Project.prototype.getLanguageService = function (ensureSynchronized) { + if (ensureSynchronized === void 0) { ensureSynchronized = true; } + if (ensureSynchronized) { + this.updateGraph(); + } + return this.languageService; + }; + Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { + if (!this.languageServiceEnabled) { + return []; + } + this.updateGraph(); + return this.builder.getFilesAffectedBy(scriptInfo); + }; + Project.prototype.getProjectVersion = function () { + return this.projectStateVersion.toString(); + }; + Project.prototype.enableLanguageService = function () { + var lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); + lsHost.setCompilationSettings(this.compilerOptions); + this.languageService = ts.createLanguageService(lsHost, this.documentRegistry); + this.lsHost = lsHost; + this.languageServiceEnabled = true; + }; + Project.prototype.disableLanguageService = function () { + this.languageService = server.nullLanguageService; + this.lsHost = server.nullLanguageServiceHost; + this.languageServiceEnabled = false; + }; + Project.prototype.getSourceFile = function (path) { + if (!this.program) { + return undefined; + } + return this.program.getSourceFileByPath(path); + }; + Project.prototype.updateTypes = function () { + this.typesVersion++; + this.markAsDirty(); + this.updateGraph(); + }; + Project.prototype.close = function () { + if (this.program) { + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + var info = this.projectService.getScriptInfo(f.fileName); + info.detachFromProject(this); + } + } + else { + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; + root.detachFromProject(this); + } + } + this.rootFiles = undefined; + this.rootFilesMap = undefined; + this.program = undefined; + this.languageService.dispose(); + }; + Project.prototype.getCompilerOptions = function () { + return this.compilerOptions; + }; + Project.prototype.hasRoots = function () { + return this.rootFiles && this.rootFiles.length > 0; + }; + Project.prototype.getRootFiles = function () { + return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); + }; + Project.prototype.getRootFilesLSHost = function () { + var result = []; + if (this.rootFiles) { + for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { + var f = _a[_i]; + result.push(f.fileName); + } + if (this.typingFiles) { + for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { + var f = _c[_b]; + result.push(f); + } + } + } + return result; + }; + Project.prototype.getRootScriptInfos = function () { + return this.rootFiles; + }; + Project.prototype.getScriptInfos = function () { + var _this = this; + return ts.map(this.program.getSourceFiles(), function (sourceFile) { + var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); + if (!scriptInfo) { + ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + } + return scriptInfo; + }); + }; + Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { + if (!this.languageServiceEnabled) { + return undefined; + } + return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); + }; + Project.prototype.getFileNames = function () { + if (!this.program) { + return []; + } + if (!this.languageServiceEnabled) { + var rootFiles = this.getRootFiles(); + if (this.compilerOptions) { + var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); + if (defaultLibrary) { + (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + } + } + return rootFiles; + } + var sourceFiles = this.program.getSourceFiles(); + return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); + }; + Project.prototype.getAllEmittableFiles = function () { + if (!this.languageServiceEnabled) { + return []; + } + var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); + var infos = this.getScriptInfos(); + var result = []; + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { + result.push(info.fileName); + } + } + return result; + }; + Project.prototype.containsScriptInfo = function (info) { + return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); + }; + Project.prototype.containsFile = function (filename, requireOpen) { + var info = this.projectService.getScriptInfoForNormalizedPath(filename); + if (info && (info.isOpen || !requireOpen)) { + return this.containsScriptInfo(info); + } + }; + Project.prototype.isRoot = function (info) { + return this.rootFilesMap && this.rootFilesMap.contains(info.path); + }; + Project.prototype.addRoot = function (info) { + if (!this.isRoot(info)) { + this.rootFiles.push(info); + this.rootFilesMap.set(info.path, info); + info.attachToProject(this); + this.markAsDirty(); + } + }; + Project.prototype.removeFile = function (info, detachFromProject) { + if (detachFromProject === void 0) { detachFromProject = true; } + this.removeRootFileIfNecessary(info); + this.lsHost.notifyFileRemoved(info); + if (detachFromProject) { + info.detachFromProject(this); + } + this.markAsDirty(); + }; + Project.prototype.markAsDirty = function () { + this.projectStateVersion++; + }; + Project.prototype.updateGraph = function () { + if (!this.languageServiceEnabled) { + return true; + } + var hasChanges = this.updateGraphWorker(); + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + if (hasChanges) { + this.projectStructureVersion++; + } + return !hasChanges; + }; + Project.prototype.setTypings = function (typings) { + if (ts.arrayIsEqualTo(this.typingFiles, typings)) { + return false; + } + this.typingFiles = typings; + this.markAsDirty(); + return true; + }; + Project.prototype.updateGraphWorker = function () { + var oldProgram = this.program; + this.program = this.languageService.getProgram(); + var hasChanges = false; + if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { + hasChanges = true; + if (oldProgram) { + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (this.program.getSourceFileByPath(f.path)) { + continue; + } + var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); + if (scriptInfoToDetach) { + scriptInfoToDetach.detachFromProject(this); + } + } + } + } + this.builder.onProjectUpdateGraph(); + return hasChanges; + }; + Project.prototype.getScriptInfoLSHost = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); + if (scriptInfo) { + scriptInfo.attachToProject(this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); + if (scriptInfo && !scriptInfo.isAttached(this)) { + return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + Project.prototype.filesToString = function () { + if (!this.program) { + return ""; + } + var strBuilder = ""; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var file = _a[_i]; + strBuilder += file.fileName + "\n"; + } + return strBuilder; + }; + Project.prototype.setCompilerOptions = function (compilerOptions) { + if (compilerOptions) { + if (this.projectKind === ProjectKind.Inferred) { + compilerOptions.allowJs = true; + } + compilerOptions.allowNonTsExtensions = true; + this.compilerOptions = compilerOptions; + this.lsHost.setCompilationSettings(compilerOptions); + this.markAsDirty(); + } + }; + Project.prototype.reloadScript = function (filename, tempFileName) { + var script = this.projectService.getScriptInfoForNormalizedPath(filename); + if (script) { + ts.Debug.assert(script.isAttached(this)); + script.reloadFromFile(tempFileName); + return true; + } + return false; + }; + Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { + this.updateGraph(); + var info = { + projectName: this.getProjectName(), + version: this.projectStructureVersion, + isInferred: this.projectKind === ProjectKind.Inferred, + options: this.getCompilerOptions() + }; + if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { + if (this.projectStructureVersion == this.lastReportedVersion) { + return { info: info, projectErrors: this.projectErrors }; + } + var lastReportedFileNames = this.lastReportedFileNames; + var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added = []; + var removed = []; + for (var id in currentFiles) { + if (!ts.hasProperty(lastReportedFileNames, id)) { + added.push(id); + } + } + for (var id in lastReportedFileNames) { + if (!ts.hasProperty(currentFiles, id)) { + removed.push(id); + } + } + this.lastReportedFileNames = currentFiles; + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, changes: { added: added, removed: removed }, projectErrors: this.projectErrors }; + } + else { + var projectFileNames = this.getFileNames(); + this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; + } + }; + Project.prototype.getReferencedFiles = function (path) { + var _this = this; + if (!this.languageServiceEnabled) { + return []; + } + var sourceFile = this.getSourceFile(path); + if (!sourceFile) { + return []; + } + var referencedFiles = ts.createMap(); + if (sourceFile.imports && sourceFile.imports.length > 0) { + var checker = this.program.getTypeChecker(); + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importName = _a[_i]; + var symbol = checker.getSymbolAtLocation(importName); + if (symbol && symbol.declarations && symbol.declarations[0]) { + var declarationSourceFile = symbol.declarations[0].getSourceFile(); + if (declarationSourceFile) { + referencedFiles[declarationSourceFile.path] = true; + } + } + } + } + var currentDirectory = ts.getDirectoryPath(path); + var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); + if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { + for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { + var referencedFile = _c[_b]; + var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); + referencedFiles[referencedPath] = true; + } + } + if (sourceFile.resolvedTypeReferenceDirectiveNames) { + for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { + var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + if (!resolvedTypeReferenceDirective) { + continue; + } + var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + referencedFiles[typeFilePath] = true; + } + } + var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); + return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); + }; + Project.prototype.removeRootFileIfNecessary = function (info) { + if (this.isRoot(info)) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); + } + }; + return Project; + }()); + server.Project = Project; + var InferredProject = (function (_super) { + __extends(InferredProject, _super); + function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.directoriesWatchedForTsconfig = []; + _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); + InferredProject.NextId++; + return _this; + } + InferredProject.prototype.getProjectName = function () { + return this.inferredProjectName; + }; + InferredProject.prototype.getProjectRootPath = function () { + if (this.projectService.useSingleInferredProject) { + return undefined; + } + var rootFiles = this.getRootFiles(); + return ts.getDirectoryPath(rootFiles[0]); + }; + InferredProject.prototype.close = function () { + _super.prototype.close.call(this); + for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + this.projectService.stopWatchingDirectory(directory); + } + }; + InferredProject.prototype.getTypingOptions = function () { + return { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + }; + return InferredProject; + }(Project)); + InferredProject.NextId = 1; + server.InferredProject = InferredProject; + var ConfiguredProject = (function (_super) { + __extends(ConfiguredProject, _super); + function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; + _this.wildcardDirectories = wildcardDirectories; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.openRefCount = 0; + return _this; + } + ConfiguredProject.prototype.getProjectRootPath = function () { + return ts.getDirectoryPath(this.configFileName); + }; + ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ConfiguredProject.prototype.setTypingOptions = function (newTypingOptions) { + this.typingOptions = newTypingOptions; + }; + ConfiguredProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ConfiguredProject.prototype.getProjectName = function () { + return this.configFileName; + }; + ConfiguredProject.prototype.watchConfigFile = function (callback) { + var _this = this; + this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, function (_) { return callback(_this); }); + }; + ConfiguredProject.prototype.watchTypeRoots = function (callback) { + var _this = this; + var roots = this.getEffectiveTypeRoots(); + var watchers = []; + for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { + var root = roots_1[_i]; + this.projectService.logger.info("Add type root watcher for: " + root); + watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); + } + this.typeRootsWatchers = watchers; + }; + ConfiguredProject.prototype.watchConfigDirectory = function (callback) { + var _this = this; + if (this.directoryWatcher) { + return; + } + var directoryToWatch = ts.getDirectoryPath(this.configFileName); + this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); + this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); + }; + ConfiguredProject.prototype.watchWildcards = function (callback) { + var _this = this; + if (!this.wildcardDirectories) { + return; + } + var configDirectoryPath = ts.getDirectoryPath(this.configFileName); + this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { + if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { + var recursive = (flag & 1) !== 0; + _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); + watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); + } + return watchers; + }, {}); + }; + ConfiguredProject.prototype.stopWatchingDirectory = function () { + if (this.directoryWatcher) { + this.directoryWatcher.close(); + this.directoryWatcher = undefined; + } + }; + ConfiguredProject.prototype.close = function () { + _super.prototype.close.call(this); + if (this.projectFileWatcher) { + this.projectFileWatcher.close(); + } + if (this.typeRootsWatchers) { + for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { + var watcher = _a[_i]; + watcher.close(); + } + this.typeRootsWatchers = undefined; + } + for (var id in this.directoriesWatchedForWildcards) { + this.directoriesWatchedForWildcards[id].close(); + } + this.directoriesWatchedForWildcards = undefined; + this.stopWatchingDirectory(); + }; + ConfiguredProject.prototype.addOpenRef = function () { + this.openRefCount++; + }; + ConfiguredProject.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; + ConfiguredProject.prototype.getEffectiveTypeRoots = function () { + return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; + }; + return ConfiguredProject; + }(Project)); + server.ConfiguredProject = ConfiguredProject; + var ExternalProject = (function (_super) { + __extends(ExternalProject, _super); + function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { + var _this = _super.call(this, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.externalProjectName = externalProjectName; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.projectFilePath = projectFilePath; + return _this; + } + ExternalProject.prototype.getProjectRootPath = function () { + if (this.projectFilePath) { + return ts.getDirectoryPath(this.projectFilePath); + } + return ts.getDirectoryPath(ts.normalizeSlashes(this.externalProjectName)); + }; + ExternalProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ExternalProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ExternalProject.prototype.setTypingOptions = function (newTypingOptions) { + if (!newTypingOptions) { + newTypingOptions = { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + } + else { + if (newTypingOptions.enableAutoDiscovery === undefined) { + newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this); + } + if (!newTypingOptions.include) { + newTypingOptions.include = []; + } + if (!newTypingOptions.exclude) { + newTypingOptions.exclude = []; + } + } + this.typingOptions = newTypingOptions; + }; + ExternalProject.prototype.getProjectName = function () { + return this.externalProjectName; + }; + return ExternalProject; + }(Project)); + server.ExternalProject = ExternalProject; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { + var map = ts.createMap(); + for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { + var option = commandLineOptions_1[_i]; + if (typeof option.type === "object") { + var optionMap = option.type; + for (var id in optionMap) { + ts.Debug.assert(typeof optionMap[id] === "number"); + } + map[option.name] = optionMap; + } + } + return map; + } + var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); + var indentStyle = ts.createMap({ + "none": ts.IndentStyle.None, + "block": ts.IndentStyle.Block, + "smart": ts.IndentStyle.Smart + }); + function convertFormatOptions(protocolOptions) { + if (typeof protocolOptions.indentStyle === "string") { + protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + ts.Debug.assert(protocolOptions.indentStyle !== undefined); + } + return protocolOptions; + } + server.convertFormatOptions = convertFormatOptions; + function convertCompilerOptions(protocolOptions) { + for (var id in compilerOptionConverters) { + var propertyValue = protocolOptions[id]; + if (typeof propertyValue === "string") { + var mappedValues = compilerOptionConverters[id]; + protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + } + } + return protocolOptions; + } + server.convertCompilerOptions = convertCompilerOptions; + function tryConvertScriptKindName(scriptKindName) { + return typeof scriptKindName === "string" + ? convertScriptKindName(scriptKindName) + : scriptKindName; + } + server.tryConvertScriptKindName = tryConvertScriptKindName; + function convertScriptKindName(scriptKindName) { + switch (scriptKindName) { + case "JS": + return 1; + case "JSX": + return 2; + case "TS": + return 3; + case "TSX": + return 4; + default: + return 0; + } + } + server.convertScriptKindName = convertScriptKindName; + function combineProjectOutput(projects, action, comparer, areEqual) { + var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); + return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; + } + server.combineProjectOutput = combineProjectOutput; + var fileNamePropertyReader = { + getFileName: function (x) { return x; }, + getScriptKind: function (_) { return undefined; }, + hasMixedContent: function (_) { return false; } + }; + var externalFilePropertyReader = { + getFileName: function (x) { return x.fileName; }, + getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, + hasMixedContent: function (x) { return x.hasMixedContent; } + }; + function findProjectByName(projectName, projects) { + for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { + var proj = projects_1[_i]; + if (proj.getProjectName() === projectName) { + return proj; + } + } + } + function createFileNotFoundDiagnostic(fileName) { + return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); + } + function isRootFileInInferredProject(info) { + if (info.containingProjects.length === 0) { + return false; + } + return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); + } + var DirectoryWatchers = (function () { + function DirectoryWatchers(projectService) { + this.projectService = projectService; + this.directoryWatchersForTsconfig = ts.createMap(); + this.directoryWatchersRefCount = ts.createMap(); + } + DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchersRefCount[directory]--; + if (this.directoryWatchersRefCount[directory] === 0) { + this.projectService.logger.info("Close directory watcher for: " + directory); + this.directoryWatchersForTsconfig[directory].close(); + delete this.directoryWatchersForTsconfig[directory]; + } + }; + DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { + var currentPath = ts.getDirectoryPath(fileName); + var parentPath = ts.getDirectoryPath(currentPath); + while (currentPath != parentPath) { + if (!this.directoryWatchersForTsconfig[currentPath]) { + this.projectService.logger.info("Add watcher for: " + currentPath); + this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); + this.directoryWatchersRefCount[currentPath] = 1; + } + else { + this.directoryWatchersRefCount[currentPath] += 1; + } + project.directoriesWatchedForTsconfig.push(currentPath); + currentPath = parentPath; + parentPath = ts.getDirectoryPath(parentPath); + } + }; + return DirectoryWatchers; + }()); + var ProjectService = (function () { + function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { + if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } + this.host = host; + this.logger = logger; + this.cancellationToken = cancellationToken; + this.useSingleInferredProject = useSingleInferredProject; + this.typingsInstaller = typingsInstaller; + this.eventHandler = eventHandler; + this.filenameToScriptInfo = ts.createFileMap(); + this.externalProjectToConfiguredProjectMap = ts.createMap(); + this.externalProjects = []; + this.inferredProjects = []; + this.configuredProjects = []; + this.openFiles = []; + this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.directoryWatchers = new DirectoryWatchers(this); + this.throttledOperations = new server.ThrottledOperations(host); + this.typingsInstaller.attach(this); + this.typingsCache = new server.TypingsCache(this.typingsInstaller); + this.hostConfiguration = { + formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + hostInfo: "Unknown host" + }; + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + } + ProjectService.prototype.getChangedFiles_TestOnly = function () { + return this.changedFiles; + }; + ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { + this.ensureInferredProjectsUpToDate(); + }; + ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { + return this.compilerOptionsForInferredProjects; + }; + ProjectService.prototype.updateTypingsForProject = function (response) { + var project = this.findProject(response.projectName); + if (!project) { + return; + } + switch (response.kind) { + case "set": + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); + project.updateGraph(); + break; + case "invalidate": + this.typingsCache.invalidateCachedTypingsForProject(project); + break; + } + }; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { + this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); + this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + proj.setCompilerOptions(this.compilerOptionsForInferredProjects); + proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + } + this.updateProjectGraphs(this.inferredProjects); + }; + ProjectService.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchers.stopWatchingDirectory(directory); + }; + ProjectService.prototype.findProject = function (projectName) { + if (projectName === undefined) { + return undefined; + } + if (server.isInferredProjectName(projectName)) { + this.ensureInferredProjectsUpToDate(); + return findProjectByName(projectName, this.inferredProjects); + } + return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); + }; + ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { + if (refreshInferredProjects) { + this.ensureInferredProjectsUpToDate(); + } + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo && scriptInfo.getDefaultProject(); + }; + ProjectService.prototype.ensureInferredProjectsUpToDate = function () { + if (this.changedFiles) { + var projectsToUpdate = void 0; + if (this.changedFiles.length === 1) { + projectsToUpdate = this.changedFiles[0].containingProjects; + } + else { + projectsToUpdate = []; + for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { + var f = _a[_i]; + projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + } + } + this.updateProjectGraphs(projectsToUpdate); + this.changedFiles = undefined; + } + }; + ProjectService.prototype.findContainingExternalProject = function (fileName) { + for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.containsFile(fileName)) { + return proj; + } + } + return undefined; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + var formatCodeSettings; + if (file) { + var info = this.getScriptInfoForNormalizedPath(file); + if (info) { + formatCodeSettings = info.getFormatCodeSettings(); + } + } + return formatCodeSettings || this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.updateProjectGraphs = function (projects) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { + var p = projects_2[_i]; + if (!p.updateGraph()) { + shouldRefreshInferredProjects = true; + } + } + if (shouldRefreshInferredProjects) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onSourceFileChanged = function (fileName) { + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + this.logger.info("Error: got watch notification for unknown file: " + fileName); + return; + } + if (!this.host.fileExists(fileName)) { + this.handleDeletedFile(info); + } + else { + if (info && (!info.isOpen)) { + info.reloadFromFile(); + this.updateProjectGraphs(info.containingProjects); + } + } + }; + ProjectService.prototype.handleDeletedFile = function (info) { + this.logger.info(info.fileName + " deleted"); + info.stopWatcher(); + if (!info.isOpen) { + this.filenameToScriptInfo.remove(info.path); + this.lastDeletedFile = info; + var containingProjects = info.containingProjects.slice(); + info.detachAllProjects(); + this.updateProjectGraphs(containingProjects); + this.lastDeletedFile = undefined; + if (!this.eventHandler) { + return; + } + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var openFile = _a[_i]; + this.eventHandler({ eventName: "context", data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } }); + } + } + this.printProjects(); + }; + ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { + var _this = this; + this.logger.info("Type root file " + fileName + " changed"); + this.throttledOperations.schedule(project.configFileName + " * type root", 250, function () { + project.updateTypes(); + _this.updateConfiguredProject(project); + _this.refreshInferredProjects(); + }); + }; + ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { + var _this = this; + if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions())) { + return; + } + this.logger.info("Detected source file changes: " + fileName); + this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); + }; + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { + var _this = this; + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); + var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); + var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); + if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { + this.logger.info("Updating configured project"); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { + this.logger.info("Config file changed: " + project.configFileName); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + }; + ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { + if (ts.getBaseFileName(fileName) != "tsconfig.json") { + this.logger.info(fileName + " is not tsconfig.json"); + return; + } + var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; + this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); + this.logger.info("Detected newly added tsconfig file: " + fileName); + this.reloadProjects(); + }; + ProjectService.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + ProjectService.prototype.removeProject = function (project) { + this.logger.info("remove project: " + project.getRootFiles().toString()); + project.close(); + switch (project.projectKind) { + case server.ProjectKind.External: + server.removeItemFromSet(this.externalProjects, project); + break; + case server.ProjectKind.Configured: + server.removeItemFromSet(this.configuredProjects, project); + break; + case server.ProjectKind.Inferred: + server.removeItemFromSet(this.inferredProjects, project); + break; + } + }; + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + var externalProject = this.findContainingExternalProject(info.fileName); + if (externalProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + var foundConfiguredProject = false; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + foundConfiguredProject = true; + if (addToListOfOpenFiles) { + (p).addOpenRef(); + } + } + } + if (foundConfiguredProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + if (info.containingProjects.length === 0) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); + if (!this.useSingleInferredProject) { + for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { + var f = _c[_b]; + if (f.containingProjects.length === 0) { + continue; + } + var defaultProject = f.getDefaultProject(); + if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { + this.removeProject(defaultProject); + f.attachToProject(inferredProject); + } + } + } + } + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + }; + ProjectService.prototype.closeOpenFile = function (info) { + info.reloadFromFile(); + server.removeItemFromSet(this.openFiles, info); + info.isOpen = false; + var projectsToRemove; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + if (p.deleteOpenRef() === 0) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + if (projectsToRemove) { + for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { + var project = projectsToRemove_1[_b]; + this.removeProject(project); + } + var orphanFiles = void 0; + for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { + var f = _d[_c]; + if (f.containingProjects.length === 0) { + (orphanFiles || (orphanFiles = [])).push(f); + } + } + if (orphanFiles) { + for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { + var f = orphanFiles_1[_e]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + } + } + if (info.containingProjects.length === 0) { + this.filenameToScriptInfo.remove(info.path); + } + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + var searchPath = ts.getDirectoryPath(fileName); + this.logger.info("Search path: " + searchPath); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + if (!configFileName) { + this.logger.info("No config files found."); + return {}; + } + this.logger.info("Config file name: " + configFileName); + var project = this.findConfiguredProjectByProjectName(configFileName); + if (!project) { + var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; + if (!success) { + return { configFileName: configFileName, configFileErrors: errors }; + } + this.logger.info("Opened configuration file " + configFileName); + if (errors && errors.length > 0) { + return { configFileName: configFileName, configFileErrors: errors }; + } + } + else { + this.updateConfiguredProject(project); + } + return { configFileName: configFileName }; + }; + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; + } + var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; + } + var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.printProjects = function () { + if (!this.logger.hasLevel(server.LogLevel.verbose)) { + return; + } + this.logger.startGroup(); + var counter = 0; + counter = printProjects(this.logger, this.externalProjects, counter); + counter = printProjects(this.logger, this.configuredProjects, counter); + counter = printProjects(this.logger, this.inferredProjects, counter); + this.logger.info("Open files: "); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var rootFile = _a[_i]; + this.logger.info(rootFile.fileName); + } + this.logger.endGroup(); + function printProjects(logger, projects, counter) { + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var project = projects_3[_i]; + project.updateGraph(); + logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + logger.info(project.filesToString()); + logger.info("-----------------------------------------------"); + counter++; + } + return counter; + } + }; + ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { + return findProjectByName(configFileName, this.configuredProjects); + }; + ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { + return findProjectByName(projectFileName, this.externalProjects); + }; + ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { + configFilename = ts.normalizePath(configFilename); + var configFileContent = this.host.readFile(configFilename); + var errors; + var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); + var config = result.config; + if (result.error) { + var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; + config = sanitizedConfig; + errors = diagnostics.length ? diagnostics : [result.error]; + } + var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename); + if (parsedCommandLine.errors.length) { + errors = ts.concatenate(errors, parsedCommandLine.errors); + } + ts.Debug.assert(!!parsedCommandLine.fileNames); + if (parsedCommandLine.fileNames.length === 0) { + (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { success: false, configFileErrors: errors }; + } + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options, + configHasFilesProperty: config["files"] !== undefined, + wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), + typingOptions: parsedCommandLine.typingOptions, + compileOnSave: parsedCommandLine.compileOnSave + }; + return { success: true, projectOptions: projectOptions, configFileErrors: errors }; + }; + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + if (options && options.disableSizeLimit || !this.host.getFileSize) { + return false; + } + var totalNonTsFileSize = 0; + for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { + var f = fileNames_3[_i]; + var fileName = propertyReader.getFileName(f); + if (ts.hasTypeScriptFileExtension(fileName)) { + continue; + } + totalNonTsFileSize += this.host.getFileSize(fileName); + if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { + return true; + } + } + return false; + }; + ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { + var compilerOptions = convertCompilerOptions(options); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); + this.externalProjects.push(project); + return project; + }; + ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: "configFileDiag", + data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } + }); + }; + ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { + var _this = this; + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors); + project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); + if (!sizeLimitExceeded) { + this.watchConfigDirectoryForProject(project, projectOptions); + } + project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); + this.configuredProjects.push(project); + return project; + }; + ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { + var _this = this; + if (!options.configHasFilesProperty) { + project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + } + }; + ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typingOptions, configFileErrors) { + var errors; + for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { + var f = files_4[_i]; + var rootFilename = propertyReader.getFileName(f); + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + if (this.host.fileExists(rootFilename)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + } + } + project.setProjectErrors(ts.concatenate(configFileErrors, errors)); + project.setTypingOptions(typingOptions); + project.updateGraph(); + }; + ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { + var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); + var projectOptions = conversionResult.success + ? conversionResult.projectOptions + : { files: [], compilerOptions: {} }; + var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); + return { + success: conversionResult.success, + project: project, + errors: project.getProjectErrors() + }; + }; + ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors) { + var oldRootScriptInfos = project.getRootScriptInfos(); + var newRootScriptInfos = []; + var newRootScriptInfoMap = server.createNormalizedPathMap(); + var projectErrors; + var rootFilesChanged = false; + for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { + var f = newUncheckedFiles_1[_i]; + var newRootFile = propertyReader.getFileName(f); + if (!this.host.fileExists(newRootFile)) { + (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); + continue; + } + var normalizedPath = server.toNormalizedPath(newRootFile); + var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); + if (!scriptInfo || !project.isRoot(scriptInfo)) { + rootFilesChanged = true; + if (!scriptInfo) { + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + } + } + newRootScriptInfos.push(scriptInfo); + newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); + } + if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { + var toAdd = void 0; + var toRemove = void 0; + for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { + var oldFile = oldRootScriptInfos_1[_a]; + if (!newRootScriptInfoMap.contains(oldFile.fileName)) { + (toRemove || (toRemove = [])).push(oldFile); + } + } + for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { + var newFile = newRootScriptInfos_1[_b]; + if (!project.isRoot(newFile)) { + (toAdd || (toAdd = [])).push(newFile); + } + } + if (toRemove) { + for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { + var f = toRemove_1[_c]; + project.removeFile(f); + } + } + if (toAdd) { + for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { + var f = toAdd_1[_d]; + if (f.isOpen && isRootFileInInferredProject(f)) { + var inferredProject = f.containingProjects[0]; + inferredProject.removeFile(f); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + project.addRoot(f); + } + } + } + project.setCompilerOptions(newOptions); + project.setTypingOptions(newTypingOptions); + if (compileOnSave !== undefined) { + project.compileOnSaveEnabled = compileOnSave; + } + project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); + project.updateGraph(); + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.configFileName)) { + this.logger.info("Config file deleted"); + this.removeProject(project); + return; + } + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + if (!success) { + this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); + return configFileErrors; + } + if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + project.setCompilerOptions(projectOptions.compilerOptions); + if (!project.languageServiceEnabled) { + return; + } + project.disableLanguageService(); + project.stopWatchingDirectory(); + } + else { + if (!project.languageServiceEnabled) { + project.enableLanguageService(); + } + this.watchConfigDirectoryForProject(project, projectOptions); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors); + } + }; + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + var _this = this; + var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; + var project = useExistingProject + ? this.inferredProjects[0] + : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); + project.addRoot(root); + this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); + project.updateGraph(); + if (!useExistingProject) { + this.inferredProjects.push(project); + } + return project; + }; + ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { + return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); + }; + ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { + var _this = this; + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + var content = void 0; + if (this.host.fileExists(fileName)) { + content = fileContent || (hasMixedContent ? "" : this.host.readFile(fileName)); + } + if (!content) { + if (openedByClient) { + content = ""; + } + } + if (content !== undefined) { + info = new server.ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent); + this.filenameToScriptInfo.set(info.path, info); + if (!info.isOpen && !hasMixedContent) { + info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); + } + } + } + if (info) { + if (fileContent !== undefined) { + info.reload(fileContent); + } + if (openedByClient) { + info.isOpen = true; + } + } + return info; + }; + ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { + return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); + }; + ProjectService.prototype.getScriptInfoForPath = function (fileName) { + return this.filenameToScriptInfo.get(fileName); + }; + ProjectService.prototype.setHostConfiguration = function (args) { + if (args.file) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); + if (info) { + info.setFormatOptions(convertFormatOptions(args.formatOptions)); + this.logger.info("Host configuration update for file " + args.file); + } + } + else { + if (args.hostInfo !== undefined) { + this.hostConfiguration.hostInfo = args.hostInfo; + this.logger.info("Host information " + args.hostInfo); + } + if (args.formatOptions) { + server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.logger.info("Format host information updated"); + } + } + }; + ProjectService.prototype.closeLog = function () { + this.logger.close(); + }; + ProjectService.prototype.reloadProjects = function () { + this.logger.info("reload projects."); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.refreshInferredProjects(); + }; + ProjectService.prototype.refreshInferredProjects = function () { + this.logger.info("updating project structure from ..."); + this.printProjects(); + var orphantedFiles = []; + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + if (info.containingProjects.length === 0) { + orphantedFiles.push(info); + } + else { + if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { + var inferredProject = info.containingProjects[0]; + ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); + inferredProject.removeFile(info); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + } + } + for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { + var f = orphantedFiles_1[_b]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { + var p = _d[_c]; + p.updateGraph(); + } + this.printProjects(); + }; + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + }; + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + var _a = this.findContainingExternalProject(fileName) + ? {} + : this.openOrUpdateConfiguredProjectForFile(fileName), _b = _a.configFileName, configFileName = _b === void 0 ? undefined : _b, _c = _a.configFileErrors, configFileErrors = _c === void 0 ? undefined : _c; + var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); + this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.printProjects(); + return { configFileName: configFileName, configFileErrors: configFileErrors }; + }; + ProjectService.prototype.closeClientFile = function (uncheckedFileName) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + if (info) { + this.closeOpenFile(info); + info.isOpen = false; + } + this.printProjects(); + }; + ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { + var _loop_3 = function (proj) { + var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); + }; + for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { + var proj = currentProjects_1[_i]; + _loop_3(proj); + } + }; + ProjectService.prototype.synchronizeProjectList = function (knownProjects) { + var files = []; + this.collectChanges(knownProjects, this.externalProjects, files); + this.collectChanges(knownProjects, this.configuredProjects, files); + this.collectChanges(knownProjects, this.inferredProjects, files); + return files; + }; + ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { + var recordChangedFiles = changedFiles && !openFiles && !closedFiles; + if (openFiles) { + for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { + var file = openFiles_1[_i]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); + var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); + } + } + if (changedFiles) { + for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { + var file = changedFiles_1[_a]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!!scriptInfo); + for (var i = file.changes.length - 1; i >= 0; i--) { + var change = file.changes[i]; + scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); + } + if (recordChangedFiles) { + if (!this.changedFiles) { + this.changedFiles = [scriptInfo]; + } + else if (this.changedFiles.indexOf(scriptInfo) < 0) { + this.changedFiles.push(scriptInfo); + } + } + } + } + if (closedFiles) { + for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { + var file = closedFiles_1[_b]; + this.closeClientFile(file); + } + } + if (openFiles || closedFiles) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.closeConfiguredProject = function (configFile) { + var configuredProject = this.findConfiguredProjectByProjectName(configFile); + if (configuredProject && configuredProject.deleteOpenRef() === 0) { + this.removeProject(configuredProject); + } + }; + ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { + if (suppressRefresh === void 0) { suppressRefresh = false; } + var fileName = server.toNormalizedPath(uncheckedFileName); + var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + if (configFiles) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { + var configFile = configFiles_1[_i]; + if (this.closeConfiguredProject(configFile)) { + shouldRefreshInferredProjects = true; + } + } + delete this.externalProjectToConfiguredProjectMap[fileName]; + if (shouldRefreshInferredProjects && !suppressRefresh) { + this.refreshInferredProjects(); + } + } + else { + var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); + if (externalProject) { + this.removeProject(externalProject); + if (!suppressRefresh) { + this.refreshInferredProjects(); + } + } + } + }; + ProjectService.prototype.openExternalProject = function (proj) { + var tsConfigFiles; + var rootFiles = []; + for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { + var file = _a[_i]; + var normalized = server.toNormalizedPath(file.fileName); + if (ts.getBaseFileName(normalized) === "tsconfig.json") { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } + else { + rootFiles.push(file); + } + } + if (tsConfigFiles) { + tsConfigFiles.sort(); + } + var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); + var exisingConfigFiles; + if (externalProject) { + if (!tsConfigFiles) { + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, undefined); + return; + } + this.closeExternalProject(proj.projectFileName, true); + } + else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + if (!tsConfigFiles) { + this.closeExternalProject(proj.projectFileName, true); + } + else { + var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + var iNew = 0; + var iOld = 0; + while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { + var newConfig = tsConfigFiles[iNew]; + var oldConfig = oldConfigFiles[iOld]; + if (oldConfig < newConfig) { + this.closeConfiguredProject(oldConfig); + iOld++; + } + else if (oldConfig > newConfig) { + iNew++; + } + else { + (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); + iOld++; + iNew++; + } + } + for (var i = iOld; i < oldConfigFiles.length; i++) { + this.closeConfiguredProject(oldConfigFiles[i]); + } + } + } + if (tsConfigFiles) { + this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { + var tsconfigFile = tsConfigFiles_1[_b]; + var project = this.findConfiguredProjectByProjectName(tsconfigFile); + if (!project) { + var result = this.openConfigFile(tsconfigFile); + project = result.success && result.project; + } + if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { + project.addOpenRef(); + } + } + } + else { + delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions); + } + this.refreshInferredProjects(); + }; + return ProjectService; + }()); + server.ProjectService = ProjectService; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + function hrTimeToMilliseconds(time) { + var seconds = time[0]; + var nanoseconds = time[1]; + return ((1e9 * seconds) + nanoseconds) / 1000000.0; + } + function shouldSkipSematicCheck(project) { + if (project.getCompilerOptions().skipLibCheck !== undefined) { + return false; + } + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { + return true; + } + return false; + } + function compareNumber(a, b) { + return a - b; + } + function compareFileStart(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file == b.file) { + var n = compareNumber(a.start.line, b.start.line); + if (n === 0) { + return compareNumber(a.start.offset, b.start.offset); + } + else + return n; + } + else { + return 1; + } + } + function formatDiag(fileName, project, diag) { + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); + return { + start: scriptInfo.positionToLineOffset(diag.start), + end: scriptInfo.positionToLineOffset(diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + code: diag.code + }; + } + function formatConfigFileDiag(diag) { + return { + start: undefined, + end: undefined, + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + }; + } + function allEditsBeforePos(edits, pos) { + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var edit = edits_1[_i]; + if (ts.textSpanEnd(edit.span) >= pos) { + return false; + } + } + return true; + } + var CommandNames; + (function (CommandNames) { + CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; + CommandNames.Exit = "exit"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; + CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; + CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; + CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; + CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; + CommandNames.Saveto = "saveto"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; + CommandNames.TypeDefinition = "typeDefinition"; + CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; + CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); + function formatMessage(msg, logger, byteLength, newLine) { + var verboseLogging = logger.hasLevel(server.LogLevel.verbose); + var json = JSON.stringify(msg); + if (verboseLogging) { + logger.info(msg.type + ": " + json); + } + var len = byteLength(json, "utf8"); + return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + } + server.formatMessage = formatMessage; + var Session = (function () { + function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { + var _this = this; + this.host = host; + this.typingsInstaller = typingsInstaller; + this.byteLength = byteLength; + this.hrtime = hrtime; + this.logger = logger; + this.canUseEvents = canUseEvents; + this.changeSeq = 0; + this.handlers = ts.createMap((_a = {}, + _a[CommandNames.OpenExternalProject] = function (request) { + _this.projectService.openExternalProject(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.OpenExternalProjects] = function (request) { + for (var _i = 0, _a = request.arguments.projects; _i < _a.length; _i++) { + var proj = _a[_i]; + _this.projectService.openExternalProject(proj); + } + return _this.requiredResponse(true); + }, + _a[CommandNames.CloseExternalProject] = function (request) { + _this.projectService.closeExternalProject(request.arguments.projectFileName); + return _this.requiredResponse(true); + }, + _a[CommandNames.SynchronizeProjectList] = function (request) { + var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); + if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { + return _this.requiredResponse(result); + } + var converted = ts.map(result, function (p) { + if (!p.projectErrors || p.projectErrors.length === 0) { + return p; + } + return { + info: p.info, + changes: p.changes, + files: p.files, + projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) + }; + }); + return _this.requiredResponse(converted); + }, + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); + _this.changeSeq++; + return _this.requiredResponse(true); + }, + _a[CommandNames.Exit] = function () { + _this.exit(); + return _this.notRequired(); + }, + _a[CommandNames.Definition] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, true)); + }, + _a[CommandNames.DefinitionFull] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, false)); + }, + _a[CommandNames.TypeDefinition] = function (request) { + return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); + }, + _a[CommandNames.Implementation] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, true)); + }, + _a[CommandNames.ImplementationFull] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, false)); + }, + _a[CommandNames.References] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, true)); + }, + _a[CommandNames.ReferencesFull] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, false)); + }, + _a[CommandNames.Rename] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); + }, + _a[CommandNames.RenameLocationsFull] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); + }, + _a[CommandNames.RenameInfoFull] = function (request) { + return _this.requiredResponse(_this.getRenameInfo(request.arguments)); + }, + _a[CommandNames.Open] = function (request) { + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + return _this.notRequired(); + }, + _a[CommandNames.Quickinfo] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); + }, + _a[CommandNames.QuickinfoFull] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); + }, + _a[CommandNames.OutliningSpans] = function (request) { + return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); + }, + _a[CommandNames.TodoComments] = function (request) { + return _this.requiredResponse(_this.getTodoComments(request.arguments)); + }, + _a[CommandNames.Indentation] = function (request) { + return _this.requiredResponse(_this.getIndentation(request.arguments)); + }, + _a[CommandNames.NameOrDottedNameSpan] = function (request) { + return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); + }, + _a[CommandNames.BreakpointStatement] = function (request) { + return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); + }, + _a[CommandNames.BraceCompletion] = function (request) { + return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); + }, + _a[CommandNames.DocCommentTemplate] = function (request) { + return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); + }, + _a[CommandNames.Format] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); + }, + _a[CommandNames.Formatonkey] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); + }, + _a[CommandNames.FormatFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); + }, + _a[CommandNames.FormatonkeyFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); + }, + _a[CommandNames.FormatRangeFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); + }, + _a[CommandNames.Completions] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + }, + _a[CommandNames.CompletionsFull] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, false)); + }, + _a[CommandNames.CompletionDetails] = function (request) { + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); + }, + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { + return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); + }, + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { + return _this.requiredResponse(_this.emitFile(request.arguments)); + }, + _a[CommandNames.SignatureHelp] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); + }, + _a[CommandNames.SignatureHelpFull] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); + }, + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { + return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); + }, + _a[CommandNames.Cleanup] = function () { + _this.cleanup(); + return _this.requiredResponse(true); + }, + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.Geterr] = function (request) { + var geterrArgs = request.arguments; + return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; + }, + _a[CommandNames.GeterrForProject] = function (request) { + var _a = request.arguments, file = _a.file, delay = _a.delay; + return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; + }, + _a[CommandNames.Change] = function (request) { + _this.change(request.arguments); + return _this.notRequired(); + }, + _a[CommandNames.Configure] = function (request) { + _this.projectService.setHostConfiguration(request.arguments); + _this.output(undefined, CommandNames.Configure, request.seq); + return _this.notRequired(); + }, + _a[CommandNames.Reload] = function (request) { + _this.reload(request.arguments, request.seq); + return _this.requiredResponse({ reloadFinished: true }); + }, + _a[CommandNames.Saveto] = function (request) { + var savetoArgs = request.arguments; + _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + return _this.notRequired(); + }, + _a[CommandNames.Close] = function (request) { + var closeArgs = request.arguments; + _this.closeClientFile(closeArgs.file); + return _this.notRequired(); + }, + _a[CommandNames.Navto] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); + }, + _a[CommandNames.NavtoFull] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); + }, + _a[CommandNames.Brace] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); + }, + _a[CommandNames.BraceFull] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); + }, + _a[CommandNames.NavBar] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); + }, + _a[CommandNames.NavBarFull] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); + }, + _a[CommandNames.NavTree] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); + }, + _a[CommandNames.NavTreeFull] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); + }, + _a[CommandNames.Occurrences] = function (request) { + return _this.requiredResponse(_this.getOccurrences(request.arguments)); + }, + _a[CommandNames.DocumentHighlights] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); + }, + _a[CommandNames.DocumentHighlightsFull] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { + _this.setCompilerOptionsForInferredProjects(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.ProjectInfo] = function (request) { + return _this.requiredResponse(_this.getProjectInfo(request.arguments)); + }, + _a[CommandNames.ReloadProjects] = function () { + _this.projectService.reloadProjects(); + return _this.notRequired(); + }, + _a[CommandNames.GetCodeFixes] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); + }, + _a[CommandNames.GetCodeFixesFull] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); + }, + _a[CommandNames.GetSupportedCodeFixes] = function () { + return _this.requiredResponse(_this.getSupportedCodeFixes()); + }, + _a)); + this.eventHander = canUseEvents + ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + : undefined; + this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.gcTimer = new server.GcTimer(host, 7000, logger); + var _a; + } + Session.prototype.defaultEventHandler = function (event) { + var _this = this; + switch (event.eventName) { + case "context": + var _a = event.data, project = _a.project, fileName = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName); + this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); + break; + case "configFileDiag": + var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; + this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); + } + }; + Session.prototype.logError = function (err, cmd) { + var msg = "Exception on executing command " + cmd; + if (err.message) { + msg += ":\n" + err.message; + if (err.stack) { + msg += "\n" + err.stack; + } + } + this.logger.msg(msg, server.Msg.Err); + }; + Session.prototype.send = function (msg) { + if (msg.type === "event" && !this.canUseEvents) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + } + return; + } + this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + }; + Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { + var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); + var ev = { + seq: 0, + type: "event", + event: "configFileDiag", + body: { + triggerFile: triggerFile, + configFile: configFile, + diagnostics: bakedDiags + } + }; + this.send(ev); + }; + Session.prototype.event = function (info, eventName) { + var ev = { + seq: 0, + type: "event", + event: eventName, + body: info, + }; + this.send(ev); + }; + Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { + if (reqSeq === void 0) { reqSeq = 0; } + var res = { + seq: 0, + type: "response", + command: cmdName, + request_seq: reqSeq, + success: !errorMsg, + }; + if (!errorMsg) { + res.body = info; + } + else { + res.message = errorMsg; + } + this.send(res); + }; + Session.prototype.semanticCheck = function (file, project) { + try { + var diags = []; + if (!shouldSkipSematicCheck(project)) { + diags = project.getLanguageService().getSemanticDiagnostics(file); + } + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + } + catch (err) { + this.logError(err, "semantic check"); + } + }; + Session.prototype.syntacticCheck = function (file, project) { + try { + var diags = project.getLanguageService().getSyntacticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); + } + } + catch (err) { + this.logError(err, "syntactic check"); + } + }; + Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { + var _this = this; + if (ms === void 0) { ms = 1500; } + this.host.setTimeout(function () { + if (matchSeq(seq)) { + _this.projectService.refreshInferredProjects(); + } + }, ms); + }; + Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { + var _this = this; + if (ms === void 0) { ms = 1500; } + if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } + if (followMs > ms) { + followMs = ms; + } + if (this.errorTimer) { + this.host.clearTimeout(this.errorTimer); + } + if (this.immediateId) { + this.host.clearImmediate(this.immediateId); + this.immediateId = undefined; + } + var index = 0; + var checkOne = function () { + if (matchSeq(seq)) { + var checkSpec_1 = checkList[index]; + index++; + if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { + _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); + _this.immediateId = _this.host.setImmediate(function () { + _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); + _this.immediateId = undefined; + if (checkList.length > index) { + _this.errorTimer = _this.host.setTimeout(checkOne, followMs); + } + else { + _this.errorTimer = undefined; + } + }); + } + } + }; + if ((checkList.length > index) && (matchSeq(seq))) { + this.errorTimer = this.host.setTimeout(checkOne, ms); + } + }; + Session.prototype.cleanProjects = function (caption, projects) { + if (!projects) { + return; + } + this.logger.info("cleaning " + caption); + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var p = projects_4[_i]; + p.getLanguageService(false).cleanupSemanticCache(); + } + }; + Session.prototype.cleanup = function () { + this.cleanProjects("inferred projects", this.projectService.inferredProjects); + this.cleanProjects("configured projects", this.projectService.configuredProjects); + this.cleanProjects("external projects", this.projectService.externalProjects); + if (this.host.gc) { + this.logger.info("host.gc()"); + this.host.gc(); + } + }; + Session.prototype.getEncodedSemanticClassifications = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getEncodedSemanticClassifications(file, args); + }; + Session.prototype.getProject = function (projectFileName) { + return projectFileName && this.projectService.findProject(projectFileName); + }; + Session.prototype.getCompilerOptionsDiagnostics = function (args) { + var project = this.getProject(args.projectFileName); + return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); + }; + Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { + var _this = this; + return diagnostics.map(function (d) { return ({ + message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), + start: d.start, + length: d.length, + category: ts.DiagnosticCategory[d.category].toLowerCase(), + code: d.code, + startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), + endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) + }); }); + }; + Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { + var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; + if (isSemantic && shouldSkipSematicCheck(project)) { + return []; + } + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var diagnostics = selector(project, file); + return includeLinePosition + ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) + : diagnostics.map(function (d) { return formatDiag(file, project, d); }); + }; + Session.prototype.getDefinition = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + if (simplifiedResult) { + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); + } + else { + return definitions; + } + }; + Session.prototype.getTypeDefinition = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); + }; + Session.prototype.getImplementation = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var implementations = project.getLanguageService().getImplementationAtPosition(file, position); + if (!implementations) { + return []; + } + if (simplifiedResult) { + return implementations.map(function (impl) { return ({ + file: impl.fileName, + start: scriptInfo.positionToLineOffset(impl.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) + }); }); + } + else { + return implementations; + } + }; + Session.prototype.getOccurrences = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); + if (!occurrences) { + return undefined; + } + return occurrences.map(function (occurrence) { + var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { + start: start, + end: end, + file: fileName, + isWriteAccess: isWriteAccess, + }; + }); + }; + Session.prototype.getSyntacticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); + }; + Session.prototype.getSemanticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + }; + Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); + if (!documentHighlights) { + return undefined; + } + if (simplifiedResult) { + return documentHighlights.map(convertToDocumentHighlightsItem); + } + else { + return documentHighlights; + } + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + function convertHighlightSpan(highlightSpan) { + var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { start: start, end: end, kind: kind }; + } + } + }; + Session.prototype.setCompilerOptionsForInferredProjects = function (args) { + this.projectService.setCompilerOptionsForInferredProjects(args.options); + }; + Session.prototype.getProjectInfo = function (args) { + return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); + }; + Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { + var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; + var projectInfo = { + configFileName: project.getProjectName(), + languageServiceDisabled: !project.languageServiceEnabled, + fileNames: needFileNameList ? project.getFileNames() : undefined + }; + return projectInfo; + }; + Session.prototype.getRenameInfo = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService().getRenameInfo(file, position); + }; + Session.prototype.getProjects = function (args) { + var projects; + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + projects = [project]; + } + } + else { + var scriptInfo = this.projectService.getScriptInfo(args.file); + projects = scriptInfo.containingProjects; + } + projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); + if (!projects || !projects.length) { + return server.Errors.ThrowNoProject(); + } + return projects; + }; + Session.prototype.getRenameLocations = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var info = this.projectService.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, info); + var projects = this.getProjects(args); + if (simplifiedResult) { + var defaultProject = projects[0]; + var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); + if (!renameInfo) { + return undefined; + } + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var fileSpans = server.combineProjectOutput(projects, function (project) { + var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); + if (!renameLocations) { + return []; + } + return renameLocations.map(function (location) { + var locationScriptInfo = project.getScriptInfo(location.fileName); + return { + file: location.fileName, + start: locationScriptInfo.positionToLineOffset(location.textSpan.start), + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), + }; + }); + }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); + var locs = fileSpans.reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file !== cur.file) { + curFileAccum = undefined; + } + } + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); + } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: locs }; + } + else { + return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); + } + function renameLocationIsEqualTo(a, b) { + if (a === b) { + return true; + } + if (!a || !b) { + return false; + } + return a.fileName === b.fileName && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } + function compareRenameLocation(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file > b.file) { + return 1; + } + else { + if (a.start.line < b.start.line) { + return 1; + } + else if (a.start.line > b.start.line) { + return -1; + } + else { + return b.start.offset - a.start.offset; + } + } + } + }; + Session.prototype.getReferences = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var projects = this.getProjects(args); + var defaultProject = projects[0]; + var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + if (simplifiedResult) { + var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; + var nameText = scriptInfo.snap().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var refs = server.combineProjectOutput(projects, function (project) { + var references = project.getLanguageService().getReferencesAtPosition(file, position); + if (!references) { + return []; + } + return references.map(function (ref) { + var refScriptInfo = project.getScriptInfo(ref.fileName); var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); var lineText = refScriptInfo.snap().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); @@ -64204,7 +66719,7 @@ var ts; if (this.eventHander) { this.eventHander({ eventName: "configFileDiag", - data: { fileName: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } }); } }; @@ -64244,7 +66759,7 @@ var ts; Session.prototype.getIndentation = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); return { position: position, indentation: indentation }; }; @@ -64279,7 +66794,7 @@ var ts; start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, - documentation: docString + documentation: docString, }; } else { @@ -64300,17 +66815,17 @@ var ts; }; Session.prototype.getFormattingEditsForRangeFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); }; Session.prototype.getFormattingEditsForDocumentFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsForDocument(file, options); }; Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); }; Session.prototype.getFormattingEditsAfterKeystroke = function (args) { @@ -64377,7 +66892,7 @@ var ts; result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; - }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); + }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); } else { return completions; @@ -64440,7 +66955,7 @@ var ts; }, selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount + argumentCount: helpItems.argumentCount, }; } else { @@ -64477,10 +66992,11 @@ var ts; }; Session.prototype.reload = function (args, reqSeq) { var file = server.toNormalizedPath(args.file); + var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); var project = this.projectService.getDefaultProjectForFile(file, true); if (project) { this.changeSeq++; - if (project.reloadScript(file)) { + if (project.reloadScript(file, tempFileName)) { this.output(undefined, CommandNames.Reload, reqSeq); } } @@ -64561,7 +67077,7 @@ var ts; kind: navItem.kind, file: navItem.fileName, start: start, - end: end + end: end, }; if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { bakedItem.kindModifiers = navItem.kindModifiers; @@ -64670,7 +67186,7 @@ var ts; if (languageServiceDisabled) { return; } - var fileNamesInProject = fileNames.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); + var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); var highPriorityFiles = []; var mediumPriorityFiles = []; var lowPriorityFiles = []; @@ -64790,7 +67306,7 @@ var ts; this.goSubtree = true; this.done = false; } - BaseLineIndexWalker.prototype.leaf = function (rangeStart, rangeLength, ll) { + BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { }; return BaseLineIndexWalker; }()); @@ -64885,14 +67401,14 @@ var ts; } return this.lineIndex; }; - EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { + 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) { + 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; @@ -65117,7 +67633,7 @@ var ts; var starts = [-1]; var count = 1; var pos = 0; - this.index.every(function (ll, s, len) { + this.index.every(function (ll) { starts[count] = pos; count++; pos += ll.text.length; @@ -65261,1415 +67777,728 @@ var ts; 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, len = this.children.length; i < len; i++) { - var child = this.children[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) { - var net = require("net"); - var childProcess = require("child_process"); - var os = require("os"); - function getGlobalTypingsCacheLocation() { - var basePath; - switch (process.platform) { - case "win32": - basePath = process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir(); - break; - case "linux": - basePath = os.homedir(); - break; - case "darwin": - basePath = ts.combinePaths(os.homedir(), "Library/Application Support/"); - break; - } - ts.Debug.assert(basePath !== undefined); - return ts.combinePaths(ts.normalizeSlashes(basePath), "Microsoft/TypeScript"); - } - var readline = require("readline"); - var fs = require("fs"); - var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - terminal: false - }); - var Logger = (function () { - function Logger(logFilename, traceToConsole, level) { - this.logFilename = logFilename; - this.traceToConsole = traceToConsole; - this.level = level; - this.fd = -1; - this.seq = 0; - this.inGroup = false; - this.firstInGroup = true; - } - Logger.padStringRight = function (str, padding) { - return (str + padding).slice(0, padding.length); - }; - Logger.prototype.close = function () { - if (this.fd >= 0) { - fs.close(this.fd); - } - }; - Logger.prototype.getLogFileName = function () { - return this.logFilename; - }; - Logger.prototype.perftrc = function (s) { - this.msg(s, server.Msg.Perf); - }; - Logger.prototype.info = function (s) { - this.msg(s, server.Msg.Info); - }; - Logger.prototype.startGroup = function () { - this.inGroup = true; - this.firstInGroup = true; - }; - Logger.prototype.endGroup = function () { - this.inGroup = false; - this.seq++; - this.firstInGroup = true; - }; - Logger.prototype.loggingEnabled = function () { - return !!this.logFilename || this.traceToConsole; - }; - Logger.prototype.hasLevel = function (level) { - return this.loggingEnabled() && this.level >= level; - }; - Logger.prototype.msg = function (s, type) { - if (type === void 0) { type = server.Msg.Err; } - if (this.fd < 0) { - if (this.logFilename) { - this.fd = fs.openSync(this.logFilename, "w"); - } - } - if (this.fd >= 0 || this.traceToConsole) { - s = s + "\n"; - var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); - if (this.firstInGroup) { - s = prefix + s; - this.firstInGroup = false; - } - if (!this.inGroup) { - this.seq++; - this.firstInGroup = true; - } - if (this.fd >= 0) { - var buf = new Buffer(s); - fs.writeSync(this.fd, buf, 0, buf.length, null); - } - if (this.traceToConsole) { - console.warn(s); - } - } - }; - return Logger; - }()); - var NodeTypingsInstaller = (function () { - function NodeTypingsInstaller(logger, eventPort, globalTypingsCacheLocation, newLine) { - var _this = this; - this.logger = logger; - this.eventPort = eventPort; - this.globalTypingsCacheLocation = globalTypingsCacheLocation; - this.newLine = newLine; - if (eventPort) { - var s_1 = net.connect({ port: eventPort }, function () { - _this.socket = s_1; - }); - } - } - NodeTypingsInstaller.prototype.attach = function (projectService) { - var _this = this; - this.projectService = projectService; - if (this.logger.hasLevel(server.LogLevel.requestTime)) { - this.logger.info("Binding..."); - } - var args = ["--globalTypingsCacheLocation", this.globalTypingsCacheLocation]; - if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { - args.push("--logFile", ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); - } - var execArgv = []; - { - for (var _i = 0, _a = process.execArgv; _i < _a.length; _i++) { - var arg = _a[_i]; - var match = /^--(debug|inspect)(=(\d+))?$/.exec(arg); - if (match) { - var currentPort = match[3] !== undefined - ? +match[3] - : match[1] === "debug" ? 5858 : 9229; - execArgv.push("--" + match[1] + "=" + (currentPort + 1)); + 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; } - this.installer = childProcess.fork(ts.combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv: execArgv }); - this.installer.on("message", function (m) { return _this.handleMessage(m); }); - process.on("exit", function () { - _this.installer.kill(); - }); - }; - NodeTypingsInstaller.prototype.onProjectClosed = function (p) { - this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" }); - }; - NodeTypingsInstaller.prototype.enqueueInstallTypingsRequest = function (project, typingOptions) { - var request = server.createInstallTypingsRequest(project, typingOptions); - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Sending request: " + JSON.stringify(request)); + if (interiorNodes.length === 1) { + return interiorNodes[0]; + } + else { + return this.buildTreeFromBottom(interiorNodes); } - this.installer.send(request); }; - NodeTypingsInstaller.prototype.handleMessage = function (response) { - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Received response: " + JSON.stringify(response)); + LineIndex.linesFromText = function (text) { + var lineStarts = ts.computeLineStarts(text); + if (lineStarts.length === 0) { + return { lines: [], lineMap: lineStarts }; } - this.projectService.updateTypingsForProject(response); - if (response.kind == "set" && this.socket) { - this.socket.write(server.formatMessage({ seq: 0, type: "event", message: response }, this.logger, Buffer.byteLength, this.newLine), "utf8"); + 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 NodeTypingsInstaller; + return LineIndex; }()); - var IOSession = (function (_super) { - __extends(IOSession, _super); - function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, globalTypingsCacheLocation, logger) { - return _super.call(this, host, cancellationToken, useSingleInferredProject, new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; + server.LineIndex = LineIndex; + var LineNode = (function () { + function LineNode() { + this.totalChars = 0; + this.totalLines = 0; + this.children = []; } - IOSession.prototype.exit = function () { - this.logger.info("Exiting..."); - this.projectService.closeLog(); - process.exit(0); + LineNode.prototype.isLeaf = function () { + return false; }; - IOSession.prototype.listen = function () { - var _this = this; - rl.on("line", function (input) { - var message = input.trim(); - _this.onMessage(message); - }); - rl.on("close", function () { - _this.exit(); - }); + 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]; + this.totalChars += child.charCount(); + this.totalLines += child.lineCount(); + } }; - return IOSession; - }(server.Session)); - function parseLoggingEnvironmentString(logEnvStr) { - var logEnv = { logToFile: true }; - var args = logEnvStr.split(" "); - for (var i = 0, len = args.length; i < (len - 1); i += 2) { - var option = args[i]; - var value = args[i + 1]; - if (option && value) { - switch (option) { - case "-file": - logEnv.file = ts.stripQuotes(value); - break; - case "-level": - var level = server.LogLevel[value]; - logEnv.detailLevel = typeof level === "number" ? level : server.LogLevel.normal; - break; - case "-traceToConsole": - logEnv.traceToConsole = value.toLowerCase() === "true"; - break; - case "-logToFile": - logEnv.logToFile = value.toLowerCase() === "true"; - break; - } + LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { + if (walkFns.pre) { + walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); } - } - return logEnv; - } - function createLoggerFromEnv() { - var fileName = undefined; - var detailLevel = server.LogLevel.normal; - var traceToConsole = false; - var logEnvStr = process.env["TSS_LOG"]; - if (logEnvStr) { - var logEnv = parseLoggingEnvironmentString(logEnvStr); - if (logEnv.logToFile) { - if (logEnv.file) { - fileName = logEnv.file; - } - else { - fileName = __dirname + "/.log" + process.pid.toString(); + if (walkFns.goSubtree) { + this.children[childIndex].walk(rangeStart, rangeLength, walkFns); + if (walkFns.post) { + walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); } } - if (logEnv.detailLevel) { - detailLevel = logEnv.detailLevel; + else { + walkFns.goSubtree = true; } - traceToConsole = logEnv.traceToConsole; - } - return new Logger(fileName, traceToConsole, detailLevel); - } - function createPollingWatchedFileSet(interval, chunkSize) { - if (interval === void 0) { interval = 2500; } - if (chunkSize === void 0) { chunkSize = 30; } - var watchedFiles = []; - var nextFileToCheck = 0; - var watchTimer; - function getModifiedTime(fileName) { - return fs.statSync(fileName).mtime; - } - function poll(checkedIndex) { - var watchedFile = watchedFiles[checkedIndex]; - if (!watchedFile) { - return; + 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; } - fs.stat(watchedFile.fileName, function (err, stats) { - if (err) { - watchedFile.callback(watchedFile.fileName); + }; + 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 (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { - watchedFile.mtime = getModifiedTime(watchedFile.fileName); - watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + else { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, CharRangeSection.Start)) { + return; } - }); - } - function startWatchTimer() { - watchTimer = setInterval(function () { - var count = 0; - var nextToCheck = nextFileToCheck; - var firstCheck = -1; - while ((count < chunkSize) && (nextToCheck !== firstCheck)) { - poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; + 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; } - nextToCheck++; - if (nextToCheck === watchedFiles.length) { - nextToCheck = 0; + adjustedLength -= childCharCount; + childIndex++; + child = this.children[childIndex]; + childCharCount = child.charCount(); + } + if (adjustedLength > 0) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, CharRangeSection.End)) { + return; } - count++; } - nextFileToCheck = nextToCheck; - }, interval); - } - function addFile(fileName, callback) { - var file = { - fileName: fileName, - callback: callback, - mtime: getModifiedTime(fileName) - }; - watchedFiles.push(file); - if (watchedFiles.length === 1) { - startWatchTimer(); - } - return file; - } - function removeFile(file) { - ts.unorderedRemoveItem(watchedFiles, file); - } - return { - getModifiedTime: getModifiedTime, - poll: poll, - startWatchTimer: startWatchTimer, - addFile: addFile, - removeFile: removeFile - }; - } - var pollingWatchedFileSet = createPollingWatchedFileSet(); - var logger = createLoggerFromEnv(); - var pending = []; - var canWrite = true; - function writeMessage(buf) { - if (!canWrite) { - pending.push(buf); - } - else { - canWrite = false; - process.stdout.write(buf, setCanWriteFlagAndWriteMessageIfNecessary); - } - } - function setCanWriteFlagAndWriteMessageIfNecessary() { - canWrite = true; - if (pending.length) { - writeMessage(pending.shift()); - } - } - var sys = ts.sys; - sys.write = function (s) { return writeMessage(new Buffer(s, "utf8")); }; - sys.watchFile = function (fileName, callback) { - var watchedFile = pollingWatchedFileSet.addFile(fileName, callback); - return { - close: function () { return pollingWatchedFileSet.removeFile(watchedFile); } - }; - }; - sys.setTimeout = setTimeout; - sys.clearTimeout = clearTimeout; - sys.setImmediate = setImmediate; - sys.clearImmediate = clearImmediate; - if (typeof global !== "undefined" && global.gc) { - sys.gc = function () { return global.gc(); }; - } - var cancellationToken; - try { - var factory = require("./cancellationToken"); - cancellationToken = factory(sys.args); - } - catch (e) { - cancellationToken = { - isCancellationRequested: function () { return false; } - }; - } - ; - var eventPort; - { - var index = sys.args.indexOf("--eventPort"); - if (index >= 0 && index < sys.args.length - 1) { - var v = parseInt(sys.args[index + 1]); - if (!isNaN(v)) { - eventPort = v; } - } - } - var useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0; - var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, getGlobalTypingsCacheLocation(), logger); - process.on("uncaughtException", function (err) { - ioSession.logError(err, "unknown"); - }); - process.noAsar = true; - ioSession.listen(); - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var debugObjectHost = (function () { return this; })(); -var ts; -(function (ts) { - function logInternalError(logger, err) { - if (logger) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); - } - } - var ScriptSnapshotShimAdapter = (function () { - function ScriptSnapshotShimAdapter(scriptSnapshotShim) { - this.scriptSnapshotShim = scriptSnapshotShim; - } - ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { - return this.scriptSnapshotShim.getText(start, end); - }; - ScriptSnapshotShimAdapter.prototype.getLength = function () { - return this.scriptSnapshotShim.getLength(); - }; - ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { - return null; - } - var decoded = JSON.parse(encoded); - return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); - return ts.map(moduleNames, function (name) { - var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - LanguageServiceShimHostAdapter.prototype.log = function (s) { - if (this.loggingEnabled) { - this.shimHost.log(s); - } - }; - LanguageServiceShimHostAdapter.prototype.trace = function (s) { - if (this.tracingEnabled) { - this.shimHost.trace(s); - } - }; - LanguageServiceShimHostAdapter.prototype.error = function (s) { - this.shimHost.error(s); - }; - LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { - if (!this.shimHost.getProjectVersion) { - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { - return this.shimHost.getScriptVersion(fileName); - }; - LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { - return null; - } - try { - return JSON.parse(diagnosticMessagesJson); - } - catch (e) { - this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); - return null; - } - }; - LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); - }; - LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { - return this.shimHost.getCurrentDirectory(); - }; - LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); + 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); } } } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof result === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; + }; + LineNode.prototype.charOffsetToLineNumberAndPos = function (lineNumber, charOffset) { + var childInfo = this.childFromCharOffset(lineNumber, charOffset); + if (!childInfo.child) { + return { + line: lineNumber, + offset: charOffset, + }; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); - } - } - return result; - } - function forwardJSONCall(logger, actionDescription, action, logPerformance) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: result }) : result; - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - return JSON.stringify({ canceled: true }); - } - logInternalError(logger, err); - err.description = actionDescription; - return JSON.stringify({ error: err }); - } - } - var ShimBase = (function () { - function ShimBase(factory) { - this.factory = factory; - factory.registerShim(this); - } - ShimBase.prototype.dispose = function (dummy) { - this.factory.unregisterShim(this); - }; - return ShimBase; - }()); - function realizeDiagnostics(diagnostics, newLine) { - return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); - } - ts.realizeDiagnostics = realizeDiagnostics; - function realizeDiagnostic(diagnostic, newLine) { - return { - message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), - start: diagnostic.start, - length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - var LanguageServiceShimObject = (function (_super) { - __extends(LanguageServiceShimObject, _super); - function LanguageServiceShimObject(factory, host, languageService) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); + 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; } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); - }; - LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { - var _this = this; - this.forwardJSONCall("cleanupSemanticCache()", function () { - _this.languageService.cleanupSemanticCache(); - return null; - }); - }; - LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { - var _this = this; - return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { - var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { - var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); - }; - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { - var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - return LanguageServiceShimObject; - }(ShimBase)); - function convertClassifications(classifications) { - return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; - } - var ClassifierShimObject = (function (_super) { - __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory, logger) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { - var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); - }; - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; + 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) { + var net = require("net"); + var childProcess = require("child_process"); + var os = require("os"); + function getGlobalTypingsCacheLocation() { + var basePath; + switch (process.platform) { + case "win32": + basePath = process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir(); + break; + case "linux": + basePath = os.homedir(); + break; + case "darwin": + basePath = ts.combinePaths(os.homedir(), "Library/Application Support/"); + break; } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; + ts.Debug.assert(basePath !== undefined); + return ts.combinePaths(ts.normalizeSlashes(basePath), "Microsoft/TypeScript"); } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) - }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; + var readline = require("readline"); + var fs = require("fs"); + var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + terminal: false, + }); + var Logger = (function () { + function Logger(logFilename, traceToConsole, level) { + this.logFilename = logFilename; + this.traceToConsole = traceToConsole; + this.level = level; + this.fd = -1; + this.seq = 0; + this.inGroup = false; + this.firstInGroup = true; } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos + Logger.padStringRight = function (str, padding) { + return (str + padding).slice(0, padding.length); + }; + Logger.prototype.close = function () { + if (this.fd >= 0) { + fs.close(this.fd); + } + }; + Logger.prototype.getLogFileName = function () { + return this.logFilename; + }; + Logger.prototype.perftrc = function (s) { + this.msg(s, server.Msg.Perf); + }; + Logger.prototype.info = function (s) { + this.msg(s, server.Msg.Info); + }; + Logger.prototype.startGroup = function () { + this.inGroup = true; + this.firstInGroup = true; + }; + Logger.prototype.endGroup = function () { + this.inGroup = false; + this.seq++; + this.firstInGroup = true; + }; + Logger.prototype.loggingEnabled = function () { + return !!this.logFilename || this.traceToConsole; + }; + Logger.prototype.hasLevel = function (level) { + return this.loggingEnabled() && this.level >= level; + }; + Logger.prototype.msg = function (s, type) { + if (type === void 0) { type = server.Msg.Err; } + if (this.fd < 0) { + if (this.logFilename) { + this.fd = fs.openSync(this.logFilename, "w"); + } + } + if (this.fd >= 0 || this.traceToConsole) { + s = s + "\n"; + var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); + if (this.firstInGroup) { + s = prefix + s; + this.firstInGroup = false; + } + if (!this.inGroup) { + this.seq++; + this.firstInGroup = true; + } + if (this.fd >= 0) { + var buf = new Buffer(s); + fs.writeSync(this.fd, buf, 0, buf.length, null); + } + if (this.traceToConsole) { + console.warn(s); + } + } + }; + return Logger; + }()); + var NodeTypingsInstaller = (function () { + function NodeTypingsInstaller(logger, eventPort, globalTypingsCacheLocation, newLine) { + var _this = this; + this.logger = logger; + this.globalTypingsCacheLocation = globalTypingsCacheLocation; + this.newLine = newLine; + if (eventPort) { + var s_1 = net.connect({ port: eventPort }, function () { + _this.socket = s_1; + }); + } + } + NodeTypingsInstaller.prototype.attach = function (projectService) { + var _this = this; + this.projectService = projectService; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + this.logger.info("Binding..."); + } + var args = ["--globalTypingsCacheLocation", this.globalTypingsCacheLocation]; + if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { + args.push("--logFile", ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); + } + var execArgv = []; + { + for (var _i = 0, _a = process.execArgv; _i < _a.length; _i++) { + var arg = _a[_i]; + var match = /^--(debug|inspect)(=(\d+))?$/.exec(arg); + if (match) { + var currentPort = match[3] !== undefined + ? +match[3] + : match[1] === "debug" ? 5858 : 9229; + execArgv.push("--" + match[1] + "=" + (currentPort + 1)); + break; + } + } + } + this.installer = childProcess.fork(ts.combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv: execArgv }); + this.installer.on("message", function (m) { return _this.handleMessage(m); }); + process.on("exit", function () { + _this.installer.kill(); }); + }; + NodeTypingsInstaller.prototype.onProjectClosed = function (p) { + this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" }); + }; + NodeTypingsInstaller.prototype.enqueueInstallTypingsRequest = function (project, typingOptions) { + var request = server.createInstallTypingsRequest(project, typingOptions); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Sending request: " + JSON.stringify(request)); + } + this.installer.send(request); + }; + NodeTypingsInstaller.prototype.handleMessage = function (response) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Received response: " + JSON.stringify(response)); + } + this.projectService.updateTypingsForProject(response); + if (response.kind == "set" && this.socket) { + this.socket.write(server.formatMessage({ seq: 0, type: "event", message: response }, this.logger, Buffer.byteLength, this.newLine), "utf8"); + } + }; + return NodeTypingsInstaller; + }()); + var IOSession = (function (_super) { + __extends(IOSession, _super); + function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, logger) { + return _super.call(this, host, cancellationToken, useSingleInferredProject, disableAutomaticTypingAcquisition + ? server.nullTypingsInstaller + : new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; } - return result; - }; - CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { - var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileTextToJson(fileName, text); - if (result.error) { - return { - options: {}, - typingOptions: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] - }; + IOSession.prototype.exit = function () { + this.logger.info("Exiting..."); + this.projectService.closeLog(); + process.exit(0); + }; + IOSession.prototype.listen = function () { + var _this = this; + rl.on("line", function (input) { + var message = input.trim(); + _this.onMessage(message); + }); + rl.on("close", function () { + _this.exit(); + }); + }; + return IOSession; + }(server.Session)); + function parseLoggingEnvironmentString(logEnvStr) { + var logEnv = { logToFile: true }; + var args = logEnvStr.split(" "); + for (var i = 0, len = args.length; i < (len - 1); i += 2) { + var option = args[i]; + var value = args[i + 1]; + if (option && value) { + switch (option) { + case "-file": + logEnv.file = ts.stripQuotes(value); + break; + case "-level": + var level = server.LogLevel[value]; + logEnv.detailLevel = typeof level === "number" ? level : server.LogLevel.normal; + break; + case "-traceToConsole": + logEnv.traceToConsole = value.toLowerCase() === "true"; + break; + case "-logToFile": + logEnv.logToFile = value.toLowerCase() === "true"; + break; + } } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); - return { - options: configFile.options, - typingOptions: configFile.typingOptions, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); - }); - }; - return CoreServicesShimObject; - }(ShimBase)); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; + } + return logEnv; } - TypeScriptServicesFactory.prototype.getServicesVersion = function () { - return ts.servicesVersion; - }; - TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { - try { - if (this.documentRegistry === undefined) { - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + function createLoggerFromEnv() { + var fileName = undefined; + var detailLevel = server.LogLevel.normal; + var traceToConsole = false; + var logEnvStr = process.env["TSS_LOG"]; + if (logEnvStr) { + var logEnv = parseLoggingEnvironmentString(logEnvStr); + if (logEnv.logToFile) { + if (logEnv.file) { + fileName = logEnv.file; + } + else { + fileName = __dirname + "/.log" + process.pid.toString(); + } } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); - return new LanguageServiceShimObject(this, host, languageService); + if (logEnv.detailLevel) { + detailLevel = logEnv.detailLevel; + } + traceToConsole = logEnv.traceToConsole; } - catch (err) { - logInternalError(host, err); - throw err; + return new Logger(fileName, traceToConsole, detailLevel); + } + function createPollingWatchedFileSet(interval, chunkSize) { + if (interval === void 0) { interval = 2500; } + if (chunkSize === void 0) { chunkSize = 30; } + var watchedFiles = []; + var nextFileToCheck = 0; + var watchTimer; + function getModifiedTime(fileName) { + return fs.statSync(fileName).mtime; } - }; - TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { - try { - return new ClassifierShimObject(this, logger); + function poll(checkedIndex) { + var watchedFile = watchedFiles[checkedIndex]; + if (!watchedFile) { + return; + } + fs.stat(watchedFile.fileName, function (err, stats) { + if (err) { + watchedFile.callback(watchedFile.fileName); + } + else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) { + watchedFile.mtime = getModifiedTime(watchedFile.fileName); + watchedFile.callback(watchedFile.fileName, watchedFile.mtime.getTime() === 0); + } + }); } - catch (err) { - logInternalError(logger, err); - throw err; + function startWatchTimer() { + watchTimer = setInterval(function () { + var count = 0; + var nextToCheck = nextFileToCheck; + var firstCheck = -1; + while ((count < chunkSize) && (nextToCheck !== firstCheck)) { + poll(nextToCheck); + if (firstCheck < 0) { + firstCheck = nextToCheck; + } + nextToCheck++; + if (nextToCheck === watchedFiles.length) { + nextToCheck = 0; + } + count++; + } + nextFileToCheck = nextToCheck; + }, interval); } - }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { - try { - var adapter = new CoreServicesShimHostAdapter(host); - return new CoreServicesShimObject(this, host, adapter); + function addFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(fileName) + }; + watchedFiles.push(file); + if (watchedFiles.length === 1) { + startWatchTimer(); + } + return file; } - catch (err) { - logInternalError(host, err); - throw err; + function removeFile(file) { + ts.unorderedRemoveItem(watchedFiles, file); } + return { + getModifiedTime: getModifiedTime, + poll: poll, + startWatchTimer: startWatchTimer, + addFile: addFile, + removeFile: removeFile + }; + } + var pollingWatchedFileSet = createPollingWatchedFileSet(); + var logger = createLoggerFromEnv(); + var pending = []; + var canWrite = true; + function writeMessage(buf) { + if (!canWrite) { + pending.push(buf); + } + else { + canWrite = false; + process.stdout.write(buf, setCanWriteFlagAndWriteMessageIfNecessary); + } + } + function setCanWriteFlagAndWriteMessageIfNecessary() { + canWrite = true; + if (pending.length) { + writeMessage(pending.shift()); + } + } + var sys = ts.sys; + sys.write = function (s) { return writeMessage(new Buffer(s, "utf8")); }; + sys.watchFile = function (fileName, callback) { + var watchedFile = pollingWatchedFileSet.addFile(fileName, callback); + return { + close: function () { return pollingWatchedFileSet.removeFile(watchedFile); } + }; }; - TypeScriptServicesFactory.prototype.close = function () { - this._shims = []; - this.documentRegistry = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { - if (this._shims[i] === shim) { - delete this._shims[i]; - return; + sys.setTimeout = setTimeout; + sys.clearTimeout = clearTimeout; + sys.setImmediate = setImmediate; + sys.clearImmediate = clearImmediate; + if (typeof global !== "undefined" && global.gc) { + sys.gc = function () { return global.gc(); }; + } + var cancellationToken; + try { + var factory = require("./cancellationToken"); + cancellationToken = factory(sys.args); + } + catch (e) { + cancellationToken = { + isCancellationRequested: function () { return false; } + }; + } + ; + var eventPort; + { + var index = sys.args.indexOf("--eventPort"); + if (index >= 0 && index < sys.args.length - 1) { + var v = parseInt(sys.args[index + 1]); + if (!isNaN(v)) { + eventPort = v; } } - throw new Error("Invalid operation"); - }; - return TypeScriptServicesFactory; - }()); - ts.TypeScriptServicesFactory = TypeScriptServicesFactory; - if (typeof module !== "undefined" && module.exports) { - module.exports = ts; - } + } + var useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0; + var disableAutomaticTypingAcquisition = sys.args.indexOf("--disableAutomaticTypingAcquisition") >= 0; + var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), logger); + process.on("uncaughtException", function (err) { + ioSession.logError(err, "unknown"); + }); + process.noAsar = true; + ioSession.listen(); + })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var toolsVersion = "2.1"; + +//# sourceMappingURL=tsserver.js.map diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index c23bccf0a6828..63580ce8dcd7f 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,9487 +1,3252 @@ +/*! ***************************************************************************** +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.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"; +declare namespace ts { + interface MapLike { + [index: string]: T; } - interface Message { - seq: number; - type: string; + interface Map extends MapLike { + __mapBrand: any; } - interface Request extends Message { - command: string; - arguments?: any; + type Path = string & { + __pathBrand: any; + }; + interface FileMap { + get(fileName: Path): T; + set(fileName: Path, value: T): void; + contains(fileName: Path): boolean; + remove(fileName: Path): void; + forEachValue(f: (key: Path, v: T) => void): void; + getKeys(): Path[]; + clear(): void; } - interface ReloadProjectsRequest extends Message { - command: CommandTypes.ReloadProjects; + interface TextRange { + pos: number; + end: number; } - interface Event extends Message { - event: string; - body?: any; + const enum SyntaxKind { + Unknown = 0, + EndOfFileToken = 1, + SingleLineCommentTrivia = 2, + MultiLineCommentTrivia = 3, + NewLineTrivia = 4, + WhitespaceTrivia = 5, + ShebangTrivia = 6, + ConflictMarkerTrivia = 7, + NumericLiteral = 8, + StringLiteral = 9, + JsxText = 10, + RegularExpressionLiteral = 11, + NoSubstitutionTemplateLiteral = 12, + TemplateHead = 13, + TemplateMiddle = 14, + TemplateTail = 15, + OpenBraceToken = 16, + CloseBraceToken = 17, + OpenParenToken = 18, + CloseParenToken = 19, + OpenBracketToken = 20, + CloseBracketToken = 21, + DotToken = 22, + DotDotDotToken = 23, + SemicolonToken = 24, + CommaToken = 25, + LessThanToken = 26, + LessThanSlashToken = 27, + GreaterThanToken = 28, + LessThanEqualsToken = 29, + GreaterThanEqualsToken = 30, + EqualsEqualsToken = 31, + ExclamationEqualsToken = 32, + EqualsEqualsEqualsToken = 33, + ExclamationEqualsEqualsToken = 34, + EqualsGreaterThanToken = 35, + PlusToken = 36, + MinusToken = 37, + AsteriskToken = 38, + AsteriskAsteriskToken = 39, + SlashToken = 40, + PercentToken = 41, + PlusPlusToken = 42, + MinusMinusToken = 43, + LessThanLessThanToken = 44, + GreaterThanGreaterThanToken = 45, + GreaterThanGreaterThanGreaterThanToken = 46, + AmpersandToken = 47, + BarToken = 48, + CaretToken = 49, + ExclamationToken = 50, + TildeToken = 51, + AmpersandAmpersandToken = 52, + BarBarToken = 53, + QuestionToken = 54, + ColonToken = 55, + AtToken = 56, + EqualsToken = 57, + PlusEqualsToken = 58, + MinusEqualsToken = 59, + AsteriskEqualsToken = 60, + AsteriskAsteriskEqualsToken = 61, + SlashEqualsToken = 62, + PercentEqualsToken = 63, + LessThanLessThanEqualsToken = 64, + GreaterThanGreaterThanEqualsToken = 65, + GreaterThanGreaterThanGreaterThanEqualsToken = 66, + AmpersandEqualsToken = 67, + BarEqualsToken = 68, + CaretEqualsToken = 69, + Identifier = 70, + BreakKeyword = 71, + CaseKeyword = 72, + CatchKeyword = 73, + ClassKeyword = 74, + ConstKeyword = 75, + ContinueKeyword = 76, + DebuggerKeyword = 77, + DefaultKeyword = 78, + DeleteKeyword = 79, + DoKeyword = 80, + ElseKeyword = 81, + EnumKeyword = 82, + ExportKeyword = 83, + ExtendsKeyword = 84, + FalseKeyword = 85, + FinallyKeyword = 86, + ForKeyword = 87, + FunctionKeyword = 88, + IfKeyword = 89, + ImportKeyword = 90, + InKeyword = 91, + InstanceOfKeyword = 92, + NewKeyword = 93, + NullKeyword = 94, + ReturnKeyword = 95, + SuperKeyword = 96, + SwitchKeyword = 97, + ThisKeyword = 98, + ThrowKeyword = 99, + TrueKeyword = 100, + TryKeyword = 101, + TypeOfKeyword = 102, + VarKeyword = 103, + VoidKeyword = 104, + WhileKeyword = 105, + WithKeyword = 106, + ImplementsKeyword = 107, + InterfaceKeyword = 108, + LetKeyword = 109, + PackageKeyword = 110, + PrivateKeyword = 111, + ProtectedKeyword = 112, + PublicKeyword = 113, + StaticKeyword = 114, + YieldKeyword = 115, + AbstractKeyword = 116, + AsKeyword = 117, + AnyKeyword = 118, + AsyncKeyword = 119, + AwaitKeyword = 120, + BooleanKeyword = 121, + ConstructorKeyword = 122, + DeclareKeyword = 123, + GetKeyword = 124, + IsKeyword = 125, + ModuleKeyword = 126, + NamespaceKeyword = 127, + NeverKeyword = 128, + ReadonlyKeyword = 129, + RequireKeyword = 130, + NumberKeyword = 131, + SetKeyword = 132, + StringKeyword = 133, + SymbolKeyword = 134, + TypeKeyword = 135, + UndefinedKeyword = 136, + FromKeyword = 137, + GlobalKeyword = 138, + OfKeyword = 139, + QualifiedName = 140, + ComputedPropertyName = 141, + TypeParameter = 142, + Parameter = 143, + Decorator = 144, + PropertySignature = 145, + PropertyDeclaration = 146, + MethodSignature = 147, + MethodDeclaration = 148, + Constructor = 149, + GetAccessor = 150, + SetAccessor = 151, + CallSignature = 152, + ConstructSignature = 153, + IndexSignature = 154, + TypePredicate = 155, + TypeReference = 156, + FunctionType = 157, + ConstructorType = 158, + TypeQuery = 159, + TypeLiteral = 160, + ArrayType = 161, + TupleType = 162, + UnionType = 163, + IntersectionType = 164, + ParenthesizedType = 165, + ThisType = 166, + LiteralType = 167, + ObjectBindingPattern = 168, + ArrayBindingPattern = 169, + BindingElement = 170, + ArrayLiteralExpression = 171, + ObjectLiteralExpression = 172, + PropertyAccessExpression = 173, + ElementAccessExpression = 174, + CallExpression = 175, + NewExpression = 176, + TaggedTemplateExpression = 177, + TypeAssertionExpression = 178, + ParenthesizedExpression = 179, + FunctionExpression = 180, + ArrowFunction = 181, + DeleteExpression = 182, + TypeOfExpression = 183, + VoidExpression = 184, + AwaitExpression = 185, + PrefixUnaryExpression = 186, + PostfixUnaryExpression = 187, + BinaryExpression = 188, + ConditionalExpression = 189, + TemplateExpression = 190, + YieldExpression = 191, + SpreadElementExpression = 192, + ClassExpression = 193, + OmittedExpression = 194, + ExpressionWithTypeArguments = 195, + AsExpression = 196, + NonNullExpression = 197, + TemplateSpan = 198, + SemicolonClassElement = 199, + Block = 200, + VariableStatement = 201, + EmptyStatement = 202, + ExpressionStatement = 203, + IfStatement = 204, + DoStatement = 205, + WhileStatement = 206, + ForStatement = 207, + ForInStatement = 208, + ForOfStatement = 209, + ContinueStatement = 210, + BreakStatement = 211, + ReturnStatement = 212, + WithStatement = 213, + SwitchStatement = 214, + LabeledStatement = 215, + ThrowStatement = 216, + TryStatement = 217, + DebuggerStatement = 218, + VariableDeclaration = 219, + VariableDeclarationList = 220, + FunctionDeclaration = 221, + ClassDeclaration = 222, + InterfaceDeclaration = 223, + TypeAliasDeclaration = 224, + EnumDeclaration = 225, + ModuleDeclaration = 226, + ModuleBlock = 227, + CaseBlock = 228, + NamespaceExportDeclaration = 229, + ImportEqualsDeclaration = 230, + ImportDeclaration = 231, + ImportClause = 232, + NamespaceImport = 233, + NamedImports = 234, + ImportSpecifier = 235, + ExportAssignment = 236, + ExportDeclaration = 237, + NamedExports = 238, + ExportSpecifier = 239, + MissingDeclaration = 240, + ExternalModuleReference = 241, + JsxElement = 242, + JsxSelfClosingElement = 243, + JsxOpeningElement = 244, + JsxClosingElement = 245, + JsxAttribute = 246, + JsxSpreadAttribute = 247, + JsxExpression = 248, + CaseClause = 249, + DefaultClause = 250, + HeritageClause = 251, + CatchClause = 252, + PropertyAssignment = 253, + ShorthandPropertyAssignment = 254, + EnumMember = 255, + SourceFile = 256, + JSDocTypeExpression = 257, + JSDocAllType = 258, + JSDocUnknownType = 259, + JSDocArrayType = 260, + JSDocUnionType = 261, + JSDocTupleType = 262, + JSDocNullableType = 263, + JSDocNonNullableType = 264, + JSDocRecordType = 265, + JSDocRecordMember = 266, + JSDocTypeReference = 267, + JSDocOptionalType = 268, + JSDocFunctionType = 269, + JSDocVariadicType = 270, + JSDocConstructorType = 271, + JSDocThisType = 272, + JSDocComment = 273, + JSDocTag = 274, + JSDocParameterTag = 275, + JSDocReturnTag = 276, + JSDocTypeTag = 277, + JSDocTemplateTag = 278, + JSDocTypedefTag = 279, + JSDocPropertyTag = 280, + JSDocTypeLiteral = 281, + JSDocLiteralType = 282, + JSDocNullKeyword = 283, + JSDocUndefinedKeyword = 284, + JSDocNeverKeyword = 285, + SyntaxList = 286, + NotEmittedStatement = 287, + PartiallyEmittedExpression = 288, + Count = 289, + FirstAssignment = 57, + LastAssignment = 69, + FirstCompoundAssignment = 58, + LastCompoundAssignment = 69, + FirstReservedWord = 71, + LastReservedWord = 106, + FirstKeyword = 71, + LastKeyword = 139, + FirstFutureReservedWord = 107, + LastFutureReservedWord = 115, + FirstTypeNode = 155, + LastTypeNode = 167, + FirstPunctuation = 16, + LastPunctuation = 69, + FirstToken = 0, + LastToken = 139, + FirstTriviaToken = 2, + LastTriviaToken = 7, + FirstLiteralToken = 8, + LastLiteralToken = 12, + FirstTemplateToken = 12, + LastTemplateToken = 15, + FirstBinaryOperator = 26, + LastBinaryOperator = 69, + FirstNode = 140, + FirstJSDocNode = 257, + LastJSDocNode = 282, + FirstJSDocTagNode = 273, + LastJSDocTagNode = 285, } - interface Response extends Message { - request_seq: number; - success: boolean; - command: string; - message?: string; - body?: any; + const enum NodeFlags { + None = 0, + Let = 1, + Const = 2, + NestedNamespace = 4, + Synthesized = 8, + Namespace = 16, + ExportContext = 32, + ContainsThis = 64, + HasImplicitReturn = 128, + HasExplicitReturn = 256, + GlobalAugmentation = 512, + HasClassExtends = 1024, + HasDecorators = 2048, + HasParamDecorators = 4096, + HasAsyncFunctions = 8192, + HasJsxSpreadAttributes = 16384, + DisallowInContext = 32768, + YieldContext = 65536, + DecoratorContext = 131072, + AwaitContext = 262144, + ThisNodeHasError = 524288, + JavaScriptFile = 1048576, + ThisNodeOrAnySubNodesHasError = 2097152, + HasAggregatedChildData = 4194304, + BlockScoped = 3, + ReachabilityCheckFlags = 384, + EmitHelperFlags = 31744, + ReachabilityAndEmitFlags = 32128, + ContextFlags = 1540096, + TypeExcludesFlags = 327680, } - interface FileRequestArgs { - file: string; - projectFileName?: string; + const enum ModifierFlags { + None = 0, + Export = 1, + Ambient = 2, + Public = 4, + Private = 8, + Protected = 16, + Static = 32, + Readonly = 64, + Abstract = 128, + Async = 256, + Default = 512, + Const = 2048, + HasComputedFlags = 536870912, + AccessibilityModifier = 28, + ParameterPropertyModifier = 92, + NonPublicAccessibilityModifier = 24, + TypeScriptModifier = 2270, } - interface DocCommentTemplateRequest extends FileLocationRequest { - command: CommandTypes.DocCommentTemplate; + const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1, + IntrinsicIndexedElement = 2, + IntrinsicElement = 3, } - interface DocCommandTemplateResponse extends Response { - body?: TextInsertion; + interface Node extends TextRange { + kind: SyntaxKind; + flags: NodeFlags; + decorators?: NodeArray; + modifiers?: ModifiersArray; + parent?: Node; } - interface TodoCommentRequest extends FileRequest { - command: CommandTypes.TodoComments; - arguments: TodoCommentRequestArgs; + interface NodeArray extends Array, TextRange { + hasTrailingComma?: boolean; } - interface TodoCommentRequestArgs extends FileRequestArgs { - descriptors: TodoCommentDescriptor[]; + interface Token extends Node { + kind: TKind; } - interface TodoCommentsResponse extends Response { - body?: TodoComment[]; + type DotDotDotToken = Token; + type QuestionToken = Token; + type ColonToken = Token; + type EqualsToken = Token; + type AsteriskToken = Token; + type EqualsGreaterThanToken = Token; + type EndOfFileToken = Token; + type AtToken = Token; + type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + type ModifiersArray = NodeArray; + interface Identifier extends PrimaryExpression { + kind: SyntaxKind.Identifier; + text: string; + originalKeywordKind?: SyntaxKind; } - interface OutliningSpansRequest extends FileRequest { - command: CommandTypes.OutliningSpans; + interface TransientIdentifier extends Identifier { + resolvedSymbol: Symbol; } - interface OutliningSpansResponse extends Response { - body?: OutliningSpan[]; + interface QualifiedName extends Node { + kind: SyntaxKind.QualifiedName; + left: EntityName; + right: Identifier; } - interface IndentationRequest extends FileLocationRequest { - command: CommandTypes.Indentation; - arguments: IndentationRequestArgs; + type EntityName = Identifier | QualifiedName; + type PropertyName = Identifier | LiteralExpression | ComputedPropertyName; + type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; + interface Declaration extends Node { + _declarationBrand: any; + name?: DeclarationName; } - interface IndentationResponse extends Response { - body?: IndentationResult; + interface DeclarationStatement extends Declaration, Statement { + name?: Identifier | LiteralExpression; } - interface IndentationResult { - position: number; - indentation: number; - } - interface IndentationRequestArgs extends FileLocationRequestArgs { - options?: EditorSettings; + interface ComputedPropertyName extends Node { + kind: SyntaxKind.ComputedPropertyName; + expression: Expression; } - interface ProjectInfoRequestArgs extends FileRequestArgs { - needFileNameList: boolean; + interface Decorator extends Node { + kind: SyntaxKind.Decorator; + expression: LeftHandSideExpression; } - interface ProjectInfoRequest extends Request { - command: CommandTypes.ProjectInfo; - arguments: ProjectInfoRequestArgs; + interface TypeParameterDeclaration extends Declaration { + kind: SyntaxKind.TypeParameter; + name: Identifier; + constraint?: TypeNode; + expression?: Expression; } - interface CompilerOptionsDiagnosticsRequest extends Request { - arguments: CompilerOptionsDiagnosticsRequestArgs; + interface SignatureDeclaration extends Declaration { + name?: PropertyName; + typeParameters?: NodeArray; + parameters: NodeArray; + type?: TypeNode; } - interface CompilerOptionsDiagnosticsRequestArgs { - projectFileName: string; + interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.CallSignature; } - interface ProjectInfo { - configFileName: string; - fileNames?: string[]; - languageServiceDisabled?: boolean; + interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.ConstructSignature; } - interface DiagnosticWithLinePosition { - message: string; - start: number; - length: number; - startLocation: Location; - endLocation: Location; - category: string; - code: number; + type BindingName = Identifier | BindingPattern; + interface VariableDeclaration extends Declaration { + kind: SyntaxKind.VariableDeclaration; + parent?: VariableDeclarationList; + name: BindingName; + type?: TypeNode; + initializer?: Expression; } - interface ProjectInfoResponse extends Response { - body?: ProjectInfo; + interface VariableDeclarationList extends Node { + kind: SyntaxKind.VariableDeclarationList; + declarations: NodeArray; } - interface FileRequest extends Request { - arguments: FileRequestArgs; + interface ParameterDeclaration extends Declaration { + kind: SyntaxKind.Parameter; + dotDotDotToken?: DotDotDotToken; + name: BindingName; + questionToken?: QuestionToken; + type?: TypeNode; + initializer?: Expression; } - interface FileLocationRequestArgs extends FileRequestArgs { - line: number; - offset: number; - position?: number; + interface BindingElement extends Declaration { + kind: SyntaxKind.BindingElement; + propertyName?: PropertyName; + dotDotDotToken?: DotDotDotToken; + name: BindingName; + initializer?: Expression; } - interface CodeFixRequest extends Request { - command: CommandTypes.GetCodeFixes; - arguments: CodeFixRequestArgs; + interface PropertySignature extends TypeElement { + kind: SyntaxKind.PropertySignature | SyntaxKind.JSDocRecordMember; + name: PropertyName; + questionToken?: QuestionToken; + type?: TypeNode; + initializer?: Expression; } - interface CodeFixRequestArgs extends FileRequestArgs { - startLine: number; - startOffset: number; - startPosition?: number; - endLine: number; - endOffset: number; - endPosition?: number; - errorCodes?: number[]; + interface PropertyDeclaration extends ClassElement { + kind: SyntaxKind.PropertyDeclaration; + questionToken?: QuestionToken; + name: PropertyName; + type?: TypeNode; + initializer?: Expression; } - interface GetCodeFixesResponse extends Response { - body?: CodeAction[]; + interface ObjectLiteralElement extends Declaration { + _objectLiteralBrandBrand: any; + name?: PropertyName; } - interface FileLocationRequest extends FileRequest { - arguments: FileLocationRequestArgs; + type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; + interface PropertyAssignment extends ObjectLiteralElement { + kind: SyntaxKind.PropertyAssignment; + name: PropertyName; + questionToken?: QuestionToken; + initializer: Expression; } - interface GetSupportedCodeFixesRequest extends Request { - command: CommandTypes.GetSupportedCodeFixes; + interface ShorthandPropertyAssignment extends ObjectLiteralElement { + kind: SyntaxKind.ShorthandPropertyAssignment; + name: Identifier; + questionToken?: QuestionToken; + equalsToken?: Token; + objectAssignmentInitializer?: Expression; } - interface GetSupportedCodeFixesResponse extends Response { - body?: string[]; + interface VariableLikeDeclaration extends Declaration { + propertyName?: PropertyName; + dotDotDotToken?: DotDotDotToken; + name: DeclarationName; + questionToken?: QuestionToken; + type?: TypeNode; + initializer?: Expression; } - interface EncodedSemanticClassificationsRequest extends FileRequest { - arguments: EncodedSemanticClassificationsRequestArgs; + interface PropertyLikeDeclaration extends Declaration { + name: PropertyName; } - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { - start: number; - length: number; + interface BindingPattern extends Node { + elements: NodeArray; } - interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { - filesToSearch: string[]; + interface ObjectBindingPattern extends BindingPattern { + kind: SyntaxKind.ObjectBindingPattern; + elements: NodeArray; } - interface DefinitionRequest extends FileLocationRequest { - command: CommandTypes.Definition; + type ArrayBindingElement = BindingElement | OmittedExpression; + interface ArrayBindingPattern extends BindingPattern { + kind: SyntaxKind.ArrayBindingPattern; + elements: NodeArray; } - interface TypeDefinitionRequest extends FileLocationRequest { - command: CommandTypes.TypeDefinition; + interface FunctionLikeDeclaration extends SignatureDeclaration { + _functionLikeDeclarationBrand: any; + asteriskToken?: AsteriskToken; + questionToken?: QuestionToken; + body?: Block | Expression; } - interface ImplementationRequest extends FileLocationRequest { - command: CommandTypes.Implementation; + interface FunctionDeclaration extends FunctionLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.FunctionDeclaration; + name?: Identifier; + body?: FunctionBody; } - interface Location { - line: number; - offset: number; + interface MethodSignature extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.MethodSignature; + name: PropertyName; } - interface TextSpan { - start: Location; - end: Location; + interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.MethodDeclaration; + name: PropertyName; + body?: FunctionBody; } - interface FileSpan extends TextSpan { - file: string; + interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + kind: SyntaxKind.Constructor; + body?: FunctionBody; } - interface DefinitionResponse extends Response { - body?: FileSpan[]; + interface SemicolonClassElement extends ClassElement { + kind: SyntaxKind.SemicolonClassElement; } - interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; + interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.GetAccessor; + name: PropertyName; + body: FunctionBody; } - interface ImplementationResponse extends Response { - body?: FileSpan[]; + interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.SetAccessor; + name: PropertyName; + body: FunctionBody; } - interface BraceCompletionRequest extends FileLocationRequest { - command: CommandTypes.BraceCompletion; - arguments: BraceCompletionRequestArgs; + type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; + interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { + kind: SyntaxKind.IndexSignature; } - interface BraceCompletionRequestArgs extends FileLocationRequestArgs { - openingBrace: string; + interface TypeNode extends Node { + _typeNodeBrand: any; } - interface OccurrencesRequest extends FileLocationRequest { - command: CommandTypes.Occurrences; + interface KeywordTypeNode extends TypeNode { + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; } - interface OccurrencesResponseItem extends FileSpan { - isWriteAccess: boolean; + interface ThisTypeNode extends TypeNode { + kind: SyntaxKind.ThisType; } - interface OccurrencesResponse extends Response { - body?: OccurrencesResponseItem[]; + interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { + kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; } - interface DocumentHighlightsRequest extends FileLocationRequest { - command: CommandTypes.DocumentHighlights; - arguments: DocumentHighlightsRequestArgs; + interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.FunctionType; } - interface HighlightSpan extends TextSpan { - kind: string; + interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.ConstructorType; } - interface DocumentHighlightsItem { - file: string; - highlightSpans: HighlightSpan[]; + interface TypeReferenceNode extends TypeNode { + kind: SyntaxKind.TypeReference; + typeName: EntityName; + typeArguments?: NodeArray; } - interface DocumentHighlightsResponse extends Response { - body?: DocumentHighlightsItem[]; + interface TypePredicateNode extends TypeNode { + kind: SyntaxKind.TypePredicate; + parameterName: Identifier | ThisTypeNode; + type: TypeNode; } - interface ReferencesRequest extends FileLocationRequest { - command: CommandTypes.References; + interface TypeQueryNode extends TypeNode { + kind: SyntaxKind.TypeQuery; + exprName: EntityName; } - interface ReferencesResponseItem extends FileSpan { - lineText: string; - isWriteAccess: boolean; - isDefinition: boolean; + interface TypeLiteralNode extends TypeNode, Declaration { + kind: SyntaxKind.TypeLiteral; + members: NodeArray; } - interface ReferencesResponseBody { - refs: ReferencesResponseItem[]; - symbolName: string; - symbolStartOffset: number; - symbolDisplayString: string; + interface ArrayTypeNode extends TypeNode { + kind: SyntaxKind.ArrayType; + elementType: TypeNode; } - interface ReferencesResponse extends Response { - body?: ReferencesResponseBody; + interface TupleTypeNode extends TypeNode { + kind: SyntaxKind.TupleType; + elementTypes: NodeArray; } - interface RenameRequestArgs extends FileLocationRequestArgs { - findInComments?: boolean; - findInStrings?: boolean; + interface UnionOrIntersectionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; + types: NodeArray; } - interface RenameRequest extends FileLocationRequest { - command: CommandTypes.Rename; - arguments: RenameRequestArgs; + interface UnionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.UnionType; } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage?: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; + interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.IntersectionType; } - interface SpanGroup { - file: string; - locs: TextSpan[]; + interface ParenthesizedTypeNode extends TypeNode { + kind: SyntaxKind.ParenthesizedType; + type: TypeNode; } - interface RenameResponseBody { - info: RenameInfo; - locs: SpanGroup[]; + interface LiteralTypeNode extends TypeNode { + kind: SyntaxKind.LiteralType; + literal: Expression; } - interface RenameResponse extends Response { - body?: RenameResponseBody; + interface StringLiteral extends LiteralExpression { + kind: SyntaxKind.StringLiteral; } - interface ExternalFile { - fileName: string; - scriptKind?: ScriptKind; - hasMixedContent?: boolean; - content?: string; + interface Expression extends Node { + _expressionBrand: any; + contextualType?: Type; } - interface ExternalProject { - projectFileName: string; - rootFiles: ExternalFile[]; - options: ExternalProjectCompilerOptions; - typingOptions?: TypingOptions; + interface OmittedExpression extends Expression { + kind: SyntaxKind.OmittedExpression; } - interface ExternalProjectCompilerOptions extends CompilerOptions { - compileOnSave?: boolean; + interface UnaryExpression extends Expression { + _unaryExpressionBrand: any; } - interface ProjectVersionInfo { - projectName: string; - isInferred: boolean; - version: number; - options: CompilerOptions; + interface IncrementExpression extends UnaryExpression { + _incrementExpressionBrand: any; } - interface ProjectChanges { - added: string[]; - removed: string[]; + type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; + interface PrefixUnaryExpression extends IncrementExpression { + kind: SyntaxKind.PrefixUnaryExpression; + operator: PrefixUnaryOperator; + operand: UnaryExpression; } - interface ProjectFiles { - info?: ProjectVersionInfo; - files?: string[]; - changes?: ProjectChanges; + type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; + interface PostfixUnaryExpression extends IncrementExpression { + kind: SyntaxKind.PostfixUnaryExpression; + operand: LeftHandSideExpression; + operator: PostfixUnaryOperator; } - interface ProjectFilesWithDiagnostics extends ProjectFiles { - projectErrors: DiagnosticWithLinePosition[]; + interface PostfixExpression extends UnaryExpression { + _postfixExpressionBrand: any; } - interface ChangedOpenFile { - fileName: string; - changes: ts.TextChange[]; + interface LeftHandSideExpression extends IncrementExpression { + _leftHandSideExpressionBrand: any; } - interface ConfigureRequestArguments { - hostInfo?: string; - file?: string; - formatOptions?: FormatCodeSettings; + interface MemberExpression extends LeftHandSideExpression { + _memberExpressionBrand: any; } - interface ConfigureRequest extends Request { - command: CommandTypes.Configure; - arguments: ConfigureRequestArguments; + interface PrimaryExpression extends MemberExpression { + _primaryExpressionBrand: any; } - interface ConfigureResponse extends Response { + interface NullLiteral extends PrimaryExpression { + kind: SyntaxKind.NullKeyword; } - interface OpenRequestArgs extends FileRequestArgs { - fileContent?: string; - scriptKindName?: "TS" | "JS" | "TSX" | "JSX"; + interface BooleanLiteral extends PrimaryExpression { + kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface OpenRequest extends Request { - command: CommandTypes.Open; - arguments: OpenRequestArgs; + interface ThisExpression extends PrimaryExpression { + kind: SyntaxKind.ThisKeyword; } - interface OpenExternalProjectRequest extends Request { - command: CommandTypes.OpenExternalProject; - arguments: OpenExternalProjectArgs; + interface SuperExpression extends PrimaryExpression { + kind: SyntaxKind.SuperKeyword; } - type OpenExternalProjectArgs = ExternalProject; - interface OpenExternalProjectsRequest extends Request { - command: CommandTypes.OpenExternalProjects; - arguments: OpenExternalProjectsArgs; + interface DeleteExpression extends UnaryExpression { + kind: SyntaxKind.DeleteExpression; + expression: UnaryExpression; } - interface OpenExternalProjectsArgs { - projects: ExternalProject[]; + interface TypeOfExpression extends UnaryExpression { + kind: SyntaxKind.TypeOfExpression; + expression: UnaryExpression; } - interface OpenExternalProjectResponse extends Response { + interface VoidExpression extends UnaryExpression { + kind: SyntaxKind.VoidExpression; + expression: UnaryExpression; } - interface OpenExternalProjectsResponse extends Response { + interface AwaitExpression extends UnaryExpression { + kind: SyntaxKind.AwaitExpression; + expression: UnaryExpression; } - interface CloseExternalProjectRequest extends Request { - command: CommandTypes.CloseExternalProject; - arguments: CloseExternalProjectRequestArgs; + interface YieldExpression extends Expression { + kind: SyntaxKind.YieldExpression; + asteriskToken?: AsteriskToken; + expression?: Expression; } - interface CloseExternalProjectRequestArgs { - projectFileName: string; + type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + type BinaryOperatorToken = Token; + interface BinaryExpression extends Expression, Declaration { + kind: SyntaxKind.BinaryExpression; + left: Expression; + operatorToken: BinaryOperatorToken; + right: Expression; } - interface CloseExternalProjectResponse extends Response { + interface ConditionalExpression extends Expression { + kind: SyntaxKind.ConditionalExpression; + condition: Expression; + questionToken: QuestionToken; + whenTrue: Expression; + colonToken: ColonToken; + whenFalse: Expression; } - interface SynchronizeProjectListRequest extends Request { - arguments: SynchronizeProjectListRequestArgs; + type FunctionBody = Block; + type ConciseBody = FunctionBody | Expression; + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + kind: SyntaxKind.FunctionExpression; + name?: Identifier; + body: FunctionBody; } - interface SynchronizeProjectListRequestArgs { - knownProjects: protocol.ProjectVersionInfo[]; + interface ArrowFunction extends Expression, FunctionLikeDeclaration { + kind: SyntaxKind.ArrowFunction; + equalsGreaterThanToken: EqualsGreaterThanToken; + body: ConciseBody; } - interface ApplyChangedToOpenFilesRequest extends Request { - arguments: ApplyChangedToOpenFilesRequestArgs; + interface LiteralLikeNode extends Node { + text: string; + isUnterminated?: boolean; + hasExtendedUnicodeEscape?: boolean; } - interface ApplyChangedToOpenFilesRequestArgs { - openFiles?: ExternalFile[]; - changedFiles?: ChangedOpenFile[]; - closedFiles?: string[]; + interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { + _literalExpressionBrand: any; } - interface SetCompilerOptionsForInferredProjectsRequest extends Request { - command: CommandTypes.CompilerOptionsForInferredProjects; - arguments: SetCompilerOptionsForInferredProjectsArgs; + interface RegularExpressionLiteral extends LiteralExpression { + kind: SyntaxKind.RegularExpressionLiteral; } - interface SetCompilerOptionsForInferredProjectsArgs { - options: ExternalProjectCompilerOptions; + interface NoSubstitutionTemplateLiteral extends LiteralExpression { + kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - interface SetCompilerOptionsForInferredProjectsResponse extends Response { + interface NumericLiteral extends LiteralExpression { + kind: SyntaxKind.NumericLiteral; + trailingComment?: string; } - interface ExitRequest extends Request { - command: CommandTypes.Exit; + interface TemplateHead extends LiteralLikeNode { + kind: SyntaxKind.TemplateHead; } - interface CloseRequest extends FileRequest { - command: CommandTypes.Close; + interface TemplateMiddle extends LiteralLikeNode { + kind: SyntaxKind.TemplateMiddle; } - interface CompileOnSaveAffectedFileListRequest extends FileRequest { - command: CommandTypes.CompileOnSaveAffectedFileList; + interface TemplateTail extends LiteralLikeNode { + kind: SyntaxKind.TemplateTail; } - interface CompileOnSaveAffectedFileListSingleProject { - projectFileName: string; - fileNames: string[]; + type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; + interface TemplateExpression extends PrimaryExpression { + kind: SyntaxKind.TemplateExpression; + head: TemplateHead; + templateSpans: NodeArray; } - interface CompileOnSaveAffectedFileListResponse extends Response { - body: CompileOnSaveAffectedFileListSingleProject[]; + interface TemplateSpan extends Node { + kind: SyntaxKind.TemplateSpan; + expression: Expression; + literal: TemplateMiddle | TemplateTail; } - interface CompileOnSaveEmitFileRequest extends FileRequest { - command: CommandTypes.CompileOnSaveEmitFile; - arguments: CompileOnSaveEmitFileRequestArgs; + interface ParenthesizedExpression extends PrimaryExpression { + kind: SyntaxKind.ParenthesizedExpression; + expression: Expression; } - interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { - forced?: boolean; + interface ArrayLiteralExpression extends PrimaryExpression { + kind: SyntaxKind.ArrayLiteralExpression; + elements: NodeArray; } - interface QuickInfoRequest extends FileLocationRequest { - command: CommandTypes.Quickinfo; + interface SpreadElementExpression extends Expression { + kind: SyntaxKind.SpreadElementExpression; + expression: Expression; } - interface QuickInfoResponseBody { - kind: string; - kindModifiers: string; - start: Location; - end: Location; - displayString: string; - documentation: string; + interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { + properties: NodeArray; } - interface QuickInfoResponse extends Response { - body?: QuickInfoResponseBody; + interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + kind: SyntaxKind.ObjectLiteralExpression; } - interface FormatRequestArgs extends FileLocationRequestArgs { - endLine: number; - endOffset: number; - endPosition?: number; - options?: FormatCodeSettings; - } - interface FormatRequest extends FileLocationRequest { - command: CommandTypes.Format; - arguments: FormatRequestArgs; + type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + interface PropertyAccessExpression extends MemberExpression, Declaration { + kind: SyntaxKind.PropertyAccessExpression; + expression: LeftHandSideExpression; + name: Identifier; } - interface CodeEdit { - start: Location; - end: Location; - newText: string; + interface SuperPropertyAccessExpression extends PropertyAccessExpression { + expression: SuperExpression; } - interface FileCodeEdits { - fileName: string; - textChanges: CodeEdit[]; + interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + _propertyAccessExpressionLikeQualifiedNameBrand?: any; + expression: EntityNameExpression; } - interface CodeFixResponse extends Response { - body?: CodeAction[]; + interface ElementAccessExpression extends MemberExpression { + kind: SyntaxKind.ElementAccessExpression; + expression: LeftHandSideExpression; + argumentExpression?: Expression; } - interface CodeAction { - description: string; - changes: FileCodeEdits[]; + interface SuperElementAccessExpression extends ElementAccessExpression { + expression: SuperExpression; } - interface FormatResponse extends Response { - body?: CodeEdit[]; + type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + interface CallExpression extends LeftHandSideExpression, Declaration { + kind: SyntaxKind.CallExpression; + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; } - interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { - key: string; - options?: FormatCodeSettings; + interface SuperCall extends CallExpression { + expression: SuperExpression; } - interface FormatOnKeyRequest extends FileLocationRequest { - command: CommandTypes.Formatonkey; - arguments: FormatOnKeyRequestArgs; + interface ExpressionWithTypeArguments extends TypeNode { + kind: SyntaxKind.ExpressionWithTypeArguments; + expression: LeftHandSideExpression; + typeArguments?: NodeArray; } - interface CompletionsRequestArgs extends FileLocationRequestArgs { - prefix?: string; + interface NewExpression extends PrimaryExpression, Declaration { + kind: SyntaxKind.NewExpression; + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; } - interface CompletionsRequest extends FileLocationRequest { - command: CommandTypes.Completions; - arguments: CompletionsRequestArgs; + interface TaggedTemplateExpression extends MemberExpression { + kind: SyntaxKind.TaggedTemplateExpression; + tag: LeftHandSideExpression; + template: TemplateLiteral; } - interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { - entryNames: string[]; + type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + interface AsExpression extends Expression { + kind: SyntaxKind.AsExpression; + expression: Expression; + type: TypeNode; } - interface CompletionDetailsRequest extends FileLocationRequest { - command: CommandTypes.CompletionDetails; - arguments: CompletionDetailsRequestArgs; + interface TypeAssertion extends UnaryExpression { + kind: SyntaxKind.TypeAssertionExpression; + type: TypeNode; + expression: UnaryExpression; } - interface SymbolDisplayPart { - text: string; - kind: string; + type AssertionExpression = TypeAssertion | AsExpression; + interface NonNullExpression extends LeftHandSideExpression { + kind: SyntaxKind.NonNullExpression; + expression: Expression; } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - replacementSpan?: TextSpan; + interface JsxElement extends PrimaryExpression { + kind: SyntaxKind.JsxElement; + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; + type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; + interface JsxOpeningElement extends Expression { + kind: SyntaxKind.JsxOpeningElement; + tagName: JsxTagNameExpression; + attributes: NodeArray; } - interface CompletionsResponse extends Response { - body?: CompletionEntry[]; + interface JsxSelfClosingElement extends PrimaryExpression { + kind: SyntaxKind.JsxSelfClosingElement; + tagName: JsxTagNameExpression; + attributes: NodeArray; } - interface CompletionDetailsResponse extends Response { - body?: CompletionEntryDetails[]; + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + interface JsxAttribute extends Node { + kind: SyntaxKind.JsxAttribute; + name: Identifier; + initializer?: StringLiteral | JsxExpression; } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; + interface JsxSpreadAttribute extends Node { + kind: SyntaxKind.JsxSpreadAttribute; + expression: Expression; } - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; + interface JsxClosingElement extends Node { + kind: SyntaxKind.JsxClosingElement; + tagName: JsxTagNameExpression; } - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; + interface JsxExpression extends Expression { + kind: SyntaxKind.JsxExpression; + expression?: Expression; } - interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + interface JsxText extends Node { + kind: SyntaxKind.JsxText; } - interface SignatureHelpRequest extends FileLocationRequest { - command: CommandTypes.SignatureHelp; - arguments: SignatureHelpRequestArgs; + type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; + interface Statement extends Node { + _statementBrand: any; } - interface SignatureHelpResponse extends Response { - body?: SignatureHelpItems; + interface EmptyStatement extends Statement { + kind: SyntaxKind.EmptyStatement; } - interface SemanticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SemanticDiagnosticsSync; - arguments: SemanticDiagnosticsSyncRequestArgs; + interface DebuggerStatement extends Statement { + kind: SyntaxKind.DebuggerStatement; } - interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; + interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement { + kind: SyntaxKind.MissingDeclaration; + name?: Identifier; } - interface SemanticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; + type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; + interface Block extends Statement { + kind: SyntaxKind.Block; + statements: NodeArray; } - interface SyntacticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SyntacticDiagnosticsSync; - arguments: SyntacticDiagnosticsSyncRequestArgs; + interface VariableStatement extends Statement { + kind: SyntaxKind.VariableStatement; + declarationList: VariableDeclarationList; } - interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; + interface ExpressionStatement extends Statement { + kind: SyntaxKind.ExpressionStatement; + expression: Expression; } - interface SyntacticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; + interface IfStatement extends Statement { + kind: SyntaxKind.IfStatement; + expression: Expression; + thenStatement: Statement; + elseStatement?: Statement; } - interface GeterrForProjectRequestArgs { - file: string; - delay: number; + interface IterationStatement extends Statement { + statement: Statement; } - interface GeterrForProjectRequest extends Request { - command: CommandTypes.GeterrForProject; - arguments: GeterrForProjectRequestArgs; + interface DoStatement extends IterationStatement { + kind: SyntaxKind.DoStatement; + expression: Expression; } - interface GeterrRequestArgs { - files: string[]; - delay: number; + interface WhileStatement extends IterationStatement { + kind: SyntaxKind.WhileStatement; + expression: Expression; } - interface GeterrRequest extends Request { - command: CommandTypes.Geterr; - arguments: GeterrRequestArgs; + type ForInitializer = VariableDeclarationList | Expression; + interface ForStatement extends IterationStatement { + kind: SyntaxKind.ForStatement; + initializer?: ForInitializer; + condition?: Expression; + incrementor?: Expression; } - interface Diagnostic { - start: Location; - end: Location; - text: string; - code?: number; + interface ForInStatement extends IterationStatement { + kind: SyntaxKind.ForInStatement; + initializer: ForInitializer; + expression: Expression; } - interface DiagnosticEventBody { - file: string; - diagnostics: Diagnostic[]; + interface ForOfStatement extends IterationStatement { + kind: SyntaxKind.ForOfStatement; + initializer: ForInitializer; + expression: Expression; } - interface DiagnosticEvent extends Event { - body?: DiagnosticEventBody; + interface BreakStatement extends Statement { + kind: SyntaxKind.BreakStatement; + label?: Identifier; } - interface ConfigFileDiagnosticEventBody { - triggerFile: string; - configFile: string; - diagnostics: Diagnostic[]; + interface ContinueStatement extends Statement { + kind: SyntaxKind.ContinueStatement; + label?: Identifier; } - interface ConfigFileDiagnosticEvent extends Event { - body?: ConfigFileDiagnosticEventBody; - event: "configFileDiag"; + type BreakOrContinueStatement = BreakStatement | ContinueStatement; + interface ReturnStatement extends Statement { + kind: SyntaxKind.ReturnStatement; + expression?: Expression; } - interface ReloadRequestArgs extends FileRequestArgs { - tmpfile: string; + interface WithStatement extends Statement { + kind: SyntaxKind.WithStatement; + expression: Expression; + statement: Statement; } - interface ReloadRequest extends FileRequest { - command: CommandTypes.Reload; - arguments: ReloadRequestArgs; + interface SwitchStatement extends Statement { + kind: SyntaxKind.SwitchStatement; + expression: Expression; + caseBlock: CaseBlock; + possiblyExhaustive?: boolean; } - interface ReloadResponse extends Response { + interface CaseBlock extends Node { + kind: SyntaxKind.CaseBlock; + clauses: NodeArray; } - interface SavetoRequestArgs extends FileRequestArgs { - tmpfile: string; + interface CaseClause extends Node { + kind: SyntaxKind.CaseClause; + expression: Expression; + statements: NodeArray; } - interface SavetoRequest extends FileRequest { - command: CommandTypes.Saveto; - arguments: SavetoRequestArgs; + interface DefaultClause extends Node { + kind: SyntaxKind.DefaultClause; + statements: NodeArray; } - interface NavtoRequestArgs extends FileRequestArgs { - searchValue: string; - maxResultCount?: number; - currentFileOnly?: boolean; - projectFileName?: string; + type CaseOrDefaultClause = CaseClause | DefaultClause; + interface LabeledStatement extends Statement { + kind: SyntaxKind.LabeledStatement; + label: Identifier; + statement: Statement; } - interface NavtoRequest extends FileRequest { - command: CommandTypes.Navto; - arguments: NavtoRequestArgs; + interface ThrowStatement extends Statement { + kind: SyntaxKind.ThrowStatement; + expression: Expression; } - interface NavtoItem { - name: string; - kind: string; - matchKind?: string; - isCaseSensitive?: boolean; - kindModifiers?: string; - file: string; - start: Location; - end: Location; - containerName?: string; - containerKind?: string; + interface TryStatement extends Statement { + kind: SyntaxKind.TryStatement; + tryBlock: Block; + catchClause?: CatchClause; + finallyBlock?: Block; } - interface NavtoResponse extends Response { - body?: NavtoItem[]; + interface CatchClause extends Node { + kind: SyntaxKind.CatchClause; + variableDeclaration: VariableDeclaration; + block: Block; } - interface ChangeRequestArgs extends FormatRequestArgs { - insertString?: string; + type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration; + interface ClassLikeDeclaration extends Declaration { + name?: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; } - interface ChangeRequest extends FileLocationRequest { - command: CommandTypes.Change; - arguments: ChangeRequestArgs; + interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.ClassDeclaration; + name?: Identifier; } - interface BraceResponse extends Response { - body?: TextSpan[]; + interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + kind: SyntaxKind.ClassExpression; } - interface BraceRequest extends FileLocationRequest { - command: CommandTypes.Brace; + interface ClassElement extends Declaration { + _classElementBrand: any; + name?: PropertyName; } - interface NavBarRequest extends FileRequest { - command: CommandTypes.NavBar; + interface TypeElement extends Declaration { + _typeElementBrand: any; + name?: PropertyName; + questionToken?: QuestionToken; } - interface NavTreeRequest extends FileRequest { - command: CommandTypes.NavTree; + interface InterfaceDeclaration extends DeclarationStatement { + kind: SyntaxKind.InterfaceDeclaration; + name: Identifier; + typeParameters?: NodeArray; + heritageClauses?: NodeArray; + members: NodeArray; } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers?: string; - spans: TextSpan[]; - childItems?: NavigationBarItem[]; - indent: number; + interface HeritageClause extends Node { + kind: SyntaxKind.HeritageClause; + token: SyntaxKind; + types?: NodeArray; } - interface NavigationTree { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems?: NavigationTree[]; + interface TypeAliasDeclaration extends DeclarationStatement { + kind: SyntaxKind.TypeAliasDeclaration; + name: Identifier; + typeParameters?: NodeArray; + type: TypeNode; } - interface NavBarResponse extends Response { - body?: NavigationBarItem[]; + interface EnumMember extends Declaration { + kind: SyntaxKind.EnumMember; + name: PropertyName; + initializer?: Expression; } - interface NavTreeResponse extends Response { - body?: NavigationTree; + interface EnumDeclaration extends DeclarationStatement { + kind: SyntaxKind.EnumDeclaration; + name: Identifier; + members: NodeArray; } -} -declare namespace ts { - interface MapLike { - [index: string]: T; + type ModuleBody = ModuleBlock | ModuleDeclaration; + type ModuleName = Identifier | StringLiteral; + interface ModuleDeclaration extends DeclarationStatement { + kind: SyntaxKind.ModuleDeclaration; + name: Identifier | LiteralExpression; + body?: ModuleBlock | NamespaceDeclaration; } - interface Map extends MapLike { - __mapBrand: any; + interface NamespaceDeclaration extends ModuleDeclaration { + name: Identifier; + body: ModuleBlock | NamespaceDeclaration; } - type Path = string & { - __pathBrand: any; - }; - interface FileMap { - get(fileName: Path): T; - set(fileName: Path, value: T): void; - contains(fileName: Path): boolean; - remove(fileName: Path): void; - forEachValue(f: (key: Path, v: T) => void): void; - getKeys(): Path[]; - clear(): void; + interface ModuleBlock extends Node, Statement { + kind: SyntaxKind.ModuleBlock; + statements: NodeArray; } - interface TextRange { - pos: number; - end: number; + type ModuleReference = EntityName | ExternalModuleReference; + interface ImportEqualsDeclaration extends DeclarationStatement { + kind: SyntaxKind.ImportEqualsDeclaration; + name: Identifier; + moduleReference: ModuleReference; } - const enum SyntaxKind { - Unknown = 0, - EndOfFileToken = 1, - SingleLineCommentTrivia = 2, - MultiLineCommentTrivia = 3, - NewLineTrivia = 4, - WhitespaceTrivia = 5, - ShebangTrivia = 6, - ConflictMarkerTrivia = 7, - NumericLiteral = 8, - StringLiteral = 9, - RegularExpressionLiteral = 10, - NoSubstitutionTemplateLiteral = 11, - TemplateHead = 12, - TemplateMiddle = 13, - TemplateTail = 14, - OpenBraceToken = 15, - CloseBraceToken = 16, - OpenParenToken = 17, - CloseParenToken = 18, - OpenBracketToken = 19, - CloseBracketToken = 20, - DotToken = 21, - DotDotDotToken = 22, - SemicolonToken = 23, - CommaToken = 24, - LessThanToken = 25, - LessThanSlashToken = 26, - GreaterThanToken = 27, - LessThanEqualsToken = 28, - GreaterThanEqualsToken = 29, - EqualsEqualsToken = 30, - ExclamationEqualsToken = 31, - EqualsEqualsEqualsToken = 32, - ExclamationEqualsEqualsToken = 33, - EqualsGreaterThanToken = 34, - PlusToken = 35, - MinusToken = 36, - AsteriskToken = 37, - AsteriskAsteriskToken = 38, - SlashToken = 39, - PercentToken = 40, - PlusPlusToken = 41, - MinusMinusToken = 42, - LessThanLessThanToken = 43, - GreaterThanGreaterThanToken = 44, - GreaterThanGreaterThanGreaterThanToken = 45, - AmpersandToken = 46, - BarToken = 47, - CaretToken = 48, - ExclamationToken = 49, - TildeToken = 50, - AmpersandAmpersandToken = 51, - BarBarToken = 52, - QuestionToken = 53, - ColonToken = 54, - AtToken = 55, - EqualsToken = 56, - PlusEqualsToken = 57, - MinusEqualsToken = 58, - AsteriskEqualsToken = 59, - AsteriskAsteriskEqualsToken = 60, - SlashEqualsToken = 61, - PercentEqualsToken = 62, - LessThanLessThanEqualsToken = 63, - GreaterThanGreaterThanEqualsToken = 64, - GreaterThanGreaterThanGreaterThanEqualsToken = 65, - AmpersandEqualsToken = 66, - BarEqualsToken = 67, - CaretEqualsToken = 68, - Identifier = 69, - BreakKeyword = 70, - CaseKeyword = 71, - CatchKeyword = 72, - ClassKeyword = 73, - ConstKeyword = 74, - ContinueKeyword = 75, - DebuggerKeyword = 76, - DefaultKeyword = 77, - DeleteKeyword = 78, - DoKeyword = 79, - ElseKeyword = 80, - EnumKeyword = 81, - ExportKeyword = 82, - ExtendsKeyword = 83, - FalseKeyword = 84, - FinallyKeyword = 85, - ForKeyword = 86, - FunctionKeyword = 87, - IfKeyword = 88, - ImportKeyword = 89, - InKeyword = 90, - InstanceOfKeyword = 91, - NewKeyword = 92, - NullKeyword = 93, - ReturnKeyword = 94, - SuperKeyword = 95, - SwitchKeyword = 96, - ThisKeyword = 97, - ThrowKeyword = 98, - TrueKeyword = 99, - TryKeyword = 100, - TypeOfKeyword = 101, - VarKeyword = 102, - VoidKeyword = 103, - WhileKeyword = 104, - WithKeyword = 105, - ImplementsKeyword = 106, - InterfaceKeyword = 107, - LetKeyword = 108, - PackageKeyword = 109, - PrivateKeyword = 110, - ProtectedKeyword = 111, - PublicKeyword = 112, - StaticKeyword = 113, - YieldKeyword = 114, - AbstractKeyword = 115, - AsKeyword = 116, - AnyKeyword = 117, - AsyncKeyword = 118, - AwaitKeyword = 119, - BooleanKeyword = 120, - ConstructorKeyword = 121, - DeclareKeyword = 122, - GetKeyword = 123, - IsKeyword = 124, - ModuleKeyword = 125, - NamespaceKeyword = 126, - NeverKeyword = 127, - ReadonlyKeyword = 128, - RequireKeyword = 129, - NumberKeyword = 130, - SetKeyword = 131, - StringKeyword = 132, - SymbolKeyword = 133, - TypeKeyword = 134, - UndefinedKeyword = 135, - FromKeyword = 136, - GlobalKeyword = 137, - OfKeyword = 138, - QualifiedName = 139, - ComputedPropertyName = 140, - TypeParameter = 141, - Parameter = 142, - Decorator = 143, - PropertySignature = 144, - PropertyDeclaration = 145, - MethodSignature = 146, - MethodDeclaration = 147, - Constructor = 148, - GetAccessor = 149, - SetAccessor = 150, - CallSignature = 151, - ConstructSignature = 152, - IndexSignature = 153, - TypePredicate = 154, - TypeReference = 155, - FunctionType = 156, - ConstructorType = 157, - TypeQuery = 158, - TypeLiteral = 159, - ArrayType = 160, - TupleType = 161, - UnionType = 162, - IntersectionType = 163, - ParenthesizedType = 164, - ThisType = 165, - LiteralType = 166, - ObjectBindingPattern = 167, - ArrayBindingPattern = 168, - BindingElement = 169, - ArrayLiteralExpression = 170, - ObjectLiteralExpression = 171, - PropertyAccessExpression = 172, - ElementAccessExpression = 173, - CallExpression = 174, - NewExpression = 175, - TaggedTemplateExpression = 176, - TypeAssertionExpression = 177, - ParenthesizedExpression = 178, - FunctionExpression = 179, - ArrowFunction = 180, - DeleteExpression = 181, - TypeOfExpression = 182, - VoidExpression = 183, - AwaitExpression = 184, - PrefixUnaryExpression = 185, - PostfixUnaryExpression = 186, - BinaryExpression = 187, - ConditionalExpression = 188, - TemplateExpression = 189, - YieldExpression = 190, - SpreadElementExpression = 191, - ClassExpression = 192, - OmittedExpression = 193, - ExpressionWithTypeArguments = 194, - AsExpression = 195, - NonNullExpression = 196, - TemplateSpan = 197, - SemicolonClassElement = 198, - Block = 199, - VariableStatement = 200, - EmptyStatement = 201, - ExpressionStatement = 202, - IfStatement = 203, - DoStatement = 204, - WhileStatement = 205, - ForStatement = 206, - ForInStatement = 207, - ForOfStatement = 208, - ContinueStatement = 209, - BreakStatement = 210, - ReturnStatement = 211, - WithStatement = 212, - SwitchStatement = 213, - LabeledStatement = 214, - ThrowStatement = 215, - TryStatement = 216, - DebuggerStatement = 217, - VariableDeclaration = 218, - VariableDeclarationList = 219, - FunctionDeclaration = 220, - ClassDeclaration = 221, - InterfaceDeclaration = 222, - TypeAliasDeclaration = 223, - EnumDeclaration = 224, - ModuleDeclaration = 225, - ModuleBlock = 226, - CaseBlock = 227, - NamespaceExportDeclaration = 228, - ImportEqualsDeclaration = 229, - ImportDeclaration = 230, - ImportClause = 231, - NamespaceImport = 232, - NamedImports = 233, - ImportSpecifier = 234, - ExportAssignment = 235, - ExportDeclaration = 236, - NamedExports = 237, - ExportSpecifier = 238, - MissingDeclaration = 239, - ExternalModuleReference = 240, - JsxElement = 241, - JsxSelfClosingElement = 242, - JsxOpeningElement = 243, - JsxText = 244, - JsxClosingElement = 245, - JsxAttribute = 246, - JsxSpreadAttribute = 247, - JsxExpression = 248, - CaseClause = 249, - DefaultClause = 250, - HeritageClause = 251, - CatchClause = 252, - PropertyAssignment = 253, - ShorthandPropertyAssignment = 254, - EnumMember = 255, - SourceFile = 256, - JSDocTypeExpression = 257, - JSDocAllType = 258, - JSDocUnknownType = 259, - JSDocArrayType = 260, - JSDocUnionType = 261, - JSDocTupleType = 262, - JSDocNullableType = 263, - JSDocNonNullableType = 264, - JSDocRecordType = 265, - JSDocRecordMember = 266, - JSDocTypeReference = 267, - JSDocOptionalType = 268, - JSDocFunctionType = 269, - JSDocVariadicType = 270, - JSDocConstructorType = 271, - JSDocThisType = 272, - JSDocComment = 273, - JSDocTag = 274, - JSDocParameterTag = 275, - JSDocReturnTag = 276, - JSDocTypeTag = 277, - JSDocTemplateTag = 278, - JSDocTypedefTag = 279, - JSDocPropertyTag = 280, - JSDocTypeLiteral = 281, - JSDocLiteralType = 282, - JSDocNullKeyword = 283, - JSDocUndefinedKeyword = 284, - JSDocNeverKeyword = 285, - SyntaxList = 286, - NotEmittedStatement = 287, - PartiallyEmittedExpression = 288, - Count = 289, - FirstAssignment = 56, - LastAssignment = 68, - FirstCompoundAssignment = 57, - LastCompoundAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 138, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 154, - LastTypeNode = 166, - FirstPunctuation = 15, - LastPunctuation = 68, - FirstToken = 0, - LastToken = 138, - FirstTriviaToken = 2, - LastTriviaToken = 7, - FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 139, - FirstJSDocNode = 257, - LastJSDocNode = 282, - FirstJSDocTagNode = 273, - LastJSDocTagNode = 285, + interface ExternalModuleReference extends Node { + kind: SyntaxKind.ExternalModuleReference; + expression?: Expression; } - const enum NodeFlags { - None = 0, - Let = 1, - Const = 2, - NestedNamespace = 4, - Synthesized = 8, - Namespace = 16, - ExportContext = 32, - ContainsThis = 64, - HasImplicitReturn = 128, - HasExplicitReturn = 256, - GlobalAugmentation = 512, - HasClassExtends = 1024, - HasDecorators = 2048, - HasParamDecorators = 4096, - HasAsyncFunctions = 8192, - HasJsxSpreadAttributes = 16384, - DisallowInContext = 32768, - YieldContext = 65536, - DecoratorContext = 131072, - AwaitContext = 262144, - ThisNodeHasError = 524288, - JavaScriptFile = 1048576, - ThisNodeOrAnySubNodesHasError = 2097152, - HasAggregatedChildData = 4194304, - BlockScoped = 3, - ReachabilityCheckFlags = 384, - EmitHelperFlags = 31744, - ReachabilityAndEmitFlags = 32128, - ContextFlags = 1540096, - TypeExcludesFlags = 327680, + interface ImportDeclaration extends Statement { + kind: SyntaxKind.ImportDeclaration; + importClause?: ImportClause; + moduleSpecifier: Expression; } - const enum ModifierFlags { - None = 0, - Export = 1, - Ambient = 2, - Public = 4, - Private = 8, - Protected = 16, - Static = 32, - Readonly = 64, - Abstract = 128, - Async = 256, - Default = 512, - Const = 2048, - HasComputedFlags = 536870912, - AccessibilityModifier = 28, - ParameterPropertyModifier = 92, - NonPublicAccessibilityModifier = 24, + type NamedImportBindings = NamespaceImport | NamedImports; + interface ImportClause extends Declaration { + kind: SyntaxKind.ImportClause; + name?: Identifier; + namedBindings?: NamedImportBindings; } - const enum JsxFlags { - None = 0, - IntrinsicNamedElement = 1, - IntrinsicIndexedElement = 2, - IntrinsicElement = 3, + interface NamespaceImport extends Declaration { + kind: SyntaxKind.NamespaceImport; + name: Identifier; } - const enum RelationComparisonResult { - Succeeded = 1, - Failed = 2, - FailedAndReported = 3, + interface NamespaceExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.NamespaceExportDeclaration; + name: Identifier; + moduleReference: LiteralLikeNode; } - interface Node extends TextRange { - kind: SyntaxKind; - flags: NodeFlags; - modifierFlagsCache?: ModifierFlags; - transformFlags?: TransformFlags; - decorators?: NodeArray; - modifiers?: ModifiersArray; - id?: number; - parent?: Node; - original?: Node; - startsOnNewLine?: boolean; - jsDocComments?: JSDoc[]; - symbol?: Symbol; - locals?: SymbolTable; - nextContainer?: Node; - localSymbol?: Symbol; - flowNode?: FlowNode; - emitNode?: EmitNode; + interface ExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.ExportDeclaration; + exportClause?: NamedExports; + moduleSpecifier?: Expression; } - interface NodeArray extends Array, TextRange { - hasTrailingComma?: boolean; + interface NamedImports extends Node { + kind: SyntaxKind.NamedImports; + elements: NodeArray; } - interface Token extends Node { - kind: TKind; + interface NamedExports extends Node { + kind: SyntaxKind.NamedExports; + elements: NodeArray; } - type DotDotDotToken = Token; - type QuestionToken = Token; - type ColonToken = Token; - type EqualsToken = Token; - type AsteriskToken = Token; - type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token; - type AtToken = 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, + type NamedImportsOrExports = NamedImports | NamedExports; + interface ImportSpecifier extends Declaration { + kind: SyntaxKind.ImportSpecifier; + propertyName?: Identifier; + name: Identifier; } - interface Identifier extends PrimaryExpression { - kind: SyntaxKind.Identifier; - text: string; - originalKeywordKind?: SyntaxKind; - autoGenerateKind?: GeneratedIdentifierKind; - autoGenerateId?: number; + interface ExportSpecifier extends Declaration { + kind: SyntaxKind.ExportSpecifier; + propertyName?: Identifier; + name: Identifier; } - interface TransientIdentifier extends Identifier { - resolvedSymbol: Symbol; + type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; + interface ExportAssignment extends DeclarationStatement { + kind: SyntaxKind.ExportAssignment; + isExportEquals?: boolean; + expression: Expression; } - interface QualifiedName extends Node { - kind: SyntaxKind.QualifiedName; - left: EntityName; - right: Identifier; + interface FileReference extends TextRange { + fileName: string; } - type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | LiteralExpression | ComputedPropertyName; - type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { - _declarationBrand: any; - name?: DeclarationName; + interface CommentRange extends TextRange { + hasTrailingNewLine?: boolean; + kind: SyntaxKind; } - interface DeclarationStatement extends Declaration, Statement { - name?: Identifier | LiteralExpression; + interface JSDocTypeExpression extends Node { + kind: SyntaxKind.JSDocTypeExpression; + type: JSDocType; } - interface ComputedPropertyName extends Node { - kind: SyntaxKind.ComputedPropertyName; - expression: Expression; + interface JSDocType extends TypeNode { + _jsDocTypeBrand: any; } - interface Decorator extends Node { - kind: SyntaxKind.Decorator; - expression: LeftHandSideExpression; + interface JSDocAllType extends JSDocType { + kind: SyntaxKind.JSDocAllType; } - interface TypeParameterDeclaration extends Declaration { - kind: SyntaxKind.TypeParameter; - name: Identifier; - constraint?: TypeNode; - expression?: Expression; + interface JSDocUnknownType extends JSDocType { + kind: SyntaxKind.JSDocUnknownType; } - interface SignatureDeclaration extends Declaration { - name?: PropertyName; - typeParameters?: NodeArray; - parameters: NodeArray; - type?: TypeNode; + interface JSDocArrayType extends JSDocType { + kind: SyntaxKind.JSDocArrayType; + elementType: JSDocType; } - interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { - kind: SyntaxKind.CallSignature; + interface JSDocUnionType extends JSDocType { + kind: SyntaxKind.JSDocUnionType; + types: NodeArray; } - interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { - kind: SyntaxKind.ConstructSignature; + interface JSDocTupleType extends JSDocType { + kind: SyntaxKind.JSDocTupleType; + types: NodeArray; } - type BindingName = Identifier | BindingPattern; - interface VariableDeclaration extends Declaration { - kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList; - name: BindingName; - type?: TypeNode; - initializer?: Expression; + interface JSDocNonNullableType extends JSDocType { + kind: SyntaxKind.JSDocNonNullableType; + type: JSDocType; } - interface VariableDeclarationList extends Node { - kind: SyntaxKind.VariableDeclarationList; - declarations: NodeArray; + interface JSDocNullableType extends JSDocType { + kind: SyntaxKind.JSDocNullableType; + type: JSDocType; } - interface ParameterDeclaration extends Declaration { - kind: SyntaxKind.Parameter; - dotDotDotToken?: DotDotDotToken; - name: BindingName; - questionToken?: QuestionToken; - type?: TypeNode; - initializer?: Expression; + interface JSDocRecordType extends JSDocType { + kind: SyntaxKind.JSDocRecordType; + literal: TypeLiteralNode; } - interface BindingElement extends Declaration { - kind: SyntaxKind.BindingElement; - propertyName?: PropertyName; - dotDotDotToken?: DotDotDotToken; - name: BindingName; - initializer?: Expression; + interface JSDocTypeReference extends JSDocType { + kind: SyntaxKind.JSDocTypeReference; + name: EntityName; + typeArguments: NodeArray; } - interface PropertySignature extends TypeElement { - kind: SyntaxKind.PropertySignature | SyntaxKind.JSDocRecordMember; - name: PropertyName; - questionToken?: QuestionToken; - type?: TypeNode; - initializer?: Expression; + interface JSDocOptionalType extends JSDocType { + kind: SyntaxKind.JSDocOptionalType; + type: JSDocType; } - interface PropertyDeclaration extends ClassElement { - kind: SyntaxKind.PropertyDeclaration; - questionToken?: QuestionToken; - name: PropertyName; - type?: TypeNode; - initializer?: Expression; + interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + kind: SyntaxKind.JSDocFunctionType; + parameters: NodeArray; + type: JSDocType; } - interface ObjectLiteralElement extends Declaration { - _objectLiteralBrandBrand: any; - name?: PropertyName; + interface JSDocVariadicType extends JSDocType { + kind: SyntaxKind.JSDocVariadicType; + type: JSDocType; } - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement { - kind: SyntaxKind.PropertyAssignment; - name: PropertyName; - questionToken?: QuestionToken; - initializer: Expression; + interface JSDocConstructorType extends JSDocType { + kind: SyntaxKind.JSDocConstructorType; + type: JSDocType; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement { - kind: SyntaxKind.ShorthandPropertyAssignment; - name: Identifier; - questionToken?: QuestionToken; - equalsToken?: Token; - objectAssignmentInitializer?: Expression; + interface JSDocThisType extends JSDocType { + kind: SyntaxKind.JSDocThisType; + type: JSDocType; } - interface VariableLikeDeclaration extends Declaration { - propertyName?: PropertyName; - dotDotDotToken?: DotDotDotToken; - name: DeclarationName; - questionToken?: QuestionToken; - type?: TypeNode; - initializer?: Expression; - } - interface PropertyLikeDeclaration extends Declaration { - name: PropertyName; - } - interface BindingPattern extends Node { - elements: NodeArray; - } - interface ObjectBindingPattern extends BindingPattern { - kind: SyntaxKind.ObjectBindingPattern; - elements: NodeArray; - } - type ArrayBindingElement = BindingElement | OmittedExpression; - interface ArrayBindingPattern extends BindingPattern { - kind: SyntaxKind.ArrayBindingPattern; - elements: NodeArray; + interface JSDocLiteralType extends JSDocType { + kind: SyntaxKind.JSDocLiteralType; + literal: LiteralTypeNode; } - interface FunctionLikeDeclaration extends SignatureDeclaration { - _functionLikeDeclarationBrand: any; - asteriskToken?: AsteriskToken; - questionToken?: QuestionToken; - body?: Block | Expression; + type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + interface JSDocRecordMember extends PropertySignature { + kind: SyntaxKind.JSDocRecordMember; + name: Identifier | LiteralExpression; + type?: JSDocType; } - interface FunctionDeclaration extends FunctionLikeDeclaration, DeclarationStatement { - kind: SyntaxKind.FunctionDeclaration; - name?: Identifier; - body?: FunctionBody; + interface JSDoc extends Node { + kind: SyntaxKind.JSDocComment; + tags: NodeArray | undefined; + comment: string | undefined; } - interface MethodSignature extends SignatureDeclaration, TypeElement { - kind: SyntaxKind.MethodSignature; - name: PropertyName; + interface JSDocTag extends Node { + atToken: AtToken; + tagName: Identifier; + comment: string | undefined; } - interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - kind: SyntaxKind.MethodDeclaration; - name: PropertyName; - body?: FunctionBody; + interface JSDocUnknownTag extends JSDocTag { + kind: SyntaxKind.JSDocTag; } - interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { - kind: SyntaxKind.Constructor; - body?: FunctionBody; + interface JSDocTemplateTag extends JSDocTag { + kind: SyntaxKind.JSDocTemplateTag; + typeParameters: NodeArray; } - interface SemicolonClassElement extends ClassElement { - kind: SyntaxKind.SemicolonClassElement; + interface JSDocReturnTag extends JSDocTag { + kind: SyntaxKind.JSDocReturnTag; + typeExpression: JSDocTypeExpression; } - interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - kind: SyntaxKind.GetAccessor; - name: PropertyName; - body: FunctionBody; + interface JSDocTypeTag extends JSDocTag { + kind: SyntaxKind.JSDocTypeTag; + typeExpression: JSDocTypeExpression; } - interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - kind: SyntaxKind.SetAccessor; - name: PropertyName; - body: FunctionBody; + interface JSDocTypedefTag extends JSDocTag, Declaration { + kind: SyntaxKind.JSDocTypedefTag; + name?: Identifier; + typeExpression?: JSDocTypeExpression; + jsDocTypeLiteral?: JSDocTypeLiteral; } - type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { - kind: SyntaxKind.IndexSignature; + interface JSDocPropertyTag extends JSDocTag, TypeElement { + kind: SyntaxKind.JSDocPropertyTag; + name: Identifier; + typeExpression: JSDocTypeExpression; } - interface TypeNode extends Node { - _typeNodeBrand: any; + interface JSDocTypeLiteral extends JSDocType { + kind: SyntaxKind.JSDocTypeLiteral; + jsDocPropertyTags?: NodeArray; + jsDocTypeTag?: JSDocTypeTag; } - interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + interface JSDocParameterTag extends JSDocTag { + kind: SyntaxKind.JSDocParameterTag; + preParameterName?: Identifier; + typeExpression?: JSDocTypeExpression; + postParameterName?: Identifier; + parameterName: Identifier; + isBracketed: boolean; } - interface ThisTypeNode extends TypeNode { - kind: SyntaxKind.ThisType; + const enum FlowFlags { + Unreachable = 1, + Start = 2, + BranchLabel = 4, + LoopLabel = 8, + Assignment = 16, + TrueCondition = 32, + FalseCondition = 64, + SwitchClause = 128, + ArrayMutation = 256, + Referenced = 512, + Shared = 1024, + Label = 12, + Condition = 96, } - interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; + interface FlowNode { + flags: FlowFlags; + id?: number; } - interface FunctionTypeNode extends FunctionOrConstructorTypeNode { - kind: SyntaxKind.FunctionType; + interface FlowStart extends FlowNode { + container?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { - kind: SyntaxKind.ConstructorType; + interface FlowLabel extends FlowNode { + antecedents: FlowNode[]; } - interface TypeReferenceNode extends TypeNode { - kind: SyntaxKind.TypeReference; - typeName: EntityName; - typeArguments?: NodeArray; + interface FlowAssignment extends FlowNode { + node: Expression | VariableDeclaration | BindingElement; + antecedent: FlowNode; } - interface TypePredicateNode extends TypeNode { - kind: SyntaxKind.TypePredicate; - parameterName: Identifier | ThisTypeNode; - type: TypeNode; + interface FlowCondition extends FlowNode { + expression: Expression; + antecedent: FlowNode; } - interface TypeQueryNode extends TypeNode { - kind: SyntaxKind.TypeQuery; - exprName: EntityName; + interface FlowSwitchClause extends FlowNode { + switchStatement: SwitchStatement; + clauseStart: number; + clauseEnd: number; + antecedent: FlowNode; } - interface TypeLiteralNode extends TypeNode, Declaration { - kind: SyntaxKind.TypeLiteral; - members: NodeArray; + interface FlowArrayMutation extends FlowNode { + node: CallExpression | BinaryExpression; + antecedent: FlowNode; } - interface ArrayTypeNode extends TypeNode { - kind: SyntaxKind.ArrayType; - elementType: TypeNode; + type FlowType = Type | IncompleteType; + interface IncompleteType { + flags: TypeFlags; + type: Type; } - interface TupleTypeNode extends TypeNode { - kind: SyntaxKind.TupleType; - elementTypes: NodeArray; + interface AmdDependency { + path: string; + name: string; } - interface UnionOrIntersectionTypeNode extends TypeNode { - kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; - types: NodeArray; + interface SourceFile extends Declaration { + kind: SyntaxKind.SourceFile; + statements: NodeArray; + endOfFileToken: Token; + fileName: string; + path: Path; + text: string; + amdDependencies: AmdDependency[]; + moduleName: string; + referencedFiles: FileReference[]; + typeReferenceDirectives: FileReference[]; + languageVariant: LanguageVariant; + isDeclarationFile: boolean; + hasNoDefaultLib: boolean; + languageVersion: ScriptTarget; } - interface UnionTypeNode extends UnionOrIntersectionTypeNode { - kind: SyntaxKind.UnionType; + interface ScriptReferenceHost { + getCompilerOptions(): CompilerOptions; + getSourceFile(fileName: string): SourceFile; + getSourceFileByPath(path: Path): SourceFile; + getCurrentDirectory(): string; } - interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { - kind: SyntaxKind.IntersectionType; + interface ParseConfigHost { + useCaseSensitiveFileNames: boolean; + readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[]; + fileExists(path: string): boolean; + readFile(path: string): string; } - interface ParenthesizedTypeNode extends TypeNode { - kind: SyntaxKind.ParenthesizedType; - type: TypeNode; + interface WriteFileCallback { + (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: SourceFile[]): void; } - interface LiteralTypeNode extends TypeNode { - kind: SyntaxKind.LiteralType; - literal: Expression; + class OperationCanceledException { } - interface StringLiteral extends LiteralExpression { - kind: SyntaxKind.StringLiteral; - textSourceNode?: Identifier | StringLiteral; + interface CancellationToken { + isCancellationRequested(): boolean; + throwIfCancellationRequested(): void; } - interface Expression extends Node { - _expressionBrand: any; - contextualType?: Type; + interface Program extends ScriptReferenceHost { + getRootFileNames(): string[]; + getSourceFiles(): SourceFile[]; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getTypeChecker(): TypeChecker; } - interface OmittedExpression extends Expression { - kind: SyntaxKind.OmittedExpression; + interface SourceMapSpan { + emittedLine: number; + emittedColumn: number; + sourceLine: number; + sourceColumn: number; + nameIndex?: number; + sourceIndex: number; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { - kind: SyntaxKind.PartiallyEmittedExpression; - expression: Expression; + interface SourceMapData { + sourceMapFilePath: string; + jsSourceMappingURL: string; + sourceMapFile: string; + sourceMapSourceRoot: string; + sourceMapSources: string[]; + sourceMapSourcesContent?: string[]; + inputSourceFileNames: string[]; + sourceMapNames?: string[]; + sourceMapMappings: string; + sourceMapDecodedMappings: SourceMapSpan[]; } - interface UnaryExpression extends Expression { - _unaryExpressionBrand: any; + enum ExitStatus { + Success = 0, + DiagnosticsPresent_OutputsSkipped = 1, + DiagnosticsPresent_OutputsGenerated = 2, } - interface IncrementExpression extends UnaryExpression { - _incrementExpressionBrand: any; + interface EmitResult { + emitSkipped: boolean; + diagnostics: Diagnostic[]; + emittedFiles: string[]; } - type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; - interface PrefixUnaryExpression extends IncrementExpression { - kind: SyntaxKind.PrefixUnaryExpression; - operator: PrefixUnaryOperator; - operand: UnaryExpression; + interface TypeChecker { + getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; + getDeclaredTypeOfSymbol(symbol: Symbol): Type; + getPropertiesOfType(type: Type): Symbol[]; + getPropertyOfType(type: Type, propertyName: string): Symbol; + getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; + getIndexTypeOfType(type: Type, kind: IndexKind): Type; + getBaseTypes(type: InterfaceType): ObjectType[]; + getReturnTypeOfSignature(signature: Signature): Type; + getNonNullableType(type: Type): Type; + getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; + getSymbolAtLocation(node: Node): Symbol; + getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; + getShorthandAssignmentValueSymbol(location: Node): Symbol; + getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; + getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; + getTypeAtLocation(node: Node): Type; + typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; + symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; + getSymbolDisplayBuilder(): SymbolDisplayBuilder; + getFullyQualifiedName(symbol: Symbol): string; + getAugmentedPropertiesOfType(type: Type): Symbol[]; + getRootSymbols(symbol: Symbol): Symbol[]; + getContextualType(node: Expression): Type; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; + getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + isUndefinedSymbol(symbol: Symbol): boolean; + isArgumentsSymbol(symbol: Symbol): boolean; + isUnknownSymbol(symbol: Symbol): boolean; + getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; + isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + getAliasedSymbol(symbol: Symbol): Symbol; + getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; + isOptionalParameter(node: ParameterDeclaration): boolean; + getAmbientModules(): Symbol[]; } - type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; - interface PostfixUnaryExpression extends IncrementExpression { - kind: SyntaxKind.PostfixUnaryExpression; - operand: LeftHandSideExpression; - operator: PostfixUnaryOperator; + 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; + 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; + buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; + interface SymbolWriter { + writeKeyword(text: string): void; + writeOperator(text: string): void; + writePunctuation(text: string): void; + writeSpace(text: string): void; + writeStringLiteral(text: string): void; + writeParameter(text: string): void; + writeSymbol(text: string, symbol: Symbol): void; + writeLine(): void; + increaseIndent(): void; + decreaseIndent(): void; + clear(): void; + trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; + reportInaccessibleThisError(): void; } - interface LeftHandSideExpression extends IncrementExpression { - _leftHandSideExpressionBrand: any; + const enum TypeFormatFlags { + None = 0, + WriteArrayAsGenericType = 1, + UseTypeOfFunction = 2, + NoTruncation = 4, + WriteArrowStyleSignature = 8, + WriteOwnNameForAnyLike = 16, + WriteTypeArgumentsOfSignature = 32, + InElementType = 64, + UseFullyQualifiedType = 128, + InFirstTypeArgument = 256, + InTypeAlias = 512, + UseTypeAliasValue = 1024, } - interface MemberExpression extends LeftHandSideExpression { - _memberExpressionBrand: any; + const enum SymbolFormatFlags { + None = 0, + WriteTypeParametersOrArguments = 1, + UseOnlyExternalAliasing = 2, } - interface PrimaryExpression extends MemberExpression { - _primaryExpressionBrand: any; + const enum TypePredicateKind { + This = 0, + Identifier = 1, } - interface NullLiteral extends PrimaryExpression { - kind: SyntaxKind.NullKeyword; + interface TypePredicateBase { + kind: TypePredicateKind; + type: Type; } - interface BooleanLiteral extends PrimaryExpression { - kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; + interface ThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.This; } - interface ThisExpression extends PrimaryExpression { - kind: SyntaxKind.ThisKeyword; + interface IdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.Identifier; + parameterName: string; + parameterIndex: number; } - interface SuperExpression extends PrimaryExpression { - kind: SyntaxKind.SuperKeyword; + type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + const enum SymbolFlags { + None = 0, + FunctionScopedVariable = 1, + BlockScopedVariable = 2, + Property = 4, + EnumMember = 8, + Function = 16, + Class = 32, + Interface = 64, + ConstEnum = 128, + RegularEnum = 256, + ValueModule = 512, + NamespaceModule = 1024, + TypeLiteral = 2048, + ObjectLiteral = 4096, + Method = 8192, + Constructor = 16384, + GetAccessor = 32768, + SetAccessor = 65536, + Signature = 131072, + TypeParameter = 262144, + TypeAlias = 524288, + ExportValue = 1048576, + ExportType = 2097152, + ExportNamespace = 4194304, + Alias = 8388608, + Instantiated = 16777216, + Merged = 33554432, + Transient = 67108864, + Prototype = 134217728, + SyntheticProperty = 268435456, + Optional = 536870912, + ExportStar = 1073741824, + Enum = 384, + Variable = 3, + Value = 107455, + Type = 793064, + Namespace = 1920, + Module = 1536, + Accessor = 98304, + FunctionScopedVariableExcludes = 107454, + BlockScopedVariableExcludes = 107455, + ParameterExcludes = 107455, + PropertyExcludes = 0, + EnumMemberExcludes = 900095, + FunctionExcludes = 106927, + ClassExcludes = 899519, + InterfaceExcludes = 792968, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, + ValueModuleExcludes = 106639, + NamespaceModuleExcludes = 0, + MethodExcludes = 99263, + GetAccessorExcludes = 41919, + SetAccessorExcludes = 74687, + TypeParameterExcludes = 530920, + TypeAliasExcludes = 793064, + AliasExcludes = 8388608, + ModuleMember = 8914931, + ExportHasLocal = 944, + HasExports = 1952, + HasMembers = 6240, + BlockScoped = 418, + PropertyOrAccessor = 98308, + Export = 7340032, + ClassMember = 106500, } - interface DeleteExpression extends UnaryExpression { - kind: SyntaxKind.DeleteExpression; - expression: UnaryExpression; + interface Symbol { + flags: SymbolFlags; + name: string; + declarations?: Declaration[]; + valueDeclaration?: Declaration; + members?: SymbolTable; + exports?: SymbolTable; + globalExports?: SymbolTable; } - interface TypeOfExpression extends UnaryExpression { - kind: SyntaxKind.TypeOfExpression; - expression: UnaryExpression; + type SymbolTable = Map; + const enum TypeFlags { + Any = 1, + String = 2, + Number = 4, + Boolean = 8, + Enum = 16, + StringLiteral = 32, + NumberLiteral = 64, + BooleanLiteral = 128, + EnumLiteral = 256, + ESSymbol = 512, + Void = 1024, + Undefined = 2048, + Null = 4096, + Never = 8192, + TypeParameter = 16384, + Class = 32768, + Interface = 65536, + Reference = 131072, + Tuple = 262144, + Union = 524288, + Intersection = 1048576, + Anonymous = 2097152, + Instantiated = 4194304, + Literal = 480, + StringOrNumberLiteral = 96, + PossiblyFalsy = 7406, + StringLike = 34, + NumberLike = 340, + BooleanLike = 136, + EnumLike = 272, + ObjectType = 2588672, + UnionOrIntersection = 1572864, + StructuredType = 4161536, + StructuredOrTypeParameter = 4177920, + Narrowable = 4178943, + NotUnionOrUnit = 2589185, } - interface VoidExpression extends UnaryExpression { - kind: SyntaxKind.VoidExpression; - expression: UnaryExpression; + type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + interface Type { + flags: TypeFlags; + symbol?: Symbol; + pattern?: DestructuringPattern; + aliasSymbol?: Symbol; + aliasTypeArguments?: Type[]; } - interface AwaitExpression extends UnaryExpression { - kind: SyntaxKind.AwaitExpression; - expression: UnaryExpression; + interface LiteralType extends Type { + text: string; + freshType?: LiteralType; + regularType?: LiteralType; } - interface YieldExpression extends Expression { - kind: SyntaxKind.YieldExpression; - asteriskToken?: AsteriskToken; - expression?: Expression; + interface EnumType extends Type { + memberTypes: Map; } - type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; - type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; - type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; - type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; - type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; - type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; - type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; - type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; - type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; - type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; - type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; - type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; - type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; - type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; - type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; - type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; - type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; - type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; - type BinaryOperatorToken = Token; - interface BinaryExpression extends Expression, Declaration { - kind: SyntaxKind.BinaryExpression; - left: Expression; - operatorToken: BinaryOperatorToken; - right: Expression; + interface EnumLiteralType extends LiteralType { + baseType: EnumType & UnionType; } - interface ConditionalExpression extends Expression { - kind: SyntaxKind.ConditionalExpression; - condition: Expression; - questionToken: QuestionToken; - whenTrue: Expression; - colonToken: ColonToken; - whenFalse: Expression; + interface ObjectType extends Type { + isObjectLiteralPatternWithComputedProperties?: boolean; } - type FunctionBody = Block; - type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { - kind: SyntaxKind.FunctionExpression; - name?: Identifier; - body: FunctionBody; + interface InterfaceType extends ObjectType { + typeParameters: TypeParameter[]; + outerTypeParameters: TypeParameter[]; + localTypeParameters: TypeParameter[]; + thisType: TypeParameter; } - interface ArrowFunction extends Expression, FunctionLikeDeclaration { - kind: SyntaxKind.ArrowFunction; - equalsGreaterThanToken: EqualsGreaterThanToken; - body: ConciseBody; + interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + declaredProperties: Symbol[]; + declaredCallSignatures: Signature[]; + declaredConstructSignatures: Signature[]; + declaredStringIndexInfo: IndexInfo; + declaredNumberIndexInfo: IndexInfo; } - interface LiteralLikeNode extends Node { - text: string; - isUnterminated?: boolean; - hasExtendedUnicodeEscape?: boolean; - isOctalLiteral?: boolean; + interface TypeReference extends ObjectType { + target: GenericType; + typeArguments: Type[]; } - interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { - _literalExpressionBrand: any; + interface GenericType extends InterfaceType, TypeReference { } - interface RegularExpressionLiteral extends LiteralExpression { - kind: SyntaxKind.RegularExpressionLiteral; + interface UnionOrIntersectionType extends Type { + types: Type[]; } - interface NoSubstitutionTemplateLiteral extends LiteralExpression { - kind: SyntaxKind.NoSubstitutionTemplateLiteral; + interface UnionType extends UnionOrIntersectionType { } - interface NumericLiteral extends LiteralExpression { - kind: SyntaxKind.NumericLiteral; - trailingComment?: string; + interface IntersectionType extends UnionOrIntersectionType { } - interface TemplateHead extends LiteralLikeNode { - kind: SyntaxKind.TemplateHead; + interface TypeParameter extends Type { + constraint: Type; } - interface TemplateMiddle extends LiteralLikeNode { - kind: SyntaxKind.TemplateMiddle; + const enum SignatureKind { + Call = 0, + Construct = 1, } - interface TemplateTail extends LiteralLikeNode { - kind: SyntaxKind.TemplateTail; + interface Signature { + declaration: SignatureDeclaration; + typeParameters: TypeParameter[]; + parameters: Symbol[]; } - type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; - interface TemplateExpression extends PrimaryExpression { - kind: SyntaxKind.TemplateExpression; - head: TemplateHead; - templateSpans: NodeArray; + const enum IndexKind { + String = 0, + Number = 1, } - interface TemplateSpan extends Node { - kind: SyntaxKind.TemplateSpan; - expression: Expression; - literal: TemplateMiddle | TemplateTail; + interface IndexInfo { + type: Type; + isReadonly: boolean; + declaration?: SignatureDeclaration; } - interface ParenthesizedExpression extends PrimaryExpression { - kind: SyntaxKind.ParenthesizedExpression; - expression: Expression; + interface DiagnosticMessage { + key: string; + category: DiagnosticCategory; + code: number; + message: string; } - interface ArrayLiteralExpression extends PrimaryExpression { - kind: SyntaxKind.ArrayLiteralExpression; - elements: NodeArray; - multiLine?: boolean; + interface DiagnosticMessageChain { + messageText: string; + category: DiagnosticCategory; + code: number; + next?: DiagnosticMessageChain; } - interface SpreadElementExpression extends Expression { - kind: SyntaxKind.SpreadElementExpression; - expression: Expression; + interface Diagnostic { + file: SourceFile; + start: number; + length: number; + messageText: string | DiagnosticMessageChain; + category: DiagnosticCategory; + code: number; } - interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { - properties: NodeArray; + enum DiagnosticCategory { + Warning = 0, + Error = 1, + Message = 2, } - interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { - kind: SyntaxKind.ObjectLiteralExpression; - multiLine?: boolean; + enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; - type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - interface PropertyAccessExpression extends MemberExpression, Declaration { - kind: SyntaxKind.PropertyAccessExpression; - expression: LeftHandSideExpression; - name: Identifier; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + alwaysStrict?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + importHelpers?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind; + moduleResolution?: ModuleResolutionKind; + newLine?: 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; + traceResolution?: boolean; + types?: string[]; + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; } - interface SuperPropertyAccessExpression extends PropertyAccessExpression { - expression: SuperExpression; + interface TypingOptions { + enableAutoDiscovery?: boolean; + include?: string[]; + exclude?: string[]; + [option: string]: string[] | boolean | undefined; } - interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { - _propertyAccessExpressionLikeQualifiedNameBrand?: any; - expression: EntityNameExpression; + interface DiscoverTypingsInfo { + fileNames: string[]; + projectRootPath: string; + safeListPath: string; + packageNameToTypingLocation: Map; + typingOptions: TypingOptions; + compilerOptions: CompilerOptions; } - interface ElementAccessExpression extends MemberExpression { - kind: SyntaxKind.ElementAccessExpression; - expression: LeftHandSideExpression; - argumentExpression?: Expression; + enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + UMD = 3, + System = 4, + ES2015 = 5, } - interface SuperElementAccessExpression extends ElementAccessExpression { - expression: SuperExpression; + const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2, } - type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; - interface CallExpression extends LeftHandSideExpression, Declaration { - kind: SyntaxKind.CallExpression; - expression: LeftHandSideExpression; - typeArguments?: NodeArray; - arguments: NodeArray; - } - interface SuperCall extends CallExpression { - expression: SuperExpression; - } - interface ExpressionWithTypeArguments extends TypeNode { - kind: SyntaxKind.ExpressionWithTypeArguments; - expression: LeftHandSideExpression; - typeArguments?: NodeArray; - } - interface NewExpression extends PrimaryExpression, Declaration { - kind: SyntaxKind.NewExpression; - expression: LeftHandSideExpression; - typeArguments?: NodeArray; - arguments: NodeArray; - } - interface TaggedTemplateExpression extends MemberExpression { - kind: SyntaxKind.TaggedTemplateExpression; - tag: LeftHandSideExpression; - template: TemplateLiteral; - } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; - interface AsExpression extends Expression { - kind: SyntaxKind.AsExpression; - expression: Expression; - type: TypeNode; - } - interface TypeAssertion extends UnaryExpression { - kind: SyntaxKind.TypeAssertionExpression; - type: TypeNode; - expression: UnaryExpression; + const enum NewLineKind { + CarriageReturnLineFeed = 0, + LineFeed = 1, } - type AssertionExpression = TypeAssertion | AsExpression; - interface NonNullExpression extends LeftHandSideExpression { - kind: SyntaxKind.NonNullExpression; - expression: Expression; + interface LineAndCharacter { + line: number; + character: number; } - interface JsxElement extends PrimaryExpression { - kind: SyntaxKind.JsxElement; - openingElement: JsxOpeningElement; - children: NodeArray; - closingElement: JsxClosingElement; + const enum ScriptKind { + Unknown = 0, + JS = 1, + JSX = 2, + TS = 3, + TSX = 4, } - type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; - interface JsxOpeningElement extends Expression { - kind: SyntaxKind.JsxOpeningElement; - tagName: JsxTagNameExpression; - attributes: NodeArray; + const enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES2015 = 2, + ES2016 = 3, + ES2017 = 4, + Latest = 4, } - interface JsxSelfClosingElement extends PrimaryExpression { - kind: SyntaxKind.JsxSelfClosingElement; - tagName: JsxTagNameExpression; - attributes: NodeArray; + const enum LanguageVariant { + Standard = 0, + JSX = 1, } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - interface JsxAttribute extends Node { - kind: SyntaxKind.JsxAttribute; - name: Identifier; - initializer?: StringLiteral | JsxExpression; + interface ParsedCommandLine { + options: CompilerOptions; + typingOptions?: TypingOptions; + fileNames: string[]; + raw?: any; + errors: Diagnostic[]; + wildcardDirectories?: MapLike; + compileOnSave?: boolean; } - interface JsxSpreadAttribute extends Node { - kind: SyntaxKind.JsxSpreadAttribute; - expression: Expression; + const enum WatchDirectoryFlags { + None = 0, + Recursive = 1, } - interface JsxClosingElement extends Node { - kind: SyntaxKind.JsxClosingElement; - tagName: JsxTagNameExpression; + interface ExpandResult { + fileNames: string[]; + wildcardDirectories: MapLike; } - interface JsxExpression extends Expression { - kind: SyntaxKind.JsxExpression; - expression?: Expression; + interface ModuleResolutionHost { + fileExists(fileName: string): boolean; + readFile(fileName: string): string; + trace?(s: string): void; + directoryExists?(directoryName: string): boolean; + realpath?(path: string): string; + getCurrentDirectory?(): string; + getDirectories?(path: string): string[]; } - interface JsxText extends Node { - kind: SyntaxKind.JsxText; + interface ResolvedModule { + resolvedFileName: string; + isExternalLibraryImport?: boolean; } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; - interface Statement extends Node { - _statementBrand: any; + interface ResolvedModuleWithFailedLookupLocations { + resolvedModule: ResolvedModule; + failedLookupLocations: string[]; } - interface NotEmittedStatement extends Statement { - kind: SyntaxKind.NotEmittedStatement; + interface ResolvedTypeReferenceDirective { + primary: boolean; + resolvedFileName?: string; } - interface EmptyStatement extends Statement { - kind: SyntaxKind.EmptyStatement; + interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; + failedLookupLocations: string[]; } - interface DebuggerStatement extends Statement { - kind: SyntaxKind.DebuggerStatement; + interface CompilerHost extends ModuleResolutionHost { + getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getCancellationToken?(): CancellationToken; + getDefaultLibFileName(options: CompilerOptions): string; + getDefaultLibLocation?(): string; + writeFile: WriteFileCallback; + getCurrentDirectory(): string; + getDirectories(path: string): string[]; + getCanonicalFileName(fileName: string): string; + useCaseSensitiveFileNames(): boolean; + getNewLine(): string; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + getEnvironmentVariable?(name: string): string; } - interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement { - kind: SyntaxKind.MissingDeclaration; - name?: Identifier; + interface TextSpan { + start: number; + length: number; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; - interface Block extends Statement { - kind: SyntaxKind.Block; - statements: NodeArray; - multiLine?: boolean; + interface TextChangeRange { + span: TextSpan; + newLength: number; } - interface VariableStatement extends Statement { - kind: SyntaxKind.VariableStatement; - declarationList: VariableDeclarationList; + interface SyntaxList extends Node { + _children: Node[]; } - interface ExpressionStatement extends Statement { - kind: SyntaxKind.ExpressionStatement; - expression: Expression; +} +declare namespace ts { + type FileWatcherCallback = (fileName: string, removed?: boolean) => void; + type DirectoryWatcherCallback = (fileName: string) => void; + interface WatchedFile { + fileName: string; + callback: FileWatcherCallback; + mtime?: Date; } - interface IfStatement extends Statement { - kind: SyntaxKind.IfStatement; - expression: Expression; - thenStatement: Statement; - elseStatement?: Statement; + interface System { + args: string[]; + newLine: string; + useCaseSensitiveFileNames: boolean; + write(s: string): void; + readFile(path: string, encoding?: string): string; + getFileSize?(path: string): number; + writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; + watchFile?(path: string, callback: FileWatcherCallback): FileWatcher; + watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; + resolvePath(path: string): string; + fileExists(path: string): boolean; + directoryExists(path: string): boolean; + createDirectory(path: string): void; + getExecutingFilePath(): string; + getCurrentDirectory(): string; + getDirectories(path: string): string[]; + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + getModifiedTime?(path: string): Date; + createHash?(data: string): string; + getMemoryUsage?(): number; + exit(exitCode?: number): void; + realpath?(path: string): string; } - interface IterationStatement extends Statement { - statement: Statement; + interface FileWatcher { + close(): void; } - interface DoStatement extends IterationStatement { - kind: SyntaxKind.DoStatement; - expression: Expression; + interface DirectoryWatcher extends FileWatcher { + directoryName: string; + referenceCount: number; } - interface WhileStatement extends IterationStatement { - kind: SyntaxKind.WhileStatement; - expression: Expression; + let sys: System; +} +declare namespace ts { + function getEffectiveTypeRoots(options: CompilerOptions, host: { + directoryExists?: (directoryName: string) => boolean; + getCurrentDirectory?: () => string; + }): string[] | undefined; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, 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; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; +} +declare namespace ts { + function getDefaultLibFileName(options: CompilerOptions): string; + function textSpanEnd(span: TextSpan): number; + function textSpanIsEmpty(span: TextSpan): boolean; + function textSpanContainsPosition(span: TextSpan, position: number): boolean; + function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; + function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; + function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; + function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; + function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; + function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; + function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; + function createTextSpan(start: number, length: number): TextSpan; + function createTextSpanFromBounds(start: number, end: number): TextSpan; + function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; + function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; + function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; + let unchangedTextChangeRange: TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + function getTypeParameterOwner(d: Declaration): Declaration; + function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean; + function getCombinedModifierFlags(node: Node): ModifierFlags; + function getCombinedNodeFlags(node: Node): NodeFlags; +} +declare namespace ts { + interface ErrorCallback { + (message: DiagnosticMessage, length: number): void; } - type ForInitializer = VariableDeclarationList | Expression; - interface ForStatement extends IterationStatement { - kind: SyntaxKind.ForStatement; - initializer?: ForInitializer; - condition?: Expression; - incrementor?: Expression; - } - interface ForInStatement extends IterationStatement { - kind: SyntaxKind.ForInStatement; - initializer: ForInitializer; - expression: Expression; - } - interface ForOfStatement extends IterationStatement { - kind: SyntaxKind.ForOfStatement; - initializer: ForInitializer; - expression: Expression; - } - interface BreakStatement extends Statement { - kind: SyntaxKind.BreakStatement; - label?: Identifier; - } - interface ContinueStatement extends Statement { - kind: SyntaxKind.ContinueStatement; - label?: Identifier; - } - type BreakOrContinueStatement = BreakStatement | ContinueStatement; - interface ReturnStatement extends Statement { - kind: SyntaxKind.ReturnStatement; - expression?: Expression; - } - interface WithStatement extends Statement { - kind: SyntaxKind.WithStatement; - expression: Expression; - statement: Statement; - } - interface SwitchStatement extends Statement { - kind: SyntaxKind.SwitchStatement; - expression: Expression; - caseBlock: CaseBlock; - possiblyExhaustive?: boolean; - } - interface CaseBlock extends Node { - kind: SyntaxKind.CaseBlock; - clauses: NodeArray; + interface Scanner { + getStartPos(): number; + getToken(): SyntaxKind; + getTextPos(): number; + getTokenPos(): number; + getTokenText(): string; + getTokenValue(): string; + hasExtendedUnicodeEscape(): boolean; + hasPrecedingLineBreak(): boolean; + isIdentifier(): boolean; + isReservedWord(): boolean; + isUnterminated(): boolean; + reScanGreaterToken(): SyntaxKind; + reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + scanJsxAttributeValue(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; + scanJSDocToken(): SyntaxKind; + scan(): SyntaxKind; + getText(): string; + setText(text: string, start?: number, length?: number): void; + setOnError(onError: ErrorCallback): void; + setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; + setTextPos(textPos: number): void; + lookAhead(callback: () => T): T; + scanRange(start: number, length: number, callback: () => T): T; + tryScan(callback: () => T): T; } - interface CaseClause extends Node { - kind: SyntaxKind.CaseClause; - expression: Expression; - statements: NodeArray; + function tokenToString(t: SyntaxKind): string; + function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; + function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; + function isWhiteSpace(ch: number): boolean; + function isWhiteSpaceSingleLine(ch: number): boolean; + function isLineBreak(ch: number): boolean; + function couldStartTrivia(text: string, pos: number): boolean; + 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; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; + function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; + function getShebang(text: string): string; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; +} +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; + function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + function isExternalModule(file: SourceFile): boolean; + function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; +} +declare namespace ts { + const version = "2.1.0"; + function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + interface FormatDiagnosticsHost { + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; } - interface DefaultClause extends Node { - kind: SyntaxKind.DefaultClause; - statements: NodeArray; + 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; +} +declare namespace ts { + function readConfigFile(fileName: string, readFile: (path: string) => string): { + config?: any; + error?: Diagnostic; + }; + function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments?: boolean): { + config?: any; + error?: Diagnostic; + }; + function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[]): ParsedCommandLine; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; + function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + options: CompilerOptions; + errors: Diagnostic[]; + }; + function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + options: TypingOptions; + errors: Diagnostic[]; + }; +} +declare namespace ts { + interface Node { + getSourceFile(): SourceFile; + getChildCount(sourceFile?: SourceFile): number; + getChildAt(index: number, sourceFile?: SourceFile): Node; + getChildren(sourceFile?: SourceFile): Node[]; + getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; + getFullStart(): number; + getEnd(): number; + getWidth(sourceFile?: SourceFile): number; + getFullWidth(): number; + getLeadingTriviaWidth(sourceFile?: SourceFile): number; + getFullText(sourceFile?: SourceFile): string; + getText(sourceFile?: SourceFile): string; + getFirstToken(sourceFile?: SourceFile): Node; + getLastToken(sourceFile?: SourceFile): Node; } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement { - kind: SyntaxKind.LabeledStatement; - label: Identifier; - statement: Statement; + interface Symbol { + getFlags(): SymbolFlags; + getName(): string; + getDeclarations(): Declaration[]; + getDocumentationComment(): SymbolDisplayPart[]; } - interface ThrowStatement extends Statement { - kind: SyntaxKind.ThrowStatement; - expression: Expression; + interface Type { + getFlags(): TypeFlags; + getSymbol(): Symbol; + getProperties(): Symbol[]; + getProperty(propertyName: string): Symbol; + getApparentProperties(): Symbol[]; + getCallSignatures(): Signature[]; + getConstructSignatures(): Signature[]; + getStringIndexType(): Type; + getNumberIndexType(): Type; + getBaseTypes(): ObjectType[]; + getNonNullableType(): Type; } - interface TryStatement extends Statement { - kind: SyntaxKind.TryStatement; - tryBlock: Block; - catchClause?: CatchClause; - finallyBlock?: Block; + interface Signature { + getDeclaration(): SignatureDeclaration; + getTypeParameters(): Type[]; + getParameters(): Symbol[]; + getReturnType(): Type; + getDocumentationComment(): SymbolDisplayPart[]; } - interface CatchClause extends Node { - kind: SyntaxKind.CatchClause; - variableDeclaration: VariableDeclaration; - block: Block; + interface SourceFile { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + getLineStarts(): number[]; + getPositionOfLineAndCharacter(line: number, character: number): number; + update(newText: string, textChangeRange: TextChangeRange): SourceFile; } - type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration; - interface ClassLikeDeclaration extends Declaration { - name?: Identifier; - typeParameters?: NodeArray; - heritageClauses?: NodeArray; - members: NodeArray; + interface IScriptSnapshot { + getText(start: number, end: number): string; + getLength(): number; + getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined; + dispose?(): void; } - interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { - kind: SyntaxKind.ClassDeclaration; - name?: Identifier; + namespace ScriptSnapshot { + function fromString(text: string): IScriptSnapshot; } - interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { - kind: SyntaxKind.ClassExpression; + interface PreProcessedFileInfo { + referencedFiles: FileReference[]; + typeReferenceDirectives: FileReference[]; + importedFiles: FileReference[]; + ambientExternalModules: string[]; + isLibFile: boolean; } - interface ClassElement extends Declaration { - _classElementBrand: any; - name?: PropertyName; + interface HostCancellationToken { + isCancellationRequested(): boolean; } - interface TypeElement extends Declaration { - _typeElementBrand: any; - name?: PropertyName; - questionToken?: QuestionToken; + interface LanguageServiceHost { + getCompilationSettings(): CompilerOptions; + getNewLine?(): string; + getProjectVersion?(): string; + getScriptFileNames(): string[]; + getScriptKind?(fileName: string): ScriptKind; + getScriptVersion(fileName: string): string; + getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; + getLocalizedDiagnosticMessages?(): any; + getCancellationToken?(): HostCancellationToken; + getCurrentDirectory(): string; + getDefaultLibFileName(options: CompilerOptions): string; + log?(s: string): void; + trace?(s: string): void; + error?(s: string): void; + useCaseSensitiveFileNames?(): boolean; + readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + readFile?(path: string, encoding?: string): string; + fileExists?(path: string): boolean; + getTypeRootsVersion?(): number; + resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + directoryExists?(directoryName: string): boolean; + getDirectories?(directoryName: string): string[]; } - interface InterfaceDeclaration extends DeclarationStatement { - kind: SyntaxKind.InterfaceDeclaration; - name: Identifier; - typeParameters?: NodeArray; - heritageClauses?: NodeArray; - members: NodeArray; - } - interface HeritageClause extends Node { - kind: SyntaxKind.HeritageClause; - token: SyntaxKind; - types?: NodeArray; - } - interface TypeAliasDeclaration extends DeclarationStatement { - kind: SyntaxKind.TypeAliasDeclaration; - name: Identifier; - typeParameters?: NodeArray; - type: TypeNode; - } - interface EnumMember extends Declaration { - kind: SyntaxKind.EnumMember; - name: PropertyName; - initializer?: Expression; - } - interface EnumDeclaration extends DeclarationStatement { - kind: SyntaxKind.EnumDeclaration; - name: Identifier; - members: NodeArray; - } - type ModuleBody = ModuleBlock | ModuleDeclaration; - type ModuleName = Identifier | StringLiteral; - interface ModuleDeclaration extends DeclarationStatement { - kind: SyntaxKind.ModuleDeclaration; - name: Identifier | LiteralExpression; - body?: ModuleBlock | NamespaceDeclaration; - } - interface NamespaceDeclaration extends ModuleDeclaration { - name: Identifier; - body: ModuleBlock | NamespaceDeclaration; - } - interface ModuleBlock extends Node, Statement { - kind: SyntaxKind.ModuleBlock; - statements: NodeArray; + interface LanguageService { + cleanupSemanticCache(): void; + getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSemanticDiagnostics(fileName: string): Diagnostic[]; + getCompilerOptionsDiagnostics(): Diagnostic[]; + getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; + getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; + getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; + getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; + getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getRenameInfo(fileName: string, position: number): RenameInfo; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + findReferences(fileName: string, position: number): ReferencedSymbol[]; + getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; + getNavigationBarItems(fileName: string): NavigationBarItem[]; + getNavigationTree(fileName: string): NavigationTree; + getOutliningSpans(fileName: string): OutliningSpan[]; + getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; + getProgram(): Program; + dispose(): void; } - type ModuleReference = EntityName | ExternalModuleReference; - interface ImportEqualsDeclaration extends DeclarationStatement { - kind: SyntaxKind.ImportEqualsDeclaration; - name: Identifier; - moduleReference: ModuleReference; + interface Classifications { + spans: number[]; + endOfLineState: EndOfLineState; } - interface ExternalModuleReference extends Node { - kind: SyntaxKind.ExternalModuleReference; - expression?: Expression; + interface ClassifiedSpan { + textSpan: TextSpan; + classificationType: string; } - interface ImportDeclaration extends Statement { - kind: SyntaxKind.ImportDeclaration; - importClause?: ImportClause; - moduleSpecifier: Expression; + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems: NavigationBarItem[]; + indent: number; + bolded: boolean; + grayed: boolean; } - type NamedImportBindings = NamespaceImport | NamedImports; - interface ImportClause extends Declaration { - kind: SyntaxKind.ImportClause; - name?: Identifier; - namedBindings?: NamedImportBindings; + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; } - interface NamespaceImport extends Declaration { - kind: SyntaxKind.NamespaceImport; - name: Identifier; + interface TodoCommentDescriptor { + text: string; + priority: number; } - interface NamespaceExportDeclaration extends DeclarationStatement { - kind: SyntaxKind.NamespaceExportDeclaration; - name: Identifier; - moduleReference: LiteralLikeNode; + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; } - interface ExportDeclaration extends DeclarationStatement { - kind: SyntaxKind.ExportDeclaration; - exportClause?: NamedExports; - moduleSpecifier?: Expression; + class TextChange { + span: TextSpan; + newText: string; } - interface NamedImports extends Node { - kind: SyntaxKind.NamedImports; - elements: NodeArray; + interface FileTextChanges { + fileName: string; + textChanges: TextChange[]; } - interface NamedExports extends Node { - kind: SyntaxKind.NamedExports; - elements: NodeArray; + interface CodeAction { + description: string; + changes: FileTextChanges[]; } - type NamedImportsOrExports = NamedImports | NamedExports; - interface ImportSpecifier extends Declaration { - kind: SyntaxKind.ImportSpecifier; - propertyName?: Identifier; - name: Identifier; + interface TextInsertion { + newText: string; + caretOffset: number; } - interface ExportSpecifier extends Declaration { - kind: SyntaxKind.ExportSpecifier; - propertyName?: Identifier; - name: Identifier; + interface RenameLocation { + textSpan: TextSpan; + fileName: string; } - type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; - interface ExportAssignment extends DeclarationStatement { - kind: SyntaxKind.ExportAssignment; - isExportEquals?: boolean; - expression: Expression; + interface ReferenceEntry { + textSpan: TextSpan; + fileName: string; + isWriteAccess: boolean; + isDefinition: boolean; } - interface FileReference extends TextRange { + interface ImplementationLocation { + textSpan: TextSpan; fileName: string; } - interface CommentRange extends TextRange { - hasTrailingNewLine?: boolean; - kind: SyntaxKind; + interface DocumentHighlights { + fileName: string; + highlightSpans: HighlightSpan[]; } - interface JSDocTypeExpression extends Node { - kind: SyntaxKind.JSDocTypeExpression; - type: JSDocType; + namespace HighlightSpanKind { + const none = "none"; + const definition = "definition"; + const reference = "reference"; + const writtenReference = "writtenReference"; } - interface JSDocType extends TypeNode { - _jsDocTypeBrand: any; + interface HighlightSpan { + fileName?: string; + textSpan: TextSpan; + kind: string; } - interface JSDocAllType extends JSDocType { - kind: SyntaxKind.JSDocAllType; + interface NavigateToItem { + name: string; + kind: string; + kindModifiers: string; + matchKind: string; + isCaseSensitive: boolean; + fileName: string; + textSpan: TextSpan; + containerName: string; + containerKind: string; } - interface JSDocUnknownType extends JSDocType { - kind: SyntaxKind.JSDocUnknownType; + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, } - interface JSDocArrayType extends JSDocType { - kind: SyntaxKind.JSDocArrayType; - elementType: JSDocType; + interface EditorOptions { + BaseIndentSize?: number; + IndentSize: number; + TabSize: number; + NewLineCharacter: string; + ConvertTabsToSpaces: boolean; + IndentStyle: IndentStyle; } - interface JSDocUnionType extends JSDocType { - kind: SyntaxKind.JSDocUnionType; - types: NodeArray; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle; } - interface JSDocTupleType extends JSDocType { - kind: SyntaxKind.JSDocTupleType; - types: NodeArray; + interface FormatCodeOptions extends EditorOptions { + InsertSpaceAfterCommaDelimiter: boolean; + InsertSpaceAfterSemicolonInForStatements: boolean; + InsertSpaceBeforeAndAfterBinaryOperators: boolean; + InsertSpaceAfterKeywordsInControlFlowStatements: boolean; + InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; + InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; + InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + InsertSpaceAfterTypeAssertion?: boolean; + PlaceOpenBraceOnNewLineForFunctions: boolean; + PlaceOpenBraceOnNewLineForControlBlocks: boolean; } - interface JSDocNonNullableType extends JSDocType { - kind: SyntaxKind.JSDocNonNullableType; - type: JSDocType; - } - interface JSDocNullableType extends JSDocType { - kind: SyntaxKind.JSDocNullableType; - type: JSDocType; - } - interface JSDocRecordType extends JSDocType { - kind: SyntaxKind.JSDocRecordType; - literal: TypeLiteralNode; - } - interface JSDocTypeReference extends JSDocType { - kind: SyntaxKind.JSDocTypeReference; - name: EntityName; - typeArguments: NodeArray; - } - interface JSDocOptionalType extends JSDocType { - kind: SyntaxKind.JSDocOptionalType; - type: JSDocType; - } - interface JSDocFunctionType extends JSDocType, SignatureDeclaration { - kind: SyntaxKind.JSDocFunctionType; - parameters: NodeArray; - type: JSDocType; + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceAfterTypeAssertion?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; } - interface JSDocVariadicType extends JSDocType { - kind: SyntaxKind.JSDocVariadicType; - type: JSDocType; + interface DefinitionInfo { + fileName: string; + textSpan: TextSpan; + kind: string; + name: string; + containerKind: string; + containerName: string; } - interface JSDocConstructorType extends JSDocType { - kind: SyntaxKind.JSDocConstructorType; - type: JSDocType; + interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { + displayParts: SymbolDisplayPart[]; } - interface JSDocThisType extends JSDocType { - kind: SyntaxKind.JSDocThisType; - type: JSDocType; + interface ReferencedSymbol { + definition: ReferencedSymbolDefinitionInfo; + references: ReferenceEntry[]; } - interface JSDocLiteralType extends JSDocType { - kind: SyntaxKind.JSDocLiteralType; - literal: LiteralTypeNode; + enum SymbolDisplayPartKind { + aliasName = 0, + className = 1, + enumName = 2, + fieldName = 3, + interfaceName = 4, + keyword = 5, + lineBreak = 6, + numericLiteral = 7, + stringLiteral = 8, + localName = 9, + methodName = 10, + moduleName = 11, + operator = 12, + parameterName = 13, + propertyName = 14, + punctuation = 15, + space = 16, + text = 17, + typeParameterName = 18, + enumMemberName = 19, + functionName = 20, + regularExpressionLiteral = 21, } - type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; - interface JSDocRecordMember extends PropertySignature { - kind: SyntaxKind.JSDocRecordMember; - name: Identifier | LiteralExpression; - type?: JSDocType; + interface SymbolDisplayPart { + text: string; + kind: string; } - interface JSDoc extends Node { - kind: SyntaxKind.JSDocComment; - tags: NodeArray | undefined; - comment: string | undefined; + interface QuickInfo { + kind: string; + kindModifiers: string; + textSpan: TextSpan; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; } - interface JSDocTag extends Node { - atToken: AtToken; - tagName: Identifier; - comment: string | undefined; + interface RenameInfo { + canRename: boolean; + localizedErrorMessage: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + triggerSpan: TextSpan; } - interface JSDocUnknownTag extends JSDocTag { - kind: SyntaxKind.JSDocTag; + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; } - interface JSDocTemplateTag extends JSDocTag { - kind: SyntaxKind.JSDocTemplateTag; - typeParameters: NodeArray; + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; } - interface JSDocReturnTag extends JSDocTag { - kind: SyntaxKind.JSDocReturnTag; - typeExpression: JSDocTypeExpression; + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; } - interface JSDocTypeTag extends JSDocTag { - kind: SyntaxKind.JSDocTypeTag; - typeExpression: JSDocTypeExpression; + interface CompletionInfo { + isGlobalCompletion: boolean; + isMemberCompletion: boolean; + isNewIdentifierLocation: boolean; + entries: CompletionEntry[]; } - interface JSDocTypedefTag extends JSDocTag, Declaration { - kind: SyntaxKind.JSDocTypedefTag; - name?: Identifier; - typeExpression?: JSDocTypeExpression; - jsDocTypeLiteral?: JSDocTypeLiteral; + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; } - interface JSDocPropertyTag extends JSDocTag, TypeElement { - kind: SyntaxKind.JSDocPropertyTag; - name: Identifier; - typeExpression: JSDocTypeExpression; + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; } - interface JSDocTypeLiteral extends JSDocType { - kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: NodeArray; - jsDocTypeTag?: JSDocTypeTag; + interface OutliningSpan { + textSpan: TextSpan; + hintSpan: TextSpan; + bannerText: string; + autoCollapse: boolean; } - interface JSDocParameterTag extends JSDocTag { - kind: SyntaxKind.JSDocParameterTag; - preParameterName?: Identifier; - typeExpression?: JSDocTypeExpression; - postParameterName?: Identifier; - parameterName: Identifier; - isBracketed: boolean; + interface EmitOutput { + outputFiles: OutputFile[]; + emitSkipped: boolean; } - const enum FlowFlags { - Unreachable = 1, - Start = 2, - BranchLabel = 4, - LoopLabel = 8, - Assignment = 16, - TrueCondition = 32, - FalseCondition = 64, - SwitchClause = 128, - Referenced = 256, - Shared = 512, - Label = 12, - Condition = 96, + const enum OutputFileType { + JavaScript = 0, + SourceMap = 1, + Declaration = 2, } - interface FlowNode { - flags: FlowFlags; - id?: number; + interface OutputFile { + name: string; + writeByteOrderMark: boolean; + text: string; } - interface FlowStart extends FlowNode { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + const enum EndOfLineState { + None = 0, + InMultiLineCommentTrivia = 1, + InSingleQuoteStringLiteral = 2, + InDoubleQuoteStringLiteral = 3, + InTemplateHeadOrNoSubstitutionTemplate = 4, + InTemplateMiddleOrTail = 5, + InTemplateSubstitutionPosition = 6, } - interface FlowLabel extends FlowNode { - antecedents: FlowNode[]; + enum TokenClass { + Punctuation = 0, + Keyword = 1, + Operator = 2, + Comment = 3, + Whitespace = 4, + Identifier = 5, + NumberLiteral = 6, + StringLiteral = 7, + RegExpLiteral = 8, } - interface FlowAssignment extends FlowNode { - node: Expression | VariableDeclaration | BindingElement; - antecedent: FlowNode; + interface ClassificationResult { + finalLexState: EndOfLineState; + entries: ClassificationInfo[]; } - interface FlowCondition extends FlowNode { - expression: Expression; - antecedent: FlowNode; + interface ClassificationInfo { + length: number; + classification: TokenClass; } - interface FlowSwitchClause extends FlowNode { - switchStatement: SwitchStatement; - clauseStart: number; - clauseEnd: number; - antecedent: FlowNode; + interface Classifier { + getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; + getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - type FlowType = Type | IncompleteType; - interface IncompleteType { - flags: TypeFlags; - type: Type; - } - interface AmdDependency { - path: string; - name: string; - } - interface SourceFile extends Declaration { - kind: SyntaxKind.SourceFile; - statements: NodeArray; - endOfFileToken: Token; - fileName: string; - path: Path; - text: string; - amdDependencies: AmdDependency[]; - moduleName: string; - referencedFiles: FileReference[]; - 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[]; - bindDiagnostics: Diagnostic[]; - lineMap: number[]; - classifiableNames?: Map; - resolvedModules: Map; - resolvedTypeReferenceDirectiveNames: Map; - imports: LiteralExpression[]; - moduleAugmentations: LiteralExpression[]; - patternAmbientModules?: PatternAmbientModule[]; - externalHelpersModuleName?: Identifier; + namespace ScriptElementKind { + const unknown = ""; + const warning = "warning"; + const keyword = "keyword"; + const scriptElement = "script"; + const moduleElement = "module"; + const classElement = "class"; + const localClassElement = "local class"; + const interfaceElement = "interface"; + const typeElement = "type"; + const enumElement = "enum"; + const enumMemberElement = "const"; + const variableElement = "var"; + const localVariableElement = "local var"; + const functionElement = "function"; + const localFunctionElement = "local function"; + const memberFunctionElement = "method"; + const memberGetAccessorElement = "getter"; + const memberSetAccessorElement = "setter"; + const memberVariableElement = "property"; + const constructorImplementationElement = "constructor"; + const callSignatureElement = "call"; + const indexSignatureElement = "index"; + const constructSignatureElement = "construct"; + const parameterElement = "parameter"; + const typeParameterElement = "type parameter"; + const primitiveType = "primitive type"; + const label = "label"; + const alias = "alias"; + const constElement = "const"; + const letElement = "let"; + const directory = "directory"; + const externalModuleName = "external module name"; } - interface ScriptReferenceHost { - getCompilerOptions(): CompilerOptions; - getSourceFile(fileName: string): SourceFile; - getSourceFileByPath(path: Path): SourceFile; - getCurrentDirectory(): string; + namespace ScriptElementKindModifier { + const none = ""; + const publicMemberModifier = "public"; + const privateMemberModifier = "private"; + const protectedMemberModifier = "protected"; + const exportedModifier = "export"; + const ambientModifier = "declare"; + const staticModifier = "static"; + const abstractModifier = "abstract"; } - interface ParseConfigHost { - useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[]; - fileExists(path: string): boolean; - readFile(path: string): string; + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + static jsxOpenTagName: string; + static jsxCloseTagName: string; + static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } - interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: SourceFile[]): void; + const enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17, + docCommentTagName = 18, + jsxOpenTagName = 19, + jsxCloseTagName = 20, + jsxSelfClosingTagName = 21, + jsxAttribute = 22, + jsxText = 23, + jsxAttributeStringLiteralValue = 24, } - class OperationCanceledException { +} +declare namespace ts { + function createClassifier(): Classifier; +} +declare namespace ts { + interface DocumentRegistry { + acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; + releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + reportStats(): string; } - interface CancellationToken { - isCancellationRequested(): boolean; - throwIfCancellationRequested(): void; + type DocumentRegistryBucketKey = string & { + __bucketKey: any; + }; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; +} +declare namespace ts { + function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; +} +declare namespace ts { + interface TranspileOptions { + compilerOptions?: CompilerOptions; + fileName?: string; + reportDiagnostics?: boolean; + moduleName?: string; + renamedDependencies?: MapLike; } - interface Program extends ScriptReferenceHost { - getRootFileNames(): string[]; - getSourceFiles(): SourceFile[]; - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - 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; - structureIsReused?: boolean; + interface TranspileOutput { + outputText: string; + diagnostics?: Diagnostic[]; + sourceMapText?: string; } - interface SourceMapSpan { - emittedLine: number; - emittedColumn: number; - sourceLine: number; - sourceColumn: number; - nameIndex?: number; - sourceIndex: number; + function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; + function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; +} +declare namespace ts { + const servicesVersion = "0.5"; + interface DisplayPartsSymbolWriter extends SymbolWriter { + displayParts(): SymbolDisplayPart[]; } - interface SourceMapData { - sourceMapFilePath: string; - jsSourceMappingURL: string; - sourceMapFile: string; - sourceMapSourceRoot: string; - sourceMapSources: string[]; - sourceMapSourcesContent?: string[]; - inputSourceFileNames: string[]; - sourceMapNames?: string[]; - sourceMapMappings: string; - sourceMapDecodedMappings: SourceMapSpan[]; + function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; + function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function getDefaultCompilerOptions(): CompilerOptions; + function getSupportedCodeFixes(): string[]; + function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; + let disableIncrementalParsing: boolean; + function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; + function getDefaultLibFilePath(options: CompilerOptions): string; +} +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, } - enum ExitStatus { - Success = 0, - DiagnosticsPresent_OutputsSkipped = 1, - DiagnosticsPresent_OutputsGenerated = 2, + 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; } - interface EmitResult { - emitSkipped: boolean; - diagnostics: Diagnostic[]; - emittedFiles: string[]; - sourceMaps: SourceMapData[]; + 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; } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - getResolvedTypeReferenceDirectives(): Map; + function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; } - interface TypeChecker { - getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; - getDeclaredTypeOfSymbol(symbol: Symbol): Type; - getPropertiesOfType(type: Type): Symbol[]; - getPropertyOfType(type: Type, propertyName: string): Symbol; - getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; - getIndexTypeOfType(type: Type, kind: IndexKind): Type; - getBaseTypes(type: InterfaceType): ObjectType[]; - getReturnTypeOfSignature(signature: Signature): Type; - getNonNullableType(type: Type): Type; - getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; - getSymbolAtLocation(node: Node): Symbol; - getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; - getShorthandAssignmentValueSymbol(location: Node): Symbol; - getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; - getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; - getTypeAtLocation(node: Node): Type; - typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; - symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string; - getSymbolDisplayBuilder(): SymbolDisplayBuilder; - getFullyQualifiedName(symbol: Symbol): string; - getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): Symbol[]; - getContextualType(node: Expression): Type; - getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; - getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; - isUndefinedSymbol(symbol: Symbol): boolean; - isArgumentsSymbol(symbol: Symbol): boolean; - isUnknownSymbol(symbol: Symbol): boolean; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; - getAliasedSymbol(symbol: Symbol): Symbol; - getExportsOfModule(moduleSymbol: Symbol): Symbol[]; - getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; - getJsxIntrinsicTagNames(): Symbol[]; - isOptionalParameter(node: ParameterDeclaration): boolean; - getAmbientModules(): Symbol[]; - getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; + 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; } - 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; - 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; - buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildDisplayForParametersAndDelimiters(thisParameter: Symbol, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; - buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; + function createNormalizedPathMap(): NormalizedPathMap; + const nullLanguageService: LanguageService; + interface ServerLanguageServiceHost { + setCompilationSettings(options: CompilerOptions): void; + notifyFileRemoved(info: ScriptInfo): void; } - interface SymbolWriter { - writeKeyword(text: string): void; - writeOperator(text: string): void; - writePunctuation(text: string): void; - writeSpace(text: string): void; - writeStringLiteral(text: string): void; - writeParameter(text: string): void; - writeSymbol(text: string, symbol: Symbol): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - clear(): void; - trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; - reportInaccessibleThisError(): void; + const nullLanguageServiceHost: ServerLanguageServiceHost; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typingOptions?: TypingOptions; + compileOnSave?: boolean; } - const enum TypeFormatFlags { - None = 0, - WriteArrayAsGenericType = 1, - UseTypeOfFunction = 2, - NoTruncation = 4, - WriteArrowStyleSignature = 8, - WriteOwnNameForAnyLike = 16, - WriteTypeArgumentsOfSignature = 32, - InElementType = 64, - UseFullyQualifiedType = 128, - InFirstTypeArgument = 256, - InTypeAlias = 512, - UseTypeAliasValue = 1024, + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + class ThrottledOperations { + private readonly host; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); } - const enum SymbolFormatFlags { - None = 0, - WriteTypeParametersOrArguments = 1, - UseOnlyExternalAliasing = 2, + 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); } - const enum SymbolAccessibility { - Accessible = 0, - NotAccessible = 1, - CannotBeNamed = 2, +} +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"; } - const enum TypePredicateKind { - This = 0, - Identifier = 1, + interface Message { + seq: number; + type: "request" | "response" | "event"; } - interface TypePredicateBase { - kind: TypePredicateKind; - type: Type; + interface Request extends Message { + command: string; + arguments?: any; } - interface ThisTypePredicate extends TypePredicateBase { - kind: TypePredicateKind.This; + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; } - interface IdentifierTypePredicate extends TypePredicateBase { - kind: TypePredicateKind.Identifier; - parameterName: string; - parameterIndex: number; + interface Event extends Message { + event: string; + body?: any; } - type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; - interface SymbolVisibilityResult { - accessibility: SymbolAccessibility; - aliasesToMakeVisible?: AnyImportSyntax[]; - errorSymbolName?: string; - errorNode?: Node; + interface Response extends Message { + request_seq: number; + success: boolean; + command: string; + message?: string; + body?: any; } - interface SymbolAccessibilityResult extends SymbolVisibilityResult { - errorModuleName?: string; + interface FileRequestArgs { + file: string; + projectFileName?: 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; + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; } - const enum SymbolFlags { - None = 0, - FunctionScopedVariable = 1, - BlockScopedVariable = 2, - Property = 4, - EnumMember = 8, - Function = 16, - Class = 32, - Interface = 64, - ConstEnum = 128, - RegularEnum = 256, - ValueModule = 512, - NamespaceModule = 1024, - TypeLiteral = 2048, - ObjectLiteral = 4096, - Method = 8192, - Constructor = 16384, - GetAccessor = 32768, - SetAccessor = 65536, - Signature = 131072, - TypeParameter = 262144, - TypeAlias = 524288, - ExportValue = 1048576, - ExportType = 2097152, - ExportNamespace = 4194304, - Alias = 8388608, - Instantiated = 16777216, - Merged = 33554432, - Transient = 67108864, - Prototype = 134217728, - SyntheticProperty = 268435456, - Optional = 536870912, - ExportStar = 1073741824, - Enum = 384, - Variable = 3, - Value = 107455, - Type = 793064, - Namespace = 1920, - Module = 1536, - Accessor = 98304, - FunctionScopedVariableExcludes = 107454, - BlockScopedVariableExcludes = 107455, - ParameterExcludes = 107455, - PropertyExcludes = 0, - EnumMemberExcludes = 900095, - FunctionExcludes = 106927, - ClassExcludes = 899519, - InterfaceExcludes = 792968, - RegularEnumExcludes = 899327, - ConstEnumExcludes = 899967, - ValueModuleExcludes = 106639, - NamespaceModuleExcludes = 0, - MethodExcludes = 99263, - GetAccessorExcludes = 41919, - SetAccessorExcludes = 74687, - TypeParameterExcludes = 530920, - TypeAliasExcludes = 793064, - AliasExcludes = 8388608, - ModuleMember = 8914931, - ExportHasLocal = 944, - HasExports = 1952, - HasMembers = 6240, - BlockScoped = 418, - PropertyOrAccessor = 98308, - Export = 7340032, - ClassMember = 106500, - Classifiable = 788448, - } - interface Symbol { - flags: SymbolFlags; - name: string; - declarations?: Declaration[]; - valueDeclaration?: Declaration; - 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; - 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, - 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; - enumMemberValue?: number; - isVisible?: boolean; - hasReportedStatementInAmbientContext?: boolean; - jsxFlags?: JsxFlags; - resolvedJsxType?: Type; - hasSuperCall?: boolean; - superCall?: ExpressionStatement; - switchTypes?: Type[]; - } - const enum TypeFlags { - Any = 1, - String = 2, - Number = 4, - Boolean = 8, - Enum = 16, - StringLiteral = 32, - NumberLiteral = 64, - BooleanLiteral = 128, - EnumLiteral = 256, - ESSymbol = 512, - Void = 1024, - Undefined = 2048, - Null = 4096, - Never = 8192, - TypeParameter = 16384, - Class = 32768, - Interface = 65536, - Reference = 131072, - Tuple = 262144, - Union = 524288, - Intersection = 1048576, - Anonymous = 2097152, - Instantiated = 4194304, - ObjectLiteral = 8388608, - FreshLiteral = 16777216, - ContainsWideningType = 33554432, - ContainsObjectLiteral = 67108864, - ContainsAnyFunctionType = 134217728, - Nullable = 6144, - Literal = 480, - StringOrNumberLiteral = 96, - DefinitelyFalsy = 7392, - PossiblyFalsy = 7406, - Intrinsic = 16015, - Primitive = 8190, - StringLike = 34, - NumberLike = 340, - BooleanLike = 136, - EnumLike = 272, - ObjectType = 2588672, - UnionOrIntersection = 1572864, - StructuredType = 4161536, - StructuredOrTypeParameter = 4177920, - Narrowable = 4178943, - NotUnionOrUnit = 2589185, - RequiresWidening = 100663296, - PropagatingFlags = 234881024, - } - 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; - regularType?: LiteralType; - } - interface EnumType extends Type { - memberTypes: Map; - } - interface EnumLiteralType extends LiteralType { - baseType: EnumType & UnionType; - } - interface ObjectType extends Type { - isObjectLiteralPatternWithComputedProperties?: boolean; - } - interface InterfaceType extends ObjectType { - typeParameters: TypeParameter[]; - outerTypeParameters: TypeParameter[]; - localTypeParameters: TypeParameter[]; - thisType: TypeParameter; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; - } - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { - declaredProperties: Symbol[]; - declaredCallSignatures: Signature[]; - declaredConstructSignatures: Signature[]; - declaredStringIndexInfo: IndexInfo; - declaredNumberIndexInfo: IndexInfo; - } - interface TypeReference extends ObjectType { - target: GenericType; - typeArguments: Type[]; - } - interface GenericType extends InterfaceType, TypeReference { - instantiations: Map; - } - interface UnionOrIntersectionType extends Type { - types: Type[]; - resolvedProperties: SymbolTable; - couldContainTypeParameters: boolean; - } - interface UnionType extends UnionOrIntersectionType { - } - interface IntersectionType extends UnionOrIntersectionType { - } - interface AnonymousType extends ObjectType { - target?: AnonymousType; - mapper?: TypeMapper; - } - 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 TypeParameter extends Type { - constraint: Type; - target?: TypeParameter; - mapper?: TypeMapper; - resolvedApparentType: Type; - isThisType?: boolean; - } - const enum SignatureKind { - Call = 0, - Construct = 1, + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; } - interface Signature { - 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; + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; } - const enum IndexKind { - String = 0, - Number = 1, + interface TodoCommentRequestArgs extends FileRequestArgs { + descriptors: TodoCommentDescriptor[]; } - interface IndexInfo { - type: Type; - isReadonly: boolean; - declaration?: SignatureDeclaration; + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; } - interface TypeMapper { - (t: TypeParameter): Type; - mappedTypes?: Type[]; - targetTypes?: 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 IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; } - interface DiagnosticMessage { - key: string; - category: DiagnosticCategory; - code: number; - message: string; + interface IndentationResponse extends Response { + body?: IndentationResult; } - interface DiagnosticMessageChain { - messageText: string; - category: DiagnosticCategory; - code: number; - next?: DiagnosticMessageChain; + interface IndentationResult { + position: number; + indentation: number; } - interface Diagnostic { - file: SourceFile; - start: number; - length: number; - messageText: string | DiagnosticMessageChain; - category: DiagnosticCategory; - code: number; + interface IndentationRequestArgs extends FileLocationRequestArgs { + options?: EditorSettings; } - enum DiagnosticCategory { - Warning = 0, - Error = 1, - Message = 2, + interface ProjectInfoRequestArgs extends FileRequestArgs { + needFileNameList: boolean; } - enum ModuleResolutionKind { - Classic = 1, - NodeJs = 2, + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; } - 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; - module?: ModuleKind; - moduleResolution?: ModuleResolutionKind; - newLine?: 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; - pretty?: DiagnosticStyle; - reactNamespace?: string; - removeComments?: boolean; - rootDir?: string; - rootDirs?: string[]; - skipLibCheck?: boolean; - skipDefaultLibCheck?: boolean; - 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 CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; } - interface TypingOptions { - enableAutoDiscovery?: boolean; - include?: string[]; - exclude?: string[]; - [option: string]: string[] | boolean | undefined; + interface CompilerOptionsDiagnosticsRequestArgs { + projectFileName: string; } - interface DiscoverTypingsInfo { - fileNames: string[]; - projectRootPath: string; - safeListPath: string; - packageNameToTypingLocation: Map; - typingOptions: TypingOptions; - compilerOptions: CompilerOptions; - } - enum ModuleKind { - None = 0, - CommonJS = 1, - AMD = 2, - UMD = 3, - System = 4, - ES6 = 5, - ES2015 = 5, - } - const enum JsxEmit { - None = 0, - Preserve = 1, - React = 2, - } - const enum NewLineKind { - CarriageReturnLineFeed = 0, - LineFeed = 1, - } - interface LineAndCharacter { - line: number; - character: number; - } - const enum ScriptKind { - Unknown = 0, - JS = 1, - JSX = 2, - TS = 3, - TSX = 4, - } - const enum ScriptTarget { - ES3 = 0, - ES5 = 1, - ES6 = 2, - ES2015 = 2, - Latest = 2, - } - const enum LanguageVariant { - Standard = 0, - JSX = 1, - } - const enum DiagnosticStyle { - Simple = 0, - Pretty = 1, - } - interface ParsedCommandLine { - options: CompilerOptions; - typingOptions?: TypingOptions; - fileNames: string[]; - raw?: any; - errors: Diagnostic[]; - wildcardDirectories?: MapLike; - compileOnSave?: boolean; - } - const enum WatchDirectoryFlags { - None = 0, - Recursive = 1, - } - interface ExpandResult { - 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; - trace?(s: string): void; - directoryExists?(directoryName: string): boolean; - realpath?(path: string): string; - getCurrentDirectory?(): string; - getDirectories?(path: string): string[]; - } - interface ResolvedModule { - resolvedFileName: string; - isExternalLibraryImport?: boolean; - } - interface ResolvedModuleWithFailedLookupLocations { - resolvedModule: ResolvedModule; - failedLookupLocations: string[]; - } - interface ResolvedTypeReferenceDirective { - primary: boolean; - resolvedFileName?: string; - } - interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { - resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; - failedLookupLocations: string[]; - } - interface CompilerHost extends ModuleResolutionHost { - getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getCancellationToken?(): CancellationToken; - getDefaultLibFileName(options: CompilerOptions): string; - getDefaultLibLocation?(): string; - writeFile: WriteFileCallback; - getCurrentDirectory(): string; - getDirectories(path: string): string[]; - getCanonicalFileName(fileName: string): string; - useCaseSensitiveFileNames(): boolean; - getNewLine(): string; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - getEnvironmentVariable?(name: string): string; - } - const enum TransformFlags { - None = 0, - TypeScript = 1, - ContainsTypeScript = 2, - Jsx = 4, - ContainsJsx = 8, - ES7 = 16, - ContainsES7 = 32, - ES6 = 64, - ContainsES6 = 128, - DestructuringAssignment = 256, - Generator = 512, - ContainsGenerator = 1024, - ContainsDecorators = 2048, - ContainsPropertyInitializer = 4096, - ContainsLexicalThis = 8192, - ContainsCapturedLexicalThis = 16384, - ContainsLexicalThisInComputedPropertyName = 32768, - ContainsDefaultValueAssignments = 65536, - ContainsParameterPropertyAssignments = 131072, - ContainsSpreadElementExpression = 262144, - ContainsComputedPropertyName = 524288, - ContainsBlockScopedBinding = 1048576, - ContainsBindingPattern = 2097152, - ContainsYield = 4194304, - ContainsHoistedDeclarationOrCompletion = 8388608, - HasComputedFlags = 536870912, - AssertTypeScript = 3, - AssertJsx = 12, - AssertES7 = 48, - AssertES6 = 192, - AssertGenerator = 1536, - NodeExcludes = 536871765, - ArrowFunctionExcludes = 550710101, - FunctionExcludes = 550726485, - ConstructorExcludes = 550593365, - MethodOrAccessorExcludes = 550593365, - ClassExcludes = 537590613, - ModuleExcludes = 546335573, - TypeExcludes = -3, - ObjectLiteralExcludes = 537430869, - ArrayLiteralOrCallOrNewExcludes = 537133909, - VariableDeclarationListExcludes = 538968917, - ParameterExcludes = 538968917, - TypeScriptClassSyntaxMask = 137216, - ES6FunctionSyntaxMask = 81920, - } - interface EmitNode { - flags?: EmitFlags; - commentRange?: TextRange; - sourceMapRange?: TextRange; - tokenSourceMapRanges?: Map; - annotatedNodes?: Node[]; - constantValue?: number; - } - const enum EmitFlags { - EmitEmitHelpers = 1, - EmitExportStar = 2, - EmitSuperHelper = 4, - EmitAdvancedSuperHelper = 8, - UMDDefine = 16, - SingleLine = 32, - AdviseOnEmitNode = 64, - NoSubstitution = 128, - CapturesThis = 256, - NoLeadingSourceMap = 512, - NoTrailingSourceMap = 1024, - NoSourceMap = 1536, - NoNestedSourceMaps = 2048, - NoTokenLeadingSourceMaps = 4096, - NoTokenTrailingSourceMaps = 8192, - NoTokenSourceMaps = 12288, - NoLeadingComments = 16384, - NoTrailingComments = 32768, - NoComments = 49152, - NoNestedComments = 65536, - ExportName = 131072, - LocalName = 262144, - Indented = 524288, - NoIndentation = 1048576, - AsyncFunctionBody = 2097152, - ReuseTempVariableScope = 4194304, - CustomPrologue = 8388608, - } - const enum EmitContext { - SourceFile = 0, - Expression = 1, - IdentifierName = 2, - Unspecified = 3, - } - interface LexicalEnvironment { - startLexicalEnvironment(): void; - endLexicalEnvironment(): Statement[]; - } - interface TextSpan { - start: number; - length: number; - } - interface TextChangeRange { - 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 enum Ternary { - False = 0, - Maybe = 1, - True = -1, - } - 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 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 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 concatenate(array1: T[], array2: T[]): T[]; - function deduplicate(array: T[], areEqual?: (a: T, b: T) => boolean): T[]; - function compact(array: T[]): T[]; - function sum(array: any[], prop: string): number; - function addRange(to: T[], from: T[]): void; - function rangeEquals(array1: T[], array2: T[], pos: number, end: number): boolean; - function firstOrUndefined(array: T[]): T; - function singleOrUndefined(array: T[]): T; - function singleOrMany(array: T[]): T | T[]; - function lastOrUndefined(array: T[]): T; - function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => 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 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 reduceOwnProperties(map: MapLike, 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, value: V): V[]; - function multiMapRemove(map: Map, key: string, value: V): void; - function isArray(value: any): value is any[]; - 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; - let localizedDiagnosticMessages: Map; - function getLocaleSpecificMessage(message: DiagnosticMessage): string; - function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; - function formatMessage(dummy: any, message: DiagnosticMessage): string; - function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): 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 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 fileExtensionIs(path: string, extension: string): boolean; - function fileExtensionIsAny(path: string, extensions: string[]): boolean; - function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string; - interface FileSystemEntries { - files: string[]; - directories: string[]; - } - interface FileMatcherPatterns { - includeFilePattern: string; - includeDirectoryPattern: string; - excludePattern: string; - basePaths: string[]; - } - function getFileMatcherPatterns(path: string, extensions: 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): string[]; - function hasJavaScriptFileExtension(fileName: string): boolean; - function hasTypeScriptFileExtension(fileName: string): boolean; - function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions): 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 isJsxOrTsxExtension(ext: string): boolean; - 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 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; -} -declare namespace ts { - type FileWatcherCallback = (fileName: string, removed?: boolean) => void; - type DirectoryWatcherCallback = (fileName: string) => void; - interface WatchedFile { - fileName: string; - callback: FileWatcherCallback; - mtime?: Date; - } - interface System { - args: string[]; - newLine: string; - useCaseSensitiveFileNames: boolean; - write(s: string): void; - readFile(path: string, encoding?: string): string; - getFileSize?(path: string): number; - writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: FileWatcherCallback): FileWatcher; - watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; - resolvePath(path: string): string; - fileExists(path: string): boolean; - directoryExists(path: string): boolean; - createDirectory(path: string): void; - getExecutingFilePath(): string; - getCurrentDirectory(): string; - getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - getModifiedTime?(path: string): Date; - createHash?(data: string): string; - getMemoryUsage?(): number; - exit(exitCode?: number): void; - realpath?(path: string): string; - getEnvironmentVariable(name: string): string; - tryEnableSourceMapsForHost?(): void; - } - interface FileWatcher { - close(): void; - } - interface DirectoryWatcher extends FileWatcher { - directoryName: string; - referenceCount: number; - } - 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: { - 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: { - 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_name_must_be_an_identifier: { - 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; - }; - 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; - }; - 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; - }; - 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_property_or_indexer: { - 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; - }; - Invalid_left_hand_side_of_assignment_expression: { - 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; - }; - Invalid_left_hand_side_in_for_in_statement: { - 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; - }; - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { - 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_an_array_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_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_left_hand_side_in_for_of_statement: { - 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; - }; - 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; - }; - 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; - }; - 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; - }; - 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; - }; - 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; - }; - 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; - }; - 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_or_ES2015: { - 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; - }; - 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: { - 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: { - 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_types_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_but_allowJs_is_set_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; - }; - 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; - }; - Index_signature_of_object_type_implicitly_has_an_any_type: { - 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_any_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; - }; - 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_typing_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circularity_detected_while_resolving_configuration_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_path_in_an_extends_options_must_be_relative_or_rooted: { - 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_on_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_inherited_abstract_class: { - 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; - getTextPos(): number; - getTokenPos(): number; - getTokenText(): string; - getTokenValue(): string; - hasExtendedUnicodeEscape(): boolean; - hasPrecedingLineBreak(): boolean; - isIdentifier(): boolean; - isReservedWord(): boolean; - isUnterminated(): boolean; - reScanGreaterToken(): SyntaxKind; - reScanSlashToken(): SyntaxKind; - reScanTemplateToken(): SyntaxKind; - scanJsxIdentifier(): SyntaxKind; - scanJsxAttributeValue(): SyntaxKind; - reScanJsxToken(): SyntaxKind; - scanJsxToken(): SyntaxKind; - scanJSDocToken(): SyntaxKind; - scan(): SyntaxKind; - getText(): string; - setText(text: string, start?: number, length?: number): void; - setOnError(onError: ErrorCallback): void; - setScriptTarget(scriptTarget: ScriptTarget): void; - setLanguageVariant(variant: LanguageVariant): void; - setTextPos(textPos: number): void; - lookAhead(callback: () => T): T; - scanRange(start: number, length: number, callback: () => T): T; - tryScan(callback: () => T): T; + interface ProjectInfo { + configFileName: string; + fileNames?: string[]; + languageServiceDisabled?: boolean; } - 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): { + 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; - 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; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function getLeadingCommentRanges(text: string, pos: number): CommentRange[]; - function getTrailingCommentRanges(text: string, pos: number): CommentRange[]; - 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 typingOptionDeclarations: CommandLineOption[]; - interface OptionNameMap { - optionNameMap: Map; - shortOptionNames: Map; - } - const defaultInitCompilerOptions: CompilerOptions; - 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; - error?: Diagnostic; - }; - function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments?: boolean): { - 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[]): ParsedCommandLine; - function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { - options: CompilerOptions; - errors: Diagnostic[]; - }; - function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { - options: TypingOptions; - 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[]; - } - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} -declare namespace ts.server { - enum LogLevel { - terse = 0, - normal = 1, - requestTime = 2, - verbose = 3, + offset: number; } - 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; + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; } - 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; + interface CodeFixRequestArgs extends FileRequestArgs { + startLine: number; + startOffset: number; + endLine: number; + endOffset: number; + errorCodes?: number[]; } - function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, cachePath?: string): DiscoverTypings; - namespace Errors { - function ThrowNoProject(): never; - function ThrowProjectLanguageServiceDisabled(): never; - function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; } - 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; + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; } - function createNormalizedPathMap(): NormalizedPathMap; - const nullLanguageService: LanguageService; - interface ServerLanguageServiceHost { - setCompilationSettings(options: CompilerOptions): void; - notifyFileRemoved(info: ScriptInfo): void; + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; } - const nullLanguageServiceHost: ServerLanguageServiceHost; - interface ProjectOptions { - configHasFilesProperty?: boolean; - files?: string[]; - wildcardDirectories?: Map; - compilerOptions?: CompilerOptions; - typingOptions?: TypingOptions; - compileOnSave?: boolean; + interface GetSupportedCodeFixesResponse extends Response { + body?: string[]; } - function isInferredProjectName(name: string): boolean; - function makeInferredProjectName(counter: number): string; - class ThrottledOperations { - private readonly host; - private pendingTimeouts; - constructor(host: ServerHost); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run(self, operationId, cb); + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + start: number; + length: number; } - 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); + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + filesToSearch: string[]; } -} -declare namespace ts { - function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; - function createResolvedModule(resolvedFileName: string, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations; - interface ModuleResolutionState { - host: ModuleResolutionHost; - compilerOptions: CompilerOptions; - traceEnabled: boolean; - skipTsx: boolean; + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; } - function getEffectiveTypeRoots(options: CompilerOptions, host: { - directoryExists?: (directoryName: string) => boolean; - getCurrentDirectory?: () => string; - }): string[] | undefined; - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, 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; - function directoryProbablyExists(directoryName: string, host: { - directoryExists?: (directoryName: string) => boolean; - }): boolean; - function loadModuleFromNodeModules(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState, checkOneLevel: boolean): string; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): 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; - } - 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 TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; } - function getSingleLineStringWriter(): StringSymbolWriter; - function releaseStringWriter(writer: StringSymbolWriter): void; - function getFullWidth(node: Node): number; - function arrayIsEqualTo(array1: ReadonlyArray, array2: ReadonlyArray, equaler?: (a: T, b: T) => boolean): boolean; - function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; - function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule; - function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void; - function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void; - function moduleResolutionIsEqualTo(oldResolution: ResolvedModule, newResolution: ResolvedModule): 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, includeJsDocComment?: 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 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 isBlockScope(node: Node, parentNode: Node): boolean; - function getEnclosingBlockScopeContainer(node: Node): Node; - function isCatchClauseVariableDeclaration(declaration: Declaration): boolean; - function declarationNameToString(name: DeclarationName): string; - function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): 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): boolean; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; - function getLeadingCommentRangesOfNodeFromText(node: Node, text: string): CommentRange[]; - function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; - function getJsDocCommentsFromText(node: Node, text: string): CommentRange[]; - let fullTripleSlashReferencePathRegEx: RegExp; - let fullTripleSlashReferenceTypeReferenceDirectiveRegEx: RegExp; - let fullTripleSlashAMDReferencePathRegEx: RegExp; - function isPartOfTypeNode(node: Node): boolean; - function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; - function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; - 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 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 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 getJSDocComments(node: Node, checkParentVariableStatement: boolean): string[]; - function getJSDocTypeTag(node: Node): JSDocTypeTag; - function getJSDocReturnTag(node: Node): JSDocReturnTag; - function getJSDocTemplateTag(node: Node): JSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag; - function hasRestParameter(s: SignatureDeclaration): boolean; - function hasDeclaredRestParameter(s: SignatureDeclaration): boolean; - function isRestParameter(node: ParameterDeclaration): boolean; - function isDeclaredRestParam(node: ParameterDeclaration): boolean; - function isAssignmentTarget(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, 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(kind: SyntaxKind): boolean; - function hasDynamicName(declaration: Declaration): boolean; - function isDynamicName(name: DeclarationName): boolean; - function isWellKnownSymbolSyntactically(node: Expression): boolean; - function getPropertyNameForPropertyNameNode(name: DeclarationName): string; - function getPropertyNameForKnownSymbolName(symbolName: string): string; - function isESSymbolIdentifier(node: Node): 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 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.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.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.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.SpreadElementExpression | 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.JsxText | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | 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.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.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 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 isDestructuringAssignment(node: Node): node is BinaryExpression; - 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; - const stringify: (value: any) => string; - 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 collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver): { - externalImports: (ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration)[]; - exportSpecifiers: Map; - exportEquals: ExportAssignment; - hasExportStarsToExportValues: 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 isGeneratedIdentifier(node: Node): boolean; - 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 isBindingPattern(node: Node): node is BindingPattern; - function isBindingElement(node: Node): node is BindingElement; - function isArrayBindingElement(node: Node): node is ArrayBindingElement; - 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 isSpreadElementExpression(node: Node): node is SpreadElementExpression; - 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; - function textSpanEnd(span: TextSpan): number; - function textSpanIsEmpty(span: TextSpan): boolean; - function textSpanContainsPosition(span: TextSpan, position: number): boolean; - function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; - function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; - function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; - function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; - function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; - function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; - function createTextSpan(start: number, length: number): TextSpan; - function createTextSpanFromBounds(start: number, end: number): TextSpan; - function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; - function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; - function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; - let unchangedTextChangeRange: TextChangeRange; - function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; - function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; - function getCombinedNodeFlags(node: Node): NodeFlags; -} -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 | 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(name: string | Identifier | BindingPattern, initializer?: Expression, location?: TextRange): ParameterDeclaration; - function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; - function updateParameterDeclaration(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], 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, 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(asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, 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, 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): SpreadElementExpression; - function updateSpread(node: SpreadElementExpression, expression: Expression): SpreadElementExpression; - 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, 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 updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; - function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; - function createNotEmittedStatement(original: Node): NotEmittedStatement; - 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: 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; - function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression; - function createRestParameter(name: string | Identifier): ParameterDeclaration; - 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 createReactCreateElement(reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; - function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function createHelperName(externalHelpersModuleName: Identifier | undefined, name: string): Identifier | PropertyAccessExpression; - function createExtendsHelper(externalHelpersModuleName: Identifier | undefined, name: Identifier): CallExpression; - function createAssignHelper(externalHelpersModuleName: Identifier | undefined, attributesSegments: Expression[]): CallExpression; - function createParamHelper(externalHelpersModuleName: Identifier | undefined, expression: Expression, parameterOffset: number, location?: TextRange): CallExpression; - function createMetadataHelper(externalHelpersModuleName: Identifier | undefined, metadataKey: string, metadataValue: Expression): CallExpression; - function createDecorateHelper(externalHelpersModuleName: Identifier | undefined, decoratorExpressions: Expression[], target: Expression, memberName?: Expression, descriptor?: Expression, location?: TextRange): CallExpression; - function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block): CallExpression; - function createHasOwnProperty(target: LeftHandSideExpression, propertyName: Expression): CallExpression; - function createAdvancedAsyncSuperHelper(): VariableStatement; - function createSimpleAsyncSuperHelper(): VariableStatement; - 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 addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; - function ensureUseStrict(node: SourceFile): SourceFile; - function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: 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 getEmitFlags(node: Node): EmitFlags; - function setEmitFlags(node: T, emitFlags: EmitFlags): T; - function setSourceMapRange(node: T, range: TextRange): T; - function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; - function setCommentRange(node: T, range: TextRange): T; - function getCommentRange(node: Node): TextRange; - function getSourceMapRange(node: Node): TextRange; - function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; - function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; - 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; -} -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; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - 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; -} -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, f: (memo: T, node: Node) => T, initial: 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 visitEachChild(node: T, visitor: (node: Node) => VisitResult, context: LexicalEnvironment): T; - 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: (message?: string) => void; - const failBadSyntaxKind: (node: Node, message?: string) => void; - const assertNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; + 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[]; } -} -declare namespace ts { - function flattenDestructuringAssignment(context: TransformationContext, node: BinaryExpression, needsValue: boolean, recordTempVariable: (node: Identifier) => void, visitor?: (node: Node) => VisitResult): Expression; - function flattenParameterDestructuring(context: TransformationContext, node: ParameterDeclaration, value: Expression, visitor?: (node: Node) => VisitResult): VariableDeclaration[]; - function flattenVariableDestructuring(context: TransformationContext, node: VariableDeclaration, value?: Expression, visitor?: (node: Node) => VisitResult, recordTempVariable?: (node: Identifier) => void): VariableDeclaration[]; - function flattenVariableDestructuringToExpression(context: TransformationContext, node: VariableDeclaration, recordTempVariable: (name: Identifier) => void, nameSubstitution?: (name: Identifier) => Expression, visitor?: (node: Node) => VisitResult): Expression; -} -declare namespace ts { - function transformTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformJsx(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES7(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES6(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformGenerators(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 transformES6Module(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - 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; + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; } - interface TransformationContext extends LexicalEnvironment { - getCompilerOptions(): CompilerOptions; - getEmitResolver(): EmitResolver; - getEmitHost(): EmitHost; - hoistFunctionDeclaration(node: FunctionDeclaration): void; - hoistVariableDeclaration(node: Identifier): void; - 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; - } - type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; - 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; + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + openingBrace: string; } - 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 { - const version = "2.1.0"; - 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 { - getCurrentDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; } - 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; -} -declare namespace ts { - interface Node { - getSourceFile(): SourceFile; - getChildCount(sourceFile?: SourceFile): number; - getChildAt(index: number, sourceFile?: SourceFile): Node; - getChildren(sourceFile?: SourceFile): Node[]; - getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; - getFullStart(): number; - getEnd(): number; - getWidth(sourceFile?: SourceFile): number; - getFullWidth(): number; - getLeadingTriviaWidth(sourceFile?: SourceFile): number; - getFullText(sourceFile?: SourceFile): string; - getText(sourceFile?: SourceFile): string; - getFirstToken(sourceFile?: SourceFile): Node; - getLastToken(sourceFile?: SourceFile): Node; + interface OccurrencesResponseItem extends FileSpan { + isWriteAccess: boolean; } - interface Symbol { - getFlags(): SymbolFlags; - getName(): string; - getDeclarations(): Declaration[]; - getDocumentationComment(): SymbolDisplayPart[]; + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; } - interface Type { - getFlags(): TypeFlags; - getSymbol(): Symbol; - getProperties(): Symbol[]; - getProperty(propertyName: string): Symbol; - getApparentProperties(): Symbol[]; - getCallSignatures(): Signature[]; - getConstructSignatures(): Signature[]; - getStringIndexType(): Type; - getNumberIndexType(): Type; - getBaseTypes(): ObjectType[]; - getNonNullableType(): Type; + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; } - interface Signature { - getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; - getParameters(): Symbol[]; - getReturnType(): Type; - getDocumentationComment(): SymbolDisplayPart[]; + interface HighlightSpan extends TextSpan { + kind: string; } - interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; - getNamedDeclarations(): Map; - getLineAndCharacterOfPosition(pos: number): LineAndCharacter; - getLineStarts(): number[]; - getPositionOfLineAndCharacter(line: number, character: number): number; - update(newText: string, textChangeRange: TextChangeRange): SourceFile; + interface DocumentHighlightsItem { + file: string; + highlightSpans: HighlightSpan[]; } - interface IScriptSnapshot { - getText(start: number, end: number): string; - getLength(): number; - getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined; - dispose?(): void; + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; } - namespace ScriptSnapshot { - function fromString(text: string): IScriptSnapshot; + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; } - interface PreProcessedFileInfo { - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; - importedFiles: FileReference[]; - ambientExternalModules: string[]; - isLibFile: boolean; + interface ReferencesResponseItem extends FileSpan { + lineText: string; + isWriteAccess: boolean; + isDefinition: boolean; } - interface HostCancellationToken { - isCancellationRequested(): boolean; + interface ReferencesResponseBody { + refs: ReferencesResponseItem[]; + symbolName: string; + symbolStartOffset: number; + symbolDisplayString: string; } - interface LanguageServiceHost { - getCompilationSettings(): CompilerOptions; - getNewLine?(): string; - getProjectVersion?(): string; - getScriptFileNames(): string[]; - getScriptKind?(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): HostCancellationToken; - getCurrentDirectory(): string; - getDefaultLibFileName(options: CompilerOptions): string; - log?(s: string): void; - trace?(s: string): void; - error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - readFile?(path: string, encoding?: string): string; - fileExists?(path: string): boolean; - getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - directoryExists?(directoryName: string): boolean; - getDirectories?(directoryName: string): string[]; + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; } - interface LanguageService { - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; - getSemanticDiagnostics(fileName: string): Diagnostic[]; - getCompilerOptionsDiagnostics(): Diagnostic[]; - getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; - getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; - getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; - getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; - getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol; - getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; - getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; - getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - findReferences(fileName: string, position: number): ReferencedSymbol[]; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; - getNavigationBarItems(fileName: string): NavigationBarItem[]; - getNavigationTree(fileName: string): NavigationTree; - getOutliningSpans(fileName: string): OutliningSpan[]; - getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; - getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; - getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; - getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - 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 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?: TypingOptions; + } + interface CompileOnSaveMixin { + compileOnSave?: boolean; + } + type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; + interface ProjectChanges { + added: string[]; + removed: string[]; + } + interface ConfigureRequestArguments { + hostInfo?: string; + file?: string; + formatOptions?: FormatCodeSettings; + } + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; } - interface Classifications { - spans: number[]; - endOfLineState: EndOfLineState; + interface ConfigureResponse extends Response { } - interface ClassifiedSpan { - textSpan: TextSpan; - classificationType: string; + interface OpenRequestArgs extends FileRequestArgs { + fileContent?: string; + scriptKindName?: ScriptKindName; } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems: NavigationBarItem[]; - indent: number; - bolded: boolean; - grayed: boolean; + type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; } - interface NavigationTree { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems?: NavigationTree[]; + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; } - interface TodoCommentDescriptor { - text: string; - priority: number; + type OpenExternalProjectArgs = ExternalProject; + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; } - interface TodoComment { - descriptor: TodoCommentDescriptor; - message: string; - position: number; + interface OpenExternalProjectsArgs { + projects: ExternalProject[]; } - class TextChange { - span: TextSpan; - newText: string; + interface OpenExternalProjectResponse extends Response { } - interface FileTextChanges { - fileName: string; - textChanges: TextChange[]; + interface OpenExternalProjectsResponse extends Response { } - interface CodeAction { - description: string; - changes: FileTextChanges[]; + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; } - interface TextInsertion { - newText: string; - caretOffset: number; + interface CloseExternalProjectRequestArgs { + projectFileName: string; } - interface RenameLocation { - textSpan: TextSpan; - fileName: string; + interface CloseExternalProjectResponse extends Response { } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; - isWriteAccess: boolean; - isDefinition: boolean; + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; } - interface ImplementationLocation { - textSpan: TextSpan; - fileName: string; + interface SetCompilerOptionsForInferredProjectsArgs { + options: ExternalProjectCompilerOptions; } - interface DocumentHighlights { - fileName: string; - highlightSpans: HighlightSpan[]; + interface SetCompilerOptionsForInferredProjectsResponse extends Response { } - namespace HighlightSpanKind { - const none = "none"; - const definition = "definition"; - const reference = "reference"; - const writtenReference = "writtenReference"; + interface ExitRequest extends Request { + command: CommandTypes.Exit; } - interface HighlightSpan { - fileName?: string; - textSpan: TextSpan; - kind: string; + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; } - interface NavigateToItem { - name: string; + 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; - matchKind: string; - isCaseSensitive: boolean; + 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; - textSpan: TextSpan; - containerName: string; - containerKind: string; + textChanges: CodeEdit[]; } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, + interface CodeFixResponse extends Response { + body?: CodeAction[]; } - interface EditorOptions { - BaseIndentSize?: number; - IndentSize: number; - TabSize: number; - NewLineCharacter: string; - ConvertTabsToSpaces: boolean; - IndentStyle: IndentStyle; + interface CodeAction { + description: string; + changes: FileCodeEdits[]; } - interface EditorSettings { - baseIndentSize?: number; - indentSize?: number; - tabSize?: number; - newLineCharacter?: string; - convertTabsToSpaces?: boolean; - indentStyle?: IndentStyle; + interface FormatResponse extends Response { + body?: CodeEdit[]; } - interface FormatCodeOptions extends EditorOptions { - InsertSpaceAfterCommaDelimiter: boolean; - InsertSpaceAfterSemicolonInForStatements: boolean; - InsertSpaceBeforeAndAfterBinaryOperators: boolean; - InsertSpaceAfterKeywordsInControlFlowStatements: boolean; - InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; - InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; - InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - InsertSpaceAfterTypeAssertion?: boolean; - PlaceOpenBraceOnNewLineForFunctions: boolean; - PlaceOpenBraceOnNewLineForControlBlocks: boolean; + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + key: string; + options?: FormatCodeSettings; } - interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter?: boolean; - insertSpaceAfterSemicolonInForStatements?: boolean; - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - insertSpaceAfterTypeAssertion?: boolean; - placeOpenBraceOnNewLineForFunctions?: boolean; - placeOpenBraceOnNewLineForControlBlocks?: boolean; + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; } - interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; - kind: string; - name: string; - containerKind: string; - containerName: string; + interface CompletionsRequestArgs extends FileLocationRequestArgs { + prefix?: string; } - interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { - displayParts: SymbolDisplayPart[]; + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; } - interface ReferencedSymbol { - definition: ReferencedSymbolDefinitionInfo; - references: ReferenceEntry[]; + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + entryNames: string[]; } - enum SymbolDisplayPartKind { - aliasName = 0, - className = 1, - enumName = 2, - fieldName = 3, - interfaceName = 4, - keyword = 5, - lineBreak = 6, - numericLiteral = 7, - stringLiteral = 8, - localName = 9, - methodName = 10, - moduleName = 11, - operator = 12, - parameterName = 13, - propertyName = 14, - punctuation = 15, - space = 16, - text = 17, - typeParameterName = 18, - enumMemberName = 19, - functionName = 20, - regularExpressionLiteral = 21, + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; } interface SymbolDisplayPart { text: string; kind: string; } - interface QuickInfo { + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; + } + interface CompletionEntryDetails { + name: string; kind: string; kindModifiers: string; - textSpan: TextSpan; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - triggerSpan: TextSpan; + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; } interface SignatureHelpParameter { name: string; @@ -9504,848 +3269,275 @@ declare namespace ts { argumentIndex: number; argumentCount: number; } - interface CompletionInfo { - isGlobalCompletion: boolean; - isMemberCompletion: boolean; - isNewIdentifierLocation: boolean; - entries: CompletionEntry[]; + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - replacementSpan?: TextSpan; + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; } - interface OutliningSpan { - textSpan: TextSpan; - hintSpan: TextSpan; - bannerText: string; - autoCollapse: boolean; + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; } - interface EmitOutput { - outputFiles: OutputFile[]; - emitSkipped: boolean; + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; } - const enum OutputFileType { - JavaScript = 0, - SourceMap = 1, - Declaration = 2, + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; } - interface OutputFile { - name: string; - writeByteOrderMark: boolean; - text: string; + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; } - const enum EndOfLineState { - None = 0, - InMultiLineCommentTrivia = 1, - InSingleQuoteStringLiteral = 2, - InDoubleQuoteStringLiteral = 3, - InTemplateHeadOrNoSubstitutionTemplate = 4, - InTemplateMiddleOrTail = 5, - InTemplateSubstitutionPosition = 6, + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; } - enum TokenClass { - Punctuation = 0, - Keyword = 1, - Operator = 2, - Comment = 3, - Whitespace = 4, - Identifier = 5, - NumberLiteral = 6, - StringLiteral = 7, - RegExpLiteral = 8, + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; } - interface ClassificationResult { - finalLexState: EndOfLineState; - entries: ClassificationInfo[]; + interface GeterrForProjectRequestArgs { + file: string; + delay: number; } - interface ClassificationInfo { - length: number; - classification: TokenClass; + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; } - interface Classifier { - getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; - getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; + interface GeterrRequestArgs { + files: string[]; + delay: number; } - namespace ScriptElementKind { - const unknown = ""; - const warning = "warning"; - const keyword = "keyword"; - const scriptElement = "script"; - const moduleElement = "module"; - const classElement = "class"; - const localClassElement = "local class"; - const interfaceElement = "interface"; - const typeElement = "type"; - const enumElement = "enum"; - const enumMemberElement = "const"; - const variableElement = "var"; - const localVariableElement = "local var"; - const functionElement = "function"; - const localFunctionElement = "local function"; - const memberFunctionElement = "method"; - const memberGetAccessorElement = "getter"; - const memberSetAccessorElement = "setter"; - const memberVariableElement = "property"; - const constructorImplementationElement = "constructor"; - const callSignatureElement = "call"; - const indexSignatureElement = "index"; - const constructSignatureElement = "construct"; - const parameterElement = "parameter"; - const typeParameterElement = "type parameter"; - const primitiveType = "primitive type"; - const label = "label"; - const alias = "alias"; - const constElement = "const"; - const letElement = "let"; - const directory = "directory"; - const externalModuleName = "external module name"; + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; } - namespace ScriptElementKindModifier { - const none = ""; - const publicMemberModifier = "public"; - const privateMemberModifier = "private"; - const protectedMemberModifier = "protected"; - const exportedModifier = "export"; - const ambientModifier = "declare"; - const staticModifier = "static"; - const abstractModifier = "abstract"; + interface Diagnostic { + start: Location; + end: Location; + text: string; + code?: number; } - class ClassificationTypeNames { - static comment: string; - static identifier: string; - static keyword: string; - static numericLiteral: string; - static operator: string; - static stringLiteral: string; - static whiteSpace: string; - static text: string; - static punctuation: string; - static className: string; - static enumName: string; - static interfaceName: string; - static moduleName: string; - static typeParameterName: string; - static typeAliasName: string; - static parameterName: string; - static docCommentTagName: string; - static jsxOpenTagName: string; - static jsxCloseTagName: string; - static jsxSelfClosingTagName: string; - static jsxAttribute: string; - static jsxText: string; - static jsxAttributeStringLiteralValue: string; + interface DiagnosticEventBody { + file: string; + diagnostics: Diagnostic[]; } - const enum ClassificationType { - comment = 1, - identifier = 2, - keyword = 3, - numericLiteral = 4, - operator = 5, - stringLiteral = 6, - regularExpressionLiteral = 7, - whiteSpace = 8, - text = 9, - punctuation = 10, - className = 11, - enumName = 12, - interfaceName = 13, - moduleName = 14, - typeParameterName = 15, - typeAliasName = 16, - parameterName = 17, - docCommentTagName = 18, - jsxOpenTagName = 19, - jsxCloseTagName = 20, - jsxSelfClosingTagName = 21, - jsxAttribute = 22, - jsxText = 23, - jsxAttributeStringLiteralValue = 24, + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; } -} -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, symbol?: Symbol): 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; + interface ConfigFileDiagnosticEventBody { + triggerFile: string; + configFile: string; diagnostics: Diagnostic[]; - }; -} -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 { - acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; - releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; - releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; - reportStats(): string; } - type DocumentRegistryBucketKey = string & { - __bucketKey: any; - }; - 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[], name: string, canUseParsedParamTagComments: boolean): 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 ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; } - interface PatternMatcher { - getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[]; - getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; - patternContainsDots: boolean; + interface ReloadRequestArgs extends FileRequestArgs { + tmpfile: string; } - 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; + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; } - 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; - fileName?: string; - reportDiagnostics?: boolean; - moduleName?: string; - renamedDependencies?: MapLike; + interface ReloadResponse extends Response { } - interface TranspileOutput { - outputText: string; - diagnostics?: Diagnostic[]; - sourceMapText?: string; + interface SavetoRequestArgs extends FileRequestArgs { + tmpfile: string; } - 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; + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; } - 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); + interface NavtoRequestArgs extends FileRequestArgs { + searchValue: string; + maxResultCount?: number; + currentFileOnly?: boolean; + projectFileName?: string; } -} -declare namespace ts.formatting { - const enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnClosingCurlyBrace = 4, + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; } -} -declare namespace ts.formatting { - class Rule { - Descriptor: RuleDescriptor; - Operation: RuleOperation; - Flag: RuleFlags; - constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); - toString(): string; + interface NavtoItem { + name: string; + kind: string; + matchKind?: string; + isCaseSensitive?: boolean; + kindModifiers?: string; + file: string; + start: Location; + end: Location; + containerName?: string; + containerKind?: string; } -} -declare namespace ts.formatting { - const enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8, + interface NavtoResponse extends Response { + body?: NavtoItem[]; } -} -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; + interface ChangeRequestArgs extends FormatRequestArgs { + insertString?: string; } -} -declare namespace ts.formatting { - const enum RuleFlags { - None = 0, - CanDeleteNewLines = 1, + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; } -} -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; + interface BraceResponse extends Response { + body?: TextSpan[]; } -} -declare namespace ts.formatting { - class RuleOperationContext { - private customContextChecks; - constructor(...funcs: { - (context: FormattingContext): boolean; - }[]); - static Any: RuleOperationContext; - IsAny(): boolean; - InContext(context: FormattingContext): boolean; + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; } -} -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; - NoSpaceBeforeOpenParenInFuncDecl: Rule; - SpaceAfterVoidOperator: Rule; - NoSpaceBetweenReturnAndSemicolon: Rule; - SpaceBetweenStatements: Rule; - SpaceAfterTryFinally: Rule; - SpaceAfterGetSetInMember: Rule; - SpaceBeforeBinaryKeywordOperator: Rule; - SpaceAfterBinaryKeywordOperator: 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; - 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 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; + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; } -} -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; + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; } -} -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(tokenValue: SyntaxKind): 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; - } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers?: string; + spans: TextSpan[]; + childItems?: NavigationBarItem[]; + indent: number; } -} -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); + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; } -} -declare namespace ts.formatting { - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; } - 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; + interface NavTreeResponse extends Response { + body?: NavigationTree; } -} -declare namespace ts { - interface CodeFix { - errorCodes: number[]; - getCodeActions(context: CodeFixContext): CodeAction[] | undefined; + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; } - interface CodeFixContext { - errorCode: number; - sourceFile: SourceFile; - span: TextSpan; - program: Program; - newLineCharacter: string; + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; } - namespace codefix { - function registerCodeFix(action: CodeFix): void; - function getSupportedErrorCodes(): string[]; - function getFixes(context: CodeFixContext): CodeAction[]; + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; } -} -declare namespace ts.codefix { -} -declare namespace ts { - const servicesVersion = "0.5"; - interface DisplayPartsSymbolWriter extends SymbolWriter { - displayParts(): SymbolDisplayPart[]; + 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; } - function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; - function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; - function displayPartsToString(displayParts: SymbolDisplayPart[]): string; - function getDefaultCompilerOptions(): CompilerOptions; - function getSupportedCodeFixes(): string[]; - function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; - 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; + 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 { class ScriptInfo { @@ -10372,7 +3564,7 @@ declare namespace ts.server { getLatestVersion(): string; reload(script: string): void; saveTo(fileName: string): void; - reloadFromFile(): void; + reloadFromFile(tempFileName?: NormalizedPath): void; snap(): LineIndexSnapshot; getLineInfo(line: number): ILineInfo; editContent(start: number, end: number, newText: string): void; @@ -10529,7 +3721,7 @@ declare namespace ts.server { getScriptInfo(uncheckedFileName: string): ScriptInfo; filesToString(): string; setCompilerOptions(compilerOptions: CompilerOptions): void; - reloadScript(filename: NormalizedPath): boolean; + reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics; getReferencedFiles(path: Path): Path[]; private removeRootFileIfNecessary(info); @@ -10595,7 +3787,7 @@ declare namespace ts.server { } | { eventName: "configFileDiag"; data: { - triggerFile?: string; + triggerFile: string; configFileName: string; diagnostics: Diagnostic[]; }; @@ -10603,6 +3795,10 @@ declare namespace ts.server { 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; @@ -10638,6 +3834,7 @@ declare namespace ts.server { constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); getChangedFiles_TestOnly(): ScriptInfo[]; ensureInferredProjectsUpToDate_TestOnly(): void; + getCompilerOptionsForInferredProjects(): CompilerOptions; updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; stopWatchingDirectory(directory: string): void; @@ -10651,7 +3848,7 @@ declare namespace ts.server { private handleDeletedFile(info); private onTypeRootFileChanged(project, fileName); private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); - private handleChangeInSourceFileForConfiguredProject(project); + private handleChangeInSourceFileForConfiguredProject(project, triggerFile); private onConfigChangedForConfiguredProject(project); private onConfigFileAddedForInferredProject(fileName); private getCanonicalFileName(fileName); @@ -10666,7 +3863,7 @@ declare namespace ts.server { private convertConfigFileContentToProjectOptions(configFilename); private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); private createAndAddExternalProject(projectFileName, files, options, typingOptions); - private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile?); + private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); private watchConfigDirectoryForProject(project, options); private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typingOptions, configFileErrors); @@ -10800,7 +3997,7 @@ declare namespace ts.server { private getProject(projectFileName); private getCompilerOptionsDiagnostics(args); private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); - private getDiagnosticsWorker(args, selector, includeLinePosition); + private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); private getDefinition(args, simplifiedResult); private getTypeDefinition(args); private getImplementation(args, simplifiedResult); @@ -10996,178 +4193,3 @@ 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) => ResolvedModule[]; - 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; - close(): void; - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } -} -declare namespace TypeScript.Services { - const TypeScriptServicesFactory: typeof ts.TypeScriptServicesFactory; -} -declare const toolsVersion = "2.1"; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index a360ac081ec98..0a476fd3ed142 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -20,6 +20,418 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +444,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -46,6 +490,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -63,10 +667,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -77,7 +938,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -129,7 +990,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -150,7 +1018,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -192,6 +1060,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -335,13 +1209,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -442,6 +1335,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -454,8 +1359,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -488,8 +1393,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -708,8 +1613,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -810,7 +1715,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -841,7 +1746,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -866,11 +1771,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -933,7 +1838,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1086,7 +1991,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1383,7 +2288,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1398,7 +2303,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1508,6 +2413,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1571,10 +2484,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1596,6 +2509,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1908,7 +2828,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1980,6 +2900,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2121,7 +3046,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2137,9 +3062,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2927,7 +3852,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2964,7171 +3889,5722 @@ var ts; 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" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { - function tokenIsIdentifierOrKeyword(token) { - return token >= 69; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ - "abstract": 115, - "any": 117, - "as": 116, - "boolean": 120, - "break": 70, - "case": 71, - "catch": 72, - "class": 73, - "continue": 75, - "const": 74, - "constructor": 121, - "debugger": 76, - "declare": 122, - "default": 77, - "delete": 78, - "do": 79, - "else": 80, - "enum": 81, - "export": 82, - "extends": 83, - "false": 84, - "finally": 85, - "for": 86, - "from": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 44, - ">>>": 45, - "&": 46, - "|": 47, - "^": 48, - "!": 49, - "~": 50, - "&&": 51, - "||": 52, - "?": 53, - ":": 54, - "=": 56, - "+=": 57, - "-=": 58, - "*=": 59, - "**=": 60, - "/=": 61, - "%=": 62, - "<<=": 63, - ">>=": 64, - ">>>=": 65, - "&=": 66, - "|=": 67, - "^=": 68, - "@": 55 - }); - var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - function lookupInUnicodeMap(code, map) { - if (code < map[0]) { - return false; - } - var lo = 0; - var hi = map.length; - var mid; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - if (code < map[mid]) { - hi = mid; - } - else { - lo = mid + 2; - } - } - return false; - } - function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); - } - ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; - function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + function trace(host) { + host.trace(ts.formatMessage.apply(undefined, arguments)); } - function makeReverseMap(source) { - var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } - return result; + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; } - var tokenStrings = makeReverseMap(textToToken); - function tokenToString(t) { - return tokenStrings[t]; + ts.isTraceEnabled = isTraceEnabled; + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; } - ts.tokenToString = tokenToString; - function stringToToken(s) { - return textToToken[s]; + ts.createResolvedModule = createResolvedModule; + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - ts.stringToToken = stringToToken; - function computeLineStarts(text) { - var result = new Array(); - var pos = 0; - var lineStart = 0; - while (pos < text.length) { - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 13: - if (text.charCodeAt(pos) === 10) { - pos++; + function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + function tryReadFromField(fieldName) { + if (ts.hasProperty(jsonContent, fieldName)) { + var typesFile = jsonContent[fieldName]; + if (typeof typesFile === "string") { + var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); } - case 10: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > 127 && isLineBreak(ch)) { - result.push(lineStart); - lineStart = pos; + return typesFilePath_1; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); } - break; + } } } - result.push(lineStart); - return result; - } - ts.computeLineStarts = computeLineStarts; - function getPositionOfLineAndCharacter(sourceFile, line, character) { - return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); - } - ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; - function computePositionOfLineAndCharacter(lineStarts, line, character) { - ts.Debug.assert(line >= 0 && line < lineStarts.length); - return lineStarts[line] + character; - } - ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; - function getLineStarts(sourceFile) { - return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); - } - ts.getLineStarts = getLineStarts; - function computeLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position); - if (lineNumber < 0) { - lineNumber = ~lineNumber - 1; - ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); + var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { + return typesFilePath; } - return { - line: lineNumber, - character: position - lineStarts[lineNumber] - }; - } - ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; - function getLineAndCharacterOfPosition(sourceFile, position) { - return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); - } - ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function isWhiteSpace(ch) { - return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); - } - ts.isWhiteSpace = isWhiteSpace; - function isWhiteSpaceSingleLine(ch) { - return ch === 32 || - ch === 9 || - ch === 11 || - ch === 12 || - ch === 160 || - ch === 133 || - ch === 5760 || - ch >= 8192 && ch <= 8203 || - ch === 8239 || - ch === 8287 || - ch === 12288 || - ch === 65279; - } - ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; - function isLineBreak(ch) { - return ch === 10 || - ch === 13 || - ch === 8232 || - ch === 8233; - } - ts.isLineBreak = isLineBreak; - function isDigit(ch) { - return ch >= 48 && ch <= 57; + if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + } + var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + return mainFilePath; + } + return undefined; } - function isOctalDigit(ch) { - return ch >= 48 && ch <= 55; + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } } - ts.isOctalDigit = isOctalDigit; - function couldStartTrivia(text, pos) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - case 10: - case 9: - case 11: - case 12: - case 32: - case 47: - case 60: - case 61: - case 62: - return true; - case 35: - return pos === 0; - default: - return ch > 127; + var typeReferenceExtensions = [".d.ts"]; + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); } + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); } - ts.couldStartTrivia = couldStartTrivia; - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } - if (ts.positionIsSynthesized(pos)) { - return pos; + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } + var typeRoots; while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - if (stopAtComments) { - break; - } - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; - case 60: - case 61: - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; - case 35: - if (pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - continue; - } - break; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - pos++; - continue; - } - break; + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); } - return pos; + var parent_1 = ts.getDirectoryPath(currentDirectory); + if (parent_1 === currentDirectory) { + break; + } + currentDirectory = parent_1; } + return typeRoots; } - ts.skipTrivia = skipTrivia; - var mergeConflictMarkerLength = "<<<<<<<".length; - function isConflictMarkerTrivia(text, pos) { - ts.Debug.assert(pos >= 0); - 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++) { - if (text.charCodeAt(pos + i) !== ch) { - return false; + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + skipTsx: true, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + var primarySearchPaths = typeRoots; + for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { + var typeRoot = primarySearchPaths_1[_i]; + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); + if (resolvedFile_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); } + return { + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + failedLookupLocations: failedLookupLocations + }; } - return ch === 61 || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32; } } - return false; - } - function scanConflictMarkerTrivia(text, pos, error) { - if (error) { - error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } } - var ch = text.charCodeAt(pos); - var len = text.length; - if (ch === 60 || ch === 62) { - while (pos < len && !isLineBreak(text.charCodeAt(pos))) { - pos++; + var resolvedFile; + var initialLocationForSecondaryLookup; + if (containingFile) { + initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); + } + if (initialLocationForSecondaryLookup !== undefined) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + if (traceEnabled) { + if (resolvedFile) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } } } else { - ts.Debug.assert(ch === 61); - while (pos < len) { - var ch_1 = text.charCodeAt(pos); - if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { - break; + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + return { + resolvedTypeReferenceDirective: resolvedFile + ? { primary: false, resolvedFileName: resolvedFile } + : undefined, + failedLookupLocations: failedLookupLocations + }; + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } } - pos++; } } - return pos; + return result; } - var shebangTriviaRegex = /^#!.*/; - function isShebangTrivia(text, pos) { - ts.Debug.assert(pos === 0); - return shebangTriviaRegex.test(text); + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + 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; + 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]); + } + } + 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) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; } - function scanShebangTrivia(text, pos) { - var shebang = shebangTriviaRegex.exec(text)[0]; - pos = pos + shebang.length; - return pos; + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } } - function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { - var pendingPos; - var pendingEnd; - var pendingKind; - var pendingHasTrailingNewLine; - var hasPendingCommentRange = false; - var collecting = trailing || pos === 0; - var accumulator = initial; - scan: while (pos >= 0 && pos < text.length) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (trailing) { - break scan; - } - collecting = true; - if (hasPendingCommentRange) { - pendingHasTrailingNewLine = true; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - var nextChar = text.charCodeAt(pos + 1); - var hasTrailingNewLine = false; - if (nextChar === 47 || nextChar === 42) { - var kind = nextChar === 47 ? 2 : 3; - var startPos = pos; - pos += 2; - if (nextChar === 47) { - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - hasTrailingNewLine = true; - break; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - } - if (collecting) { - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); - if (!reduce && accumulator) { - return accumulator; - } - hasPendingCommentRange = false; - } - pendingPos = startPos; - pendingEnd = pos; - pendingKind = kind; - pendingHasTrailingNewLine = hasTrailingNewLine; - hasPendingCommentRange = true; - } - continue; - } - break scan; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - if (hasPendingCommentRange && isLineBreak(ch)) { - pendingHasTrailingNewLine = true; - } - pos++; - continue; - } - break scan; + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; } } - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } } - return accumulator; - } - function forEachLeadingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, false, cb, state); - } - ts.forEachLeadingCommentRange = forEachLeadingCommentRange; - function forEachTrailingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, true, cb, state); - } - ts.forEachTrailingCommentRange = forEachTrailingCommentRange; - function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, false, cb, state, initial); - } - ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; - function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, true, cb, state, initial); + return undefined; } - ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { - if (!comments) { - comments = []; + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - return comments; - } - function getLeadingCommentRanges(text, pos) { - return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - ts.getTrailingCommentRanges = getTrailingCommentRanges; - function getShebang(text) { - return shebangTriviaRegex.test(text) - ? shebangTriviaRegex.exec(text)[0] - : undefined; + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + var isExternalLibraryImport = false; + if (!resolvedFileName) { + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + } + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); + isExternalLibraryImport = resolvedFileName !== undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + } + } + if (resolvedFileName && host.realpath) { + var originalFileName = resolvedFileName; + resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + } + } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } - ts.getShebang = getShebang; - function isIdentifierStart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); } - ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); + function directoryProbablyExists(directoryName, host) { + return !host.directoryExists || host.directoryExists(directoryName); } - ts.isIdentifierPart = isIdentifierPart; - function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { - return false; + ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; } - for (var i = 1, n = name.length; i < n; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { - return false; + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); } - return true; } - ts.isIdentifierText = isIdentifierText; - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0; } - var pos; - var end; - var startPos; - var tokenPos; - var token; - var tokenValue; - var precedingLineBreak; - var hasExtendedUnicodeEscape; - var tokenIsUnterminated; - setText(text, start, length); - return { - getStartPos: function () { return startPos; }, - getTextPos: function () { return pos; }, - getToken: function () { return token; }, - getTokenPos: function () { return tokenPos; }, - getTokenText: function () { return text.substring(tokenPos, pos); }, - getTokenValue: function () { return tokenValue; }, - hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, - hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, - isUnterminated: function () { return tokenIsUnterminated; }, - reScanGreaterToken: reScanGreaterToken, - reScanSlashToken: reScanSlashToken, - reScanTemplateToken: reScanTemplateToken, - scanJsxIdentifier: scanJsxIdentifier, - scanJsxAttributeValue: scanJsxAttributeValue, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scanJSDocToken: scanJSDocToken, - scan: scan, - getText: getText, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead, - scanRange: scanRange - }; - function error(message, length) { - if (onError) { - onError(message, length || 0); + function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - function scanNumber() { - var start = pos; - while (isDigit(text.charCodeAt(pos))) - pos++; - if (text.charCodeAt(pos) === 46) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; + return ts.forEach(extensions, function (ext) { + return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); + }); + } + function tryFile(fileName, failedLookupLocation, 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); } - var end = pos; - if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { - pos++; - if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) - pos++; - if (isDigit(text.charCodeAt(pos))) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - end = pos; + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocation.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); + if (result) { + return result; } - else { - error(ts.Diagnostics.Digit_expected); + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); } } - return "" + +(text.substring(start, end)); } - function scanOctalDigits() { - var start = pos; - while (isOctalDigit(text.charCodeAt(pos))) { - pos++; + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } - return +(text.substring(start, pos)); + failedLookupLocation.push(packageJsonPath); } - function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); + var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; } - function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; } - function scanHexDigits(minCount, scanAsManyAsPossible) { - var digits = 0; - var value = 0; - while (digits < minCount || scanAsManyAsPossible) { - var ch = text.charCodeAt(pos); - if (ch >= 48 && ch <= 57) { - value = value * 16 + ch - 48; - } - else if (ch >= 65 && ch <= 70) { - value = value * 16 + ch - 65 + 10; - } - else if (ch >= 97 && ch <= 102) { - value = value * 16 + ch - 97 + 10; + } + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var packageResult = void 0; + if (!typesOnly) { + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + return packageResult; + } } - else { - break; + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; } - pos++; - digits++; } - if (digits < minCount) { - value = -1; + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory || checkOneLevel) { + break; } - return value; + directory = parentPath; } - function scanString(allowEscapes) { - if (allowEscapes === void 0) { allowEscapes = true; } - var quote = text.charCodeAt(pos); - pos++; - var result = ""; - var start = pos; - while (true) { - if (pos >= end) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - var ch = text.charCodeAt(pos); - if (ch === quote) { - result += text.substring(start, pos); - pos++; - break; - } - if (ch === 92 && allowEscapes) { - result += text.substring(start, pos); - result += scanEscapeSequence(); - start = pos; - continue; - } - if (isLineBreak(ch)) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - pos++; - } - return result; + return undefined; + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var failedLookupLocations = []; + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); } - function scanTemplateAndSetTokenValue() { - var startedWithBacktick = text.charCodeAt(pos) === 96; - pos++; - var start = pos; - var contents = ""; - var resultingToken; - while (true) { - if (pos >= end) { - contents += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - var currChar = text.charCodeAt(pos); - if (currChar === 96) { - contents += text.substring(start, pos); - pos++; - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { - contents += text.substring(start, pos); - pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; - break; - } - if (currChar === 92) { - contents += text.substring(start, pos); - contents += scanEscapeSequence(); - start = pos; - continue; - } - if (currChar === 13) { - contents += text.substring(start, pos); - pos++; - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - contents += "\n"; - start = pos; - continue; - } - pos++; - } - ts.Debug.assert(resultingToken !== undefined); - tokenValue = contents; - return resultingToken; + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } - function scanEscapeSequence() { - pos++; - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - return ""; - } - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 48: - return "\0"; - case 98: - return "\b"; - case 116: - return "\t"; - case 110: - return "\n"; - case 118: - return "\v"; - case 102: - return "\f"; - case 114: - return "\r"; - case 39: - return "\'"; - case 34: - return "\""; - case 117: - if (pos < end && text.charCodeAt(pos) === 123) { - hasExtendedUnicodeEscape = true; - pos++; - return scanExtendedUnicodeEscape(); - } - return scanHexadecimalEscape(4); - case 120: - return scanHexadecimalEscape(2); - case 13: - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - case 10: - case 8232: - case 8233: - return ""; - default: - return String.fromCharCode(ch); - } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); } - function scanHexadecimalEscape(numDigits) { - var escapedValue = scanExactNumberOfHexDigits(numDigits); - if (escapedValue >= 0) { - return String.fromCharCode(escapedValue); + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + return referencedSourceFile; } - else { - error(ts.Diagnostics.Hexadecimal_digit_expected); - return ""; + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; } + containingDirectory = parentPath; } - function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1); - var isInvalidExtendedEscape = false; - if (escapedValue < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - isInvalidExtendedEscape = true; - } - else if (escapedValue > 0x10FFFF) { - error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); - isInvalidExtendedEscape = true; - } - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - isInvalidExtendedEscape = true; - } - else if (text.charCodeAt(pos) === 125) { - pos++; - } - else { - error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); - isInvalidExtendedEscape = true; - } - if (isInvalidExtendedEscape) { - return ""; + } +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.externalHelpersModuleNameText = "tslib"; + function getDeclarationOfKind(symbol, kind) { + var declarations = symbol.declarations; + if (declarations) { + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; + if (declaration.kind === kind) { + return declaration; + } } - return utf16EncodeAsString(escapedValue); } - function utf16EncodeAsString(codePoint) { - ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); - if (codePoint <= 65535) { - return String.fromCharCode(codePoint); + return undefined; + } + ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length === 0) { + var str_1 = ""; + var writeText = function (text) { return str_1 += text; }; + return { + string: function () { return str_1; }, + writeKeyword: writeText, + writeOperator: writeText, + writePunctuation: writeText, + writeSpace: writeText, + writeStringLiteral: writeText, + writeParameter: writeText, + writeSymbol: writeText, + writeLine: function () { return str_1 += " "; }, + increaseIndent: function () { }, + decreaseIndent: function () { }, + clear: function () { return str_1 = ""; }, + trackSymbol: function () { }, + reportInaccessibleThisError: function () { } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + ts.releaseStringWriter = releaseStringWriter; + function getFullWidth(node) { + return node.end - node.pos; + } + ts.getFullWidth = getFullWidth; + function arrayIsEqualTo(array1, array2, equaler) { + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; + if (!equals) { + return false; } - var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; - var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; - return String.fromCharCode(codeUnit1, codeUnit2); } - function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { - var start_1 = pos; - pos += 2; - var value = scanExactNumberOfHexDigits(4); - pos = start_1; - return value; + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function hasResolvedModule(sourceFile, moduleNameText) { + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + } + ts.hasResolvedModule = hasResolvedModule; + function getResolvedModule(sourceFile, moduleNameText) { + return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + } + ts.getResolvedModule = getResolvedModule; + function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + if (!sourceFile.resolvedModules) { + sourceFile.resolvedModules = ts.createMap(); + } + sourceFile.resolvedModules[moduleNameText] = resolvedModule; + } + ts.setResolvedModule = setResolvedModule; + function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { + if (!sourceFile.resolvedTypeReferenceDirectiveNames) { + sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + } + sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; + } + ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; + function moduleResolutionIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; + } + ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; + function typeDirectiveIsEqualTo(oldResolution, newResolution) { + return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + } + ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; + function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { + if (names.length !== newResolutions.length) { + return false; + } + for (var i = 0; i < names.length; i++) { + var newResolution = newResolutions[i]; + var oldResolution = oldResolutions && oldResolutions[names[i]]; + var changed = oldResolution + ? !newResolution || !comparer(oldResolution, newResolution) + : newResolution; + if (changed) { + return true; } - return -1; } - function scanIdentifierParts() { - var result = ""; - var start = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch, languageVersion)) { - pos++; - } - else if (ch === 92) { - ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { - break; - } - result += text.substring(start, pos); - result += String.fromCharCode(ch); - pos += 6; - start = pos; - } - else { - break; - } + return false; + } + ts.hasChangesInResolutions = hasChangesInResolutions; + function containsParseError(node) { + aggregateChildData(node); + return (node.flags & 2097152) !== 0; + } + ts.containsParseError = containsParseError; + function aggregateChildData(node) { + if (!(node.flags & 4194304)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || + ts.forEachChild(node, containsParseError); + if (thisNodeOrAnySubNodesHasError) { + node.flags |= 2097152; } - result += text.substring(start, pos); - return result; + node.flags |= 4194304; } - function getIdentifierToken() { - var len = tokenValue.length; - if (len >= 2 && len <= 11) { - var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; - } + } + function getSourceFileOfNode(node) { + while (node && node.kind !== 256) { + node = node.parent; + } + return node; + } + ts.getSourceFileOfNode = getSourceFileOfNode; + function isStatementWithLocals(node) { + switch (node.kind) { + case 200: + case 228: + case 207: + case 208: + case 209: + return true; + } + return false; + } + ts.isStatementWithLocals = isStatementWithLocals; + function getStartPositionOfLine(line, sourceFile) { + ts.Debug.assert(line >= 0); + return ts.getLineStarts(sourceFile)[line]; + } + ts.getStartPositionOfLine = getStartPositionOfLine; + function nodePosToString(node) { + var file = getSourceFileOfNode(node); + var loc = ts.getLineAndCharacterOfPosition(file, node.pos); + return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + } + ts.nodePosToString = nodePosToString; + function getStartPosOfNode(node) { + return node.pos; + } + ts.getStartPosOfNode = getStartPosOfNode; + function isDefined(value) { + return value !== undefined; + } + ts.isDefined = isDefined; + function getEndLinePosition(line, sourceFile) { + ts.Debug.assert(line >= 0); + var lineStarts = ts.getLineStarts(sourceFile); + var lineIndex = line; + var sourceText = sourceFile.text; + if (lineIndex + 1 === lineStarts.length) { + return sourceText.length - 1; + } + else { + var start = lineStarts[lineIndex]; + var pos = lineStarts[lineIndex + 1] - 1; + ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); + while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { + pos--; } - return token = 69; + return pos; } - function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; - var numberOfDigits = 0; - while (true) { - var ch = text.charCodeAt(pos); - var valueOfCh = ch - 48; - if (!isDigit(ch) || valueOfCh >= base) { - break; - } - value = value * base + valueOfCh; - pos++; - numberOfDigits++; + } + ts.getEndLinePosition = getEndLinePosition; + function nodeIsMissing(node) { + if (node === undefined) { + return true; + } + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + } + ts.nodeIsMissing = nodeIsMissing; + function nodeIsPresent(node) { + return !nodeIsMissing(node); + } + ts.nodeIsPresent = nodeIsPresent; + function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { + if (nodeIsMissing(node)) { + return node.pos; + } + if (isJSDocNode(node)) { + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); + } + if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { + return getTokenPosOfNode(node.jsDocComments[0]); + } + if (node.kind === 286 && node._children.length > 0) { + return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + } + ts.getTokenPosOfNode = getTokenPosOfNode; + function isJSDocNode(node) { + return node.kind >= 257 && node.kind <= 282; + } + ts.isJSDocNode = isJSDocNode; + function isJSDocTag(node) { + return node.kind >= 273 && node.kind <= 285; + } + ts.isJSDocTag = isJSDocTag; + function getNonDecoratorTokenPosOfNode(node, sourceFile) { + if (nodeIsMissing(node) || !node.decorators) { + return getTokenPosOfNode(node, sourceFile); + } + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + } + ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + if (nodeIsMissing(node)) { + return ""; + } + var text = sourceFile.text; + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + } + ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; + function getTextOfNodeFromSourceText(sourceText, node) { + if (nodeIsMissing(node)) { + return ""; + } + return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + } + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + } + ts.getTextOfNode = getTextOfNode; + function getLiteralText(node, sourceFile, languageVersion) { + if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + return getQuotedEscapedLiteralText('"', node.text, '"'); + } + if (!nodeIsSynthesized(node) && node.parent) { + var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); + if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { + return node.text; } - if (numberOfDigits === 0) { - return -1; + return text; + } + switch (node.kind) { + case 9: + return getQuotedEscapedLiteralText('"', node.text, '"'); + case 12: + return getQuotedEscapedLiteralText("`", node.text, "`"); + case 13: + return getQuotedEscapedLiteralText("`", node.text, "${"); + case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: + return getQuotedEscapedLiteralText("}", node.text, "`"); + case 8: + return node.text; + } + ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + } + ts.getLiteralText = getLiteralText; + function isBinaryOrOctalIntegerLiteral(node, text) { + if (node.kind === 8 && text.length > 1) { + switch (text.charCodeAt(1)) { + case 98: + case 66: + case 111: + case 79: + return true; } - return value; } - function scan() { - startPos = pos; - hasExtendedUnicodeEscape = false; - precedingLineBreak = false; - tokenIsUnterminated = false; - while (true) { - tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var ch = text.charCodeAt(pos); - if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - if (skipTrivia) { - continue; - } - else { - return token = 6; - } - } - switch (ch) { - case 10: - case 13: - precedingLineBreak = true; - if (skipTrivia) { - pos++; - continue; - } - else { - if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { - pos += 2; - } - else { - pos++; - } - return token = 4; - } - case 9: - case 11: - case 12: - case 32: - if (skipTrivia) { - pos++; - continue; - } - else { - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - } - case 33: - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; - } - return pos += 2, token = 31; - } - pos++; - return token = 49; - case 34: - case 39: - tokenValue = scanString(); - return token = 9; - case 96: - return token = scanTemplateAndSetTokenValue(); - case 37: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; - } - pos++; - return token = 40; - case 38: - if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; - } - pos++; - return token = 46; - case 40: - pos++; - return token = 17; - case 41: - pos++; - return token = 18; - case 42: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; - } - if (text.charCodeAt(pos + 1) === 42) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; - } - return pos += 2, token = 38; - } - pos++; - return token = 37; - case 43: - if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - pos++; - return token = 35; - case 44: - pos++; - return token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 46: - if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); - return token = 8; - } - if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; - } - pos++; - return token = 21; - case 47: - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < end) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - if (skipTrivia) { - continue; - } - else { - return token = 2; - } - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - var commentClosed = false; - while (pos < end) { - var ch_2 = text.charCodeAt(pos); - if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - commentClosed = true; - break; - } - if (isLineBreak(ch_2)) { - precedingLineBreak = true; - } - pos++; - } - if (!commentClosed) { - error(ts.Diagnostics.Asterisk_Slash_expected); - } - if (skipTrivia) { - continue; - } - else { - tokenIsUnterminated = !commentClosed; - return token = 3; - } - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; - } - pos++; - return token = 39; - case 48: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { - pos += 2; - var value = scanMinimumNumberOfHexDigits(1); - if (value < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { - pos += 2; - var value = scanBinaryOrOctalDigits(2); - if (value < 0) { - error(ts.Diagnostics.Binary_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { - pos += 2; - var value = scanBinaryOrOctalDigits(8); - if (value < 0) { - error(ts.Diagnostics.Octal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - return token = 8; - } - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - tokenValue = scanNumber(); - return token = 8; - case 58: - pos++; - return token = 54; - case 59: - pos++; - return token = 23; - case 60: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 60) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; - } - return pos += 2, token = 43; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; - } - if (languageVariant === 1 && - text.charCodeAt(pos + 1) === 47 && - text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; - } - pos++; - return token = 25; - case 61: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; - } - return pos += 2, token = 30; - } - if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; - } - pos++; - return token = 56; - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - pos++; - return token = 27; - case 63: - pos++; - return token = 53; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 94: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; - case 123: - pos++; - return token = 15; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; - } - pos++; - return token = 47; - case 125: - pos++; - return token = 16; - case 126: - pos++; - return token = 50; - case 64: - pos++; - return token = 55; - case 92: - var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - default: - if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else if (isWhiteSpaceSingleLine(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - } - } + return false; + } + ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; + function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { + return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + } + function escapeIdentifier(identifier) { + return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + } + ts.escapeIdentifier = escapeIdentifier; + function unescapeIdentifier(identifier) { + return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + } + ts.unescapeIdentifier = unescapeIdentifier; + function makeIdentifierFromModuleName(moduleName) { + return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + } + ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; + function isBlockOrCatchScoped(declaration) { + return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || + isCatchClauseVariableDeclaration(declaration); + } + ts.isBlockOrCatchScoped = isBlockOrCatchScoped; + function isAmbientModule(node) { + return node && node.kind === 226 && + (node.name.kind === 9 || isGlobalScopeAugmentation(node)); + } + ts.isAmbientModule = isAmbientModule; + function isShorthandAmbientModuleSymbol(moduleSymbol) { + return isShorthandAmbientModule(moduleSymbol.valueDeclaration); + } + ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; + function isShorthandAmbientModule(node) { + return node.kind === 226 && (!node.body); + } + function isBlockScopedContainerTopLevel(node) { + return node.kind === 256 || + node.kind === 226 || + isFunctionLike(node); + } + ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; + function isGlobalScopeAugmentation(module) { + return !!(module.flags & 512); + } + ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; + function isExternalModuleAugmentation(node) { + if (!node || !isAmbientModule(node)) { + return false; } - function reScanGreaterToken() { - if (token === 27) { - if (text.charCodeAt(pos) === 62) { - if (text.charCodeAt(pos + 1) === 62) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; - } - return pos += 2, token = 45; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - pos++; - return token = 44; - } - if (text.charCodeAt(pos) === 61) { - pos++; - return token = 29; - } + switch (node.parent.kind) { + case 256: + return ts.isExternalModule(node.parent); + case 227: + return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); + } + return false; + } + ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isBlockScope(node, parentNode) { + switch (node.kind) { + case 256: + case 228: + case 252: + case 226: + case 207: + case 208: + case 209: + case 149: + case 148: + case 150: + case 151: + case 221: + case 180: + case 181: + return true; + case 200: + return parentNode && !isFunctionLike(parentNode); + } + return false; + } + ts.isBlockScope = isBlockScope; + function getEnclosingBlockScopeContainer(node) { + var current = node.parent; + while (current) { + if (isBlockScope(current, current.parent)) { + return current; } - return token; + current = current.parent; } - function reScanSlashToken() { - if (token === 39 || token === 61) { - var p = tokenPos + 1; - var inEscape = false; - var inCharacterClass = false; - while (true) { - if (p >= end) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - var ch = text.charCodeAt(p); - if (isLineBreak(ch)) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - if (inEscape) { - inEscape = false; - } - else if (ch === 47 && !inCharacterClass) { - p++; - break; - } - else if (ch === 91) { - inCharacterClass = true; - } - else if (ch === 92) { - inEscape = true; - } - else if (ch === 93) { - inCharacterClass = false; - } - p++; - } - while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { - p++; - } - pos = p; - tokenValue = text.substring(tokenPos, pos); - token = 10; + } + ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; + function isCatchClauseVariableDeclaration(declaration) { + return declaration && + declaration.kind === 219 && + declaration.parent && + declaration.parent.kind === 252; + } + ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; + function declarationNameToString(name) { + return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + } + ts.declarationNameToString = declarationNameToString; + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeFromMessageChain(node, messageChain) { + var sourceFile = getSourceFileOfNode(node); + var span = getErrorSpanForNode(sourceFile, node); + return { + file: sourceFile, + start: span.start, + length: span.length, + code: messageChain.code, + category: messageChain.category, + messageText: messageChain.next ? messageChain : messageChain.messageText + }; + } + ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function getSpanOfTokenAtPosition(sourceFile, pos) { + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); + scanner.scan(); + var start = scanner.getTokenPos(); + return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + } + ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; + function getErrorSpanForArrowFunction(sourceFile, node) { + var pos = ts.skipTrivia(sourceFile.text, node.pos); + if (node.body && node.body.kind === 200) { + var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; + var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; + if (startLine < endLine) { + return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); } - return token; } - function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); - pos = tokenPos; - return token = scanTemplateAndSetTokenValue(); + return ts.createTextSpanFromBounds(pos, node.end); + } + function getErrorSpanForNode(sourceFile, node) { + var errorNode = node; + switch (node.kind) { + case 256: + 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 219: + case 170: + case 222: + case 193: + case 223: + case 226: + case 225: + case 255: + case 221: + case 180: + case 148: + case 150: + case 151: + case 224: + errorNode = node.name; + break; + case 181: + return getErrorSpanForArrowFunction(sourceFile, node); } - function reScanJsxToken() { - pos = tokenPos = startPos; - return token = scanJsxToken(); + if (errorNode === undefined) { + return getSpanOfTokenAtPosition(sourceFile, node.pos); } - function scanJsxToken() { - startPos = tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var char = text.charCodeAt(pos); - if (char === 60) { - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - return token = 26; + var pos = nodeIsMissing(errorNode) + ? errorNode.pos + : ts.skipTrivia(sourceFile.text, errorNode.pos); + return ts.createTextSpanFromBounds(pos, errorNode.end); + } + ts.getErrorSpanForNode = getErrorSpanForNode; + function isExternalOrCommonJsModule(file) { + return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + } + ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; + function isDeclarationFile(file) { + return file.isDeclarationFile; + } + ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return node.kind === 225 && isConst(node); + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; + function isConst(node) { + return !!(ts.getCombinedNodeFlags(node) & 2) + || !!(ts.getCombinedModifierFlags(node) & 2048); + } + ts.isConst = isConst; + function isLet(node) { + return !!(ts.getCombinedNodeFlags(node) & 1); + } + ts.isLet = isLet; + function isSuperCall(n) { + return n.kind === 175 && n.expression.kind === 96; + } + ts.isSuperCall = isSuperCall; + function isPrologueDirective(node) { + return node.kind === 203 && node.expression.kind === 9; + } + ts.isPrologueDirective = isPrologueDirective; + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + } + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; + function getLeadingCommentRangesOfNodeFromText(node, text) { + return ts.getLeadingCommentRanges(text, node.pos); + } + ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; + function getJsDocComments(node, sourceFileOfNode) { + return getJsDocCommentsFromText(node, sourceFileOfNode.text); + } + ts.getJsDocComments = getJsDocComments; + function getJsDocCommentsFromText(node, text) { + var commentRanges = (node.kind === 143 || + node.kind === 142 || + node.kind === 180 || + node.kind === 181) ? + ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : + getLeadingCommentRangesOfNodeFromText(node, text); + return ts.filter(commentRanges, isJsDocComment); + function isJsDocComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 42 && + text.charCodeAt(comment.pos + 3) !== 47; + } + } + ts.getJsDocCommentsFromText = getJsDocCommentsFromText; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + function isPartOfTypeNode(node) { + if (155 <= node.kind && node.kind <= 167) { + return true; + } + switch (node.kind) { + case 118: + case 131: + case 133: + case 121: + case 134: + case 136: + case 128: + return true; + case 104: + return node.parent.kind !== 184; + case 195: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 70: + if (node.parent.kind === 140 && node.parent.right === node) { + node = node.parent; } - pos++; - return token = 25; - } - if (char === 123) { - pos++; - return token = 15; - } - while (pos < end) { - pos++; - char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { - break; + else if (node.parent.kind === 173 && node.parent.name === node) { + node = node.parent; + } + ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140: + case 173: + case 98: + var parent_2 = node.parent; + if (parent_2.kind === 159) { + return false; + } + if (155 <= parent_2.kind && parent_2.kind <= 167) { + return true; } + switch (parent_2.kind) { + case 195: + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); + case 142: + return node === parent_2.constraint; + case 146: + case 145: + case 143: + case 219: + return node === parent_2.type; + case 221: + case 180: + case 181: + case 149: + case 148: + case 147: + case 150: + case 151: + return node === parent_2.type; + case 152: + case 153: + case 154: + return node === parent_2.type; + case 178: + return node === parent_2.type; + case 175: + case 176: + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; + case 177: + return false; + } + } + return false; + } + ts.isPartOfTypeNode = isPartOfTypeNode; + function forEachReturnStatement(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 212: + return visitor(node); + case 228: + case 200: + case 204: + case 205: + case 206: + case 207: + case 208: + case 209: + case 213: + case 214: + case 249: + case 250: + case 215: + case 217: + case 252: + return ts.forEachChild(node, traverse); } - return token = 244; } - function scanJsxIdentifier() { - if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { - pos++; + } + ts.forEachReturnStatement = forEachReturnStatement; + function forEachYieldExpression(body, visitor) { + return traverse(body); + function traverse(node) { + switch (node.kind) { + case 191: + visitor(node); + var operand = node.expression; + if (operand) { + traverse(operand); } - else { - break; + case 225: + case 223: + case 226: + case 224: + case 222: + case 193: + return; + default: + if (isFunctionLike(node)) { + var name_4 = node.name; + if (name_4 && name_4.kind === 141) { + traverse(name_4.expression); + return; + } + } + else if (!isPartOfTypeNode(node)) { + ts.forEachChild(node, traverse); } - } - tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); } - return token; } - function scanJsxAttributeValue() { - startPos = pos; - switch (text.charCodeAt(pos)) { - case 34: - case 39: - tokenValue = scanString(false); - return token = 9; - default: - return scan(); + } + ts.forEachYieldExpression = forEachYieldExpression; + function isVariableLike(node) { + if (node) { + switch (node.kind) { + case 170: + case 255: + case 143: + case 253: + case 146: + case 145: + case 254: + case 219: + return true; } } - function scanJSDocToken() { - if (pos >= end) { - return token = 1; + return false; + } + ts.isVariableLike = isVariableLike; + function isAccessor(node) { + return node && (node.kind === 150 || node.kind === 151); + } + ts.isAccessor = isAccessor; + function isClassLike(node) { + return node && (node.kind === 222 || node.kind === 193); + } + ts.isClassLike = isClassLike; + function isFunctionLike(node) { + return node && isFunctionLikeKind(node.kind); + } + ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 149: + case 180: + case 221: + case 181: + case 148: + case 147: + case 150: + case 151: + case 152: + case 153: + case 154: + case 157: + case 158: + return true; + } + return false; + } + ts.isFunctionLikeKind = isFunctionLikeKind; + function introducesArgumentsExoticObject(node) { + switch (node.kind) { + case 148: + case 147: + case 149: + case 150: + case 151: + case 221: + case 180: + return true; + } + return false; + } + ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; + function isIterationStatement(node, lookInLabeledStatements) { + switch (node.kind) { + case 207: + case 208: + case 209: + case 205: + case 206: + return true; + case 215: + return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); + } + return false; + } + ts.isIterationStatement = isIterationStatement; + function isFunctionBlock(node) { + return node && node.kind === 200 && isFunctionLike(node.parent); + } + ts.isFunctionBlock = isFunctionBlock; + function isObjectLiteralMethod(node) { + return node && node.kind === 148 && node.parent.kind === 172; + } + ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 148 && + (node.parent.kind === 172 || + node.parent.kind === 193); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; + function isIdentifierTypePredicate(predicate) { + return predicate && predicate.kind === 1; + } + ts.isIdentifierTypePredicate = isIdentifierTypePredicate; + function isThisTypePredicate(predicate) { + return predicate && predicate.kind === 0; + } + ts.isThisTypePredicate = isThisTypePredicate; + function getContainingFunction(node) { + while (true) { + node = node.parent; + if (!node || isFunctionLike(node)) { + return node; } - startPos = pos; - tokenPos = pos; - var ch = text.charCodeAt(pos); - switch (ch) { - case 9: - case 11: - case 12: - case 32: - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - case 64: - pos++; - return token = 55; - case 10: - case 13: - pos++; - return token = 4; - case 42: - pos++; - return token = 37; - case 123: - pos++; - return token = 15; - case 125: - pos++; - return token = 16; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 61: - pos++; - return token = 56; - case 44: - pos++; - return token = 24; + } + } + ts.getContainingFunction = getContainingFunction; + function getContainingClass(node) { + while (true) { + node = node.parent; + if (!node || isClassLike(node)) { + return node; } - if (isIdentifierStart(ch, 2)) { - pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { - pos++; - } - return token = 69; + } + } + ts.getContainingClass = getContainingClass; + function getThisContainer(node, includeArrowFunctions) { + while (true) { + node = node.parent; + if (!node) { + return undefined; } - else { - return pos += 1, token = 0; + switch (node.kind) { + case 141: + if (isClassLike(node.parent.parent)) { + return node; + } + node = node.parent; + break; + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; + case 181: + if (!includeArrowFunctions) { + continue; + } + case 221: + case 180: + case 226: + case 146: + case 145: + case 148: + case 147: + case 149: + case 150: + case 151: + case 152: + case 153: + case 154: + case 225: + case 256: + return node; } } - function speculationHelper(callback, isLookahead) { - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var saveTokenValue = tokenValue; - var savePrecedingLineBreak = precedingLineBreak; - var result = callback(); - if (!result || isLookahead) { - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; + } + ts.getThisContainer = getThisContainer; + function getSuperContainer(node, stopOnFunctions) { + while (true) { + node = node.parent; + if (!node) { + return node; + } + switch (node.kind) { + case 141: + node = node.parent; + break; + case 221: + case 180: + case 181: + if (!stopOnFunctions) { + continue; + } + case 146: + case 145: + case 148: + case 147: + case 149: + case 150: + case 151: + return node; + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + node = node.parent.parent; + } + else if (isClassElement(node.parent)) { + node = node.parent; + } + break; } - return result; } - function scanRange(start, length, callback) { - var saveEnd = end; - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var savePrecedingLineBreak = precedingLineBreak; - var saveTokenValue = tokenValue; - var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; - var saveTokenIsUnterminated = tokenIsUnterminated; - setText(text, start, length); - var result = callback(); - end = saveEnd; - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - precedingLineBreak = savePrecedingLineBreak; - tokenValue = saveTokenValue; - hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; - tokenIsUnterminated = saveTokenIsUnterminated; - return result; + } + ts.getSuperContainer = getSuperContainer; + function getImmediatelyInvokedFunctionExpression(func) { + if (func.kind === 180 || func.kind === 181) { + var prev = func; + var parent_3 = func.parent; + while (parent_3.kind === 179) { + prev = parent_3; + parent_3 = parent_3.parent; + } + if (parent_3.kind === 175 && parent_3.expression === prev) { + return parent_3; + } } - function lookAhead(callback) { - return speculationHelper(callback, true); + } + ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; + function isSuperProperty(node) { + var kind = node.kind; + return (kind === 173 || kind === 174) + && node.expression.kind === 96; + } + ts.isSuperProperty = isSuperProperty; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 156: + return node.typeName; + case 195: + ts.Debug.assert(isEntityNameExpression(node.expression)); + return node.expression; + case 70: + case 140: + return node; + } } - function tryScan(callback) { - return speculationHelper(callback, false); + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; + function isCallLikeExpression(node) { + switch (node.kind) { + case 175: + case 176: + case 177: + case 144: + return true; + default: + return false; } - function getText() { - return text; + } + ts.isCallLikeExpression = isCallLikeExpression; + function getInvokedExpression(node) { + if (node.kind === 177) { + return node.tag; } - function setText(newText, start, length) { - text = newText || ""; - end = length === undefined ? text.length : start + length; - setTextPos(start || 0); + return node.expression; + } + ts.getInvokedExpression = getInvokedExpression; + function nodeCanBeDecorated(node) { + switch (node.kind) { + case 222: + return true; + case 146: + return node.parent.kind === 222; + case 150: + case 151: + case 148: + return node.body !== undefined + && node.parent.kind === 222; + case 143: + return node.parent.body !== undefined + && (node.parent.kind === 149 + || node.parent.kind === 148 + || node.parent.kind === 151) + && node.parent.parent.kind === 222; } - function setOnError(errorCallback) { - onError = errorCallback; + return false; + } + ts.nodeCanBeDecorated = nodeCanBeDecorated; + function nodeIsDecorated(node) { + return node.decorators !== undefined + && nodeCanBeDecorated(node); + } + ts.nodeIsDecorated = nodeIsDecorated; + function nodeOrChildIsDecorated(node) { + return nodeIsDecorated(node) || childIsDecorated(node); + } + ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; + function childIsDecorated(node) { + switch (node.kind) { + case 222: + return ts.forEach(node.members, nodeOrChildIsDecorated); + case 148: + case 151: + return ts.forEach(node.parameters, nodeIsDecorated); } - function setScriptTarget(scriptTarget) { - languageVersion = scriptTarget; + } + ts.childIsDecorated = childIsDecorated; + function isJSXTagName(node) { + var parent = node.parent; + if (parent.kind === 244 || + parent.kind === 243 || + parent.kind === 245) { + return parent.tagName === node; } - function setLanguageVariant(variant) { - languageVariant = variant; + return false; + } + ts.isJSXTagName = isJSXTagName; + function isPartOfExpression(node) { + switch (node.kind) { + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: + case 171: + case 172: + case 173: + case 174: + case 175: + case 176: + case 177: + case 196: + case 178: + case 197: + case 179: + case 180: + case 193: + case 181: + case 184: + case 182: + case 183: + case 186: + case 187: + case 188: + case 189: + case 192: + case 190: + case 12: + case 194: + case 242: + case 243: + case 191: + case 185: + return true; + case 140: + while (node.parent.kind === 140) { + node = node.parent; + } + return node.parent.kind === 159 || isJSXTagName(node); + case 70: + if (node.parent.kind === 159 || isJSXTagName(node)) { + return true; + } + case 8: + case 9: + case 98: + var parent_4 = node.parent; + switch (parent_4.kind) { + case 219: + case 143: + case 146: + case 145: + case 255: + case 253: + case 170: + return parent_4.initializer === node; + case 203: + case 204: + case 205: + case 206: + case 212: + case 213: + case 214: + case 249: + case 216: + case 214: + return parent_4.expression === node; + case 207: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || + forStatement.condition === node || + forStatement.incrementor === node; + case 208: + case 209: + var forInStatement = parent_4; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || + forInStatement.expression === node; + case 178: + case 196: + return node === parent_4.expression; + case 198: + return node === parent_4.expression; + case 141: + return node === parent_4.expression; + case 144: + case 248: + case 247: + return true; + case 195: + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); + default: + if (isPartOfExpression(parent_4)) { + return true; + } + } } - function setTextPos(textPos) { - ts.Debug.assert(textPos >= 0); - pos = textPos; - startPos = textPos; - tokenPos = textPos; - token = 0; - precedingLineBreak = false; - tokenValue = undefined; - hasExtendedUnicodeEscape = false; - tokenIsUnterminated = false; + return false; + } + ts.isPartOfExpression = isPartOfExpression; + function isInstantiatedModule(node, preserveConstEnums) { + var moduleState = ts.getModuleInstanceState(node); + return moduleState === 1 || + (preserveConstEnums && moduleState === 2); + } + ts.isInstantiatedModule = isInstantiatedModule; + function isExternalModuleImportEqualsDeclaration(node) { + return node.kind === 230 && node.moduleReference.kind === 241; + } + ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; + function getExternalModuleImportEqualsDeclarationExpression(node) { + ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); + return node.moduleReference.expression; + } + ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; + function isInternalModuleImportEqualsDeclaration(node) { + return node.kind === 230 && node.moduleReference.kind !== 241; + } + ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; + function isSourceFileJavaScript(file) { + return isInJavaScriptFile(file); + } + ts.isSourceFileJavaScript = isSourceFileJavaScript; + function isInJavaScriptFile(node) { + return node && !!(node.flags & 1048576); + } + ts.isInJavaScriptFile = isInJavaScriptFile; + function isRequireCall(expression, checkArgumentIsStringLiteral) { + var isRequire = expression.kind === 175 && + expression.expression.kind === 70 && + expression.expression.text === "require" && + expression.arguments.length === 1; + return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + } + ts.isRequireCall = isRequireCall; + function isSingleOrDoubleQuote(charCode) { + return charCode === 39 || charCode === 34; + } + ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; + function isDeclarationOfFunctionExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219) { + var declaration = s.valueDeclaration; + return declaration.initializer && declaration.initializer.kind === 180; } + return false; } - ts.createScanner = createScanner; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file - }, - { - name: "inlineSourceMap", - type: "boolean" - }, - { - name: "inlineSources", - type: "boolean" - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2 - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true + ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + function getSpecialPropertyAssignmentKind(expression) { + if (!isInJavaScriptFile(expression)) { + return 0; + } + if (expression.kind !== 188) { + return 0; + } + var expr = expression; + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { + return 0; + } + var lhs = expr.left; + if (lhs.expression.kind === 70) { + var lhsId = lhs.expression; + if (lhsId.text === "exports") { + return 1; } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true + else if (lhsId.text === "module" && lhs.name.text === "exports") { + return 2; } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.ts", - "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", - "es2016.array.include": "lib.es2016.array.include.d.ts", - "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } - ]; - ts.typingOptionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean" - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" + else if (lhs.expression.kind === 98) { + return 4; + } + else if (lhs.expression.kind === 173) { + var innerPropertyAccess = lhs.expression; + if (innerPropertyAccess.expression.kind === 70) { + var innerPropertyAccessIdentifier = innerPropertyAccess.expression; + if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { + return 1; + } + if (innerPropertyAccess.name.text === "prototype") { + return 3; + } } } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false - }; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; + return 0; + } + ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; + function getExternalModuleName(node) { + if (node.kind === 231) { + return node.moduleSpecifier; } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; + if (node.kind === 230) { + var reference = node.moduleReference; + if (reference.kind === 241) { + return reference.expression; } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); } - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - var key = trimString((value || "")).toLowerCase(); - var map = opt.type; - if (key in map) { - return map[key]; + if (node.kind === 237) { + return node.moduleSpecifier; } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + if (node.kind === 226 && node.name.kind === 9) { + return node.name; } } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; + ts.getExternalModuleName = getExternalModuleName; + function getNamespaceDeclarationNode(node) { + if (node.kind === 230) { + return node; } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + var importClause = node.importClause; + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { + return importClause.namedBindings; } } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } + ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; + function isDefaultImport(node) { + return node.kind === 231 + && node.importClause + && !!node.importClause.name; + } + ts.isDefaultImport = isDefaultImport; + function hasQuestionToken(node) { + if (node) { + switch (node.kind) { + case 143: + case 148: + case 147: + case 254: + case 253: + case 146: + case 145: + return node.questionToken !== undefined; } - parseStrings(args); } + return false; } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); + ts.hasQuestionToken = hasQuestionToken; + function isJSDocConstructSignature(node) { + return node.kind === 269 && + node.parameters.length > 0 && + node.parameters[0].type.kind === 271; } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + ts.isJSDocConstructSignature = isJSDocConstructSignature; + function getJSDocTag(node, kind, checkParentVariableStatement) { + if (!node) { + return undefined; } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; + var jsDocTags = getJSDocTags(node, checkParentVariableStatement); + if (!jsDocTags) { + return undefined; } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; + for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { + var tag = jsDocTags_1[_i]; + if (tag.kind === kind) { + return tag; } } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } + } + function append(previous, additional) { + if (additional) { + if (!previous) { + previous = []; + } + for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { + var x = additional_1[_i]; + previous.push(x); } - return undefined; } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_5] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_5] = convertedValue; - } - else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } + return previous; + } + function getJSDocComments(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); + } + ts.getJSDocComments = getJSDocComments; + function getJSDocTags(node, checkParentVariableStatement) { + return getJSDocs(node, checkParentVariableStatement, function (docs) { + var result = []; + for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { + var doc = docs_1[_i]; + if (doc.tags) { + result.push.apply(result, doc.tags); } } return result; - } + }, function (tags) { return tags; }); } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; + function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { + var result = undefined; + if (checkParentVariableStatement) { + var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && + (node.parent).initializer === node && + node.parent.parent.parent.kind === 201; + var isVariableOfVariableDeclarationStatement = isVariableLike(node) && + node.parent.parent.kind === 201; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : + isVariableOfVariableDeclarationStatement ? node.parent.parent : + undefined; + if (variableStatementNode) { + result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === 226 && + node.parent && node.parent.kind === 226) { + result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); + } + var parent_5 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && + parent_5.kind === 188 && + parent_5.operatorToken.kind === 57 && + parent_5.parent.kind === 203; + if (isSourceOfAssignmentExpressionStatement) { + result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); + } + var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; + if (isPropertyAssignmentExpression) { + result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === 143) { + var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); + if (paramTags) { + result = append(result, getTags(paramTags)); + } } } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - var errors = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typingOptions: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; + if (isVariableLike(node) && node.initializer) { + result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + if (node.jsDocComments) { + if (result) { + result = append(result, getDocs(node.jsDocComments)); } else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; + return getDocs(node.jsDocComments); } - if (files && !json["files"]) { - json["files"] = files; + } + return result; + } + function getJSDocParameterTag(param, checkParentVariableStatement) { + var func = param.parent; + var tags = getJSDocTags(func, checkParentVariableStatement); + if (!param.name) { + var i = func.parameters.indexOf(param); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275; }); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; } - options = ts.assign({}, baseOptions, options); } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typingOptions: typingOptions, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; + else if (param.name.kind === 70) { + var name_5 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_5; }); + if (paramTags) { + return paramTags; } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + else { + return undefined; + } + } + function getJSDocTypeTag(node) { + return getJSDocTag(node, 277, false); + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocReturnTag(node) { + return getJSDocTag(node, 276, true); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getJSDocTag(node, 278, false); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getCorrespondingJSDocParameterTag(parameter) { + if (parameter.name && parameter.name.kind === 70) { + var parameterName = parameter.name.text; + var jsDocTags = getJSDocTags(parameter.parent, true); + if (!jsDocTags) { + return undefined; } - else { - excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); + for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { + var tag = jsDocTags_2[_i]; + if (tag.kind === 275) { + var parameterTag = tag; + if (parameterTag.parameterName.text === parameterName) { + return parameterTag; + } } } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; } - return false; + return undefined; } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; + ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; + function hasRestParameter(s) { + return isRestParameter(ts.lastOrUndefined(s.parameters)); } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; + ts.hasRestParameter = hasRestParameter; + function hasDeclaredRestParameter(s) { + return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); } - ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; + ts.hasDeclaredRestParameter = hasDeclaredRestParameter; + function isRestParameter(node) { + if (node && (node.flags & 1048576)) { + if (node.type && node.type.kind === 270) { + return true; + } + var paramTag = getCorrespondingJSDocParameterTag(node); + if (paramTag && paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 270; + } + } + return isDeclaredRestParam(node); } - function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; - convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); - return options; + ts.isRestParameter = isRestParameter; + function isDeclaredRestParam(node) { + return node && node.dotDotDotToken !== undefined; } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; + ts.isDeclaredRestParam = isDeclaredRestParam; + function isAssignmentTarget(node) { + while (node.parent.kind === 179) { + node = node.parent; } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + while (true) { + var parent_6 = node.parent; + if (parent_6.kind === 171 || parent_6.kind === 192) { + node = parent_6; + continue; } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + if (parent_6.kind === 253 || parent_6.kind === 254) { + node = parent_6.parent; + continue; } + return parent_6.kind === 188 && + isAssignmentOperator(parent_6.operatorToken.kind) && + parent_6.left === node || + (parent_6.kind === 208 || parent_6.kind === 209) && + parent_6.initializer === node; } } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); + ts.isAssignmentTarget = isAssignmentTarget; + function isNodeDescendantOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); + return false; + } + ts.isNodeDescendantOf = isNodeDescendantOf; + function isInAmbientContext(node) { + while (node) { + if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { + return true; } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } + node = node.parent; + } + return false; + } + ts.isInAmbientContext = isInAmbientContext; + function isDeclarationName(name) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + return false; + } + var parent = name.parent; + if (parent.kind === 235 || parent.kind === 239) { + if (parent.propertyName) { + return true; } - return value; } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + if (isDeclaration(parent)) { + return parent.name === name; } + return false; } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + ts.isDeclarationName = isDeclarationName; + function isLiteralComputedPropertyDeclarationName(node) { + return (node.kind === 9 || node.kind === 8) && + node.parent.kind === 141 && + isDeclaration(node.parent.parent); + } + ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; + function isIdentifierName(node) { + var parent = node.parent; + switch (parent.kind) { + case 146: + case 145: + case 148: + case 147: + case 150: + case 151: + case 255: + case 253: + case 173: + return parent.name === node; + case 140: + if (parent.right === node) { + while (parent.kind === 140) { + parent = parent.parent; + } + return parent.kind === 159; + } + return false; + case 170: + case 235: + return parent.propertyName === node; + case 239: + return true; } + return false; } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + ts.isIdentifierName = isIdentifierName; + function isAliasSymbolDeclaration(node) { + return node.kind === 230 || + node.kind === 229 || + node.kind === 232 && !!node.name || + node.kind === 233 || + node.kind === 235 || + node.kind === 239 || + node.kind === 236 && exportAssignmentIsAlias(node); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; + function exportAssignmentIsAlias(node) { + return isEntityNameExpression(node.expression); } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; + ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getClassExtendsHeritageClauseElement(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + } + ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; + function getClassImplementsHeritageClauseElements(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 107); + return heritageClause ? heritageClause.types : undefined; + } + ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + function getInterfaceBaseTypeNodes(node) { + var heritageClause = getHeritageClause(node.heritageClauses, 84); + return heritageClause ? heritageClause.types : undefined; + } + ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; + function getHeritageClause(clauses, kind) { + if (clauses) { + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; + if (clause.token === kind) { + return clause; } } } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; + return undefined; } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + ts.getHeritageClause = getHeritageClause; + function tryResolveScriptReference(host, sourceFile, reference) { + if (!host.getCompilerOptions().noResolve) { + var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); + return host.getSourceFile(referenceFileName); + } + } + ts.tryResolveScriptReference = tryResolveScriptReference; + function getAncestor(node, kind) { + while (node) { + if (node.kind === kind) { + return node; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + node = node.parent; + } + return undefined; + } + ts.getAncestor = getAncestor; + function getFileReferenceFromReferencePath(comment, commentRange) { + var simpleReferenceRegEx = /^\/\/\/\s*/gim; + if (simpleReferenceRegEx.test(comment)) { + if (isNoDefaultLibRegEx.test(comment)) { + return { + isNoDefaultLib: true + }; } else { - validSpecs.push(spec); + var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); + if (refMatchResult || refLibResult) { + var start = commentRange.pos; + var end = commentRange.end; + return { + fileReference: { + pos: start, + end: end, + fileName: (refMatchResult || refLibResult)[3] + }, + isNoDefaultLib: false, + isTypeReferenceDirective: !!refLibResult + }; + } + return { + diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, + isNoDefaultLib: false + }; } } - return validSpecs; + return undefined; } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - var recursiveKeys = []; - for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { - var file = include_1[_i]; - var name_6 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_6)) { - continue; - } - var match = wildcardDirectoryPattern.exec(name_6); - if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_6) ? 1 : 0; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } + ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; + function isKeyword(token) { + return 71 <= token && token <= 139; + } + ts.isKeyword = isKeyword; + function isTrivia(token) { + return 2 <= token && token <= 7; + } + ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; + function isStringOrNumericLiteral(kind) { + return kind === 9 || kind === 8; + } + ts.isStringOrNumericLiteral = isStringOrNumericLiteral; + function hasDynamicName(declaration) { + return declaration.name && isDynamicName(declaration.name); + } + ts.hasDynamicName = hasDynamicName; + function isDynamicName(name) { + return name.kind === 141 && + !isStringOrNumericLiteral(name.expression.kind) && + !isWellKnownSymbolSyntactically(name.expression); + } + ts.isDynamicName = isDynamicName; + function isWellKnownSymbolSyntactically(node) { + return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + } + ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; + function getPropertyNameForPropertyNameNode(name) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { + return name.text; + } + if (name.kind === 141) { + var nameExpression = name.expression; + if (isWellKnownSymbolSyntactically(nameExpression)) { + var rightHandSideName = nameExpression.name.text; + return getPropertyNameForKnownSymbolName(rightHandSideName); } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } + else if (nameExpression.kind === 9 || nameExpression.kind === 8) { + return nameExpression.text; } } - return wildcardDirectories; + return undefined; } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; + function getPropertyNameForKnownSymbolName(symbolName) { + return "__@" + symbolName; + } + ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; + function isESSymbolIdentifier(node) { + return node.kind === 70 && node.text === "Symbol"; + } + ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; + function isModifierKind(token) { + switch (token) { + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: + case 113: + case 111: + case 112: + case 129: + case 114: return true; - } } return false; } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } + ts.isModifierKind = isModifierKind; + function isParameterDeclaration(node) { + var root = getRootDeclaration(node); + return root.kind === 143; } - function addFileToOutput(output, file) { - output.push(file); - return output; + ts.isParameterDeclaration = isParameterDeclaration; + function getRootDeclaration(node) { + while (node.kind === 170) { + node = node.parent.parent; + } + return node; } - function caseSensitiveKeyMapper(key) { - return key; + ts.getRootDeclaration = getRootDeclaration; + function nodeStartsNewLexicalEnvironment(node) { + var kind = node.kind; + return kind === 149 + || kind === 180 + || kind === 221 + || kind === 181 + || kind === 148 + || kind === 150 + || kind === 151 + || kind === 226 + || kind === 256; } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); + ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; + function nodeIsSynthesized(node) { + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); } -})(ts || (ts = {})); -var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { - var inferredTypings = ts.createMap(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - 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(typingOptions.include); - exclude = typingOptions.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { - 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); - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; - } - } - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; - delete inferredTypings[excludeTypingName]; + ts.nodeIsSynthesized = nodeIsSynthesized; + function getOriginalNode(node) { + if (node) { + while (node.original !== undefined) { + node = node.original; } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } + } + return node; + } + ts.getOriginalNode = getOriginalNode; + function isParseTreeNode(node) { + return (node.flags & 8) === 0; + } + ts.isParseTreeNode = isParseTreeNode; + function getParseTreeNode(node, nodeTest) { + if (isParseTreeNode(node)) { + return node; + } + node = getOriginalNode(node); + if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { + return node; + } + return undefined; + } + ts.getParseTreeNode = getParseTreeNode; + function getOriginalSourceFiles(sourceFiles) { + var originalSourceFiles = []; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; + var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); + if (originalSourceFile) { + originalSourceFiles.push(originalSourceFile); } - 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; - } + } + return originalSourceFiles; + } + ts.getOriginalSourceFiles = getOriginalSourceFiles; + function getOriginalNodeId(node) { + node = getOriginalNode(node); + return node ? ts.getNodeId(node) : 0; + } + ts.getOriginalNodeId = getOriginalNodeId; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(ts.Associativity || (ts.Associativity = {})); + var Associativity = ts.Associativity; + function getExpressionAssociativity(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + return getOperatorAssociativity(expression.kind, operator, hasArguments); + } + ts.getExpressionAssociativity = getExpressionAssociativity; + function getOperatorAssociativity(kind, operator, hasArguments) { + switch (kind) { + case 176: + return hasArguments ? 0 : 1; + case 186: + case 183: + case 184: + case 182: + case 185: + case 189: + case 191: + return 1; + case 188: + switch (operator) { + case 39: + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 1; } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - filesToWatch.push(jsonPath); - 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)); - } + } + return 0; + } + ts.getOperatorAssociativity = getOperatorAssociativity; + function getExpressionPrecedence(expression) { + var operator = getOperator(expression); + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + return getOperatorPrecedence(expression.kind, operator, hasArguments); + } + ts.getExpressionPrecedence = getExpressionPrecedence; + function getOperator(expression) { + if (expression.kind === 188) { + return expression.operatorToken.kind; + } + else if (expression.kind === 186 || expression.kind === 187) { + return expression.operator; + } + else { + return expression.kind; + } + } + ts.getOperator = getOperator; + function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { + switch (nodeKind) { + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: + case 8: + case 9: + case 171: + case 172: + case 180: + case 181: + case 193: + case 242: + case 243: + case 11: + case 12: + case 190: + case 179: + case 194: + return 19; + case 177: + case 173: + case 174: + return 18; + case 176: + return hasArguments ? 18 : 17; + case 175: + return 17; + case 187: + return 16; + case 186: + case 183: + case 184: + case 182: + case 185: + return 15; + case 188: + switch (operatorKind) { + case 50: + case 51: + return 15; + case 39: + case 38: + case 40: + case 41: + return 14; + case 36: + case 37: + return 13; + case 44: + case 45: + case 46: + return 12; + case 26: + case 29: + case 28: + case 30: + case 91: + case 92: + return 11; + case 31: + case 33: + case 32: + case 34: + return 10; + case 47: + return 9; + case 49: + return 8; + case 48: + return 7; + case 52: + return 6; + case 53: + return 5; + case 57: + case 58: + case 59: + case 61: + case 60: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 69: + case 68: + return 3; + case 25: + return 0; + default: + return -1; } + case 189: + return 4; + case 191: + return 2; + case 192: + return 1; + default: + return -1; + } + } + ts.getOperatorPrecedence = getOperatorPrecedence; + function createDiagnosticCollection() { + var nonFileDiagnostics = []; + var fileDiagnostics = ts.createMap(); + var diagnosticsModified = false; + var modificationCount = 0; + return { + add: add, + getGlobalDiagnostics: getGlobalDiagnostics, + getDiagnostics: getDiagnostics, + getModificationCount: getModificationCount, + reattachFileDiagnostics: reattachFileDiagnostics + }; + function getModificationCount() { + return modificationCount; + } + function reattachFileDiagnostics(newFile) { + if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { + return; } - 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"]); - } + for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { + var diagnostic = _a[_i]; + diagnostic.file = newFile; } - 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); - } + } + function add(diagnostic) { + var diagnostics; + if (diagnostic.file) { + diagnostics = fileDiagnostics[diagnostic.file.fileName]; + if (!diagnostics) { + diagnostics = []; + fileDiagnostics[diagnostic.file.fileName] = diagnostics; } - mergeTypings(typingNames); } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(server.LogLevel || (server.LogLevel = {})); - var 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; + else { + diagnostics = nonFileDiagnostics; } + diagnostics.push(diagnostic); + diagnosticsModified = true; + modificationCount++; } - function createInstallTypingsRequest(project, typingOptions, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(), - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; + function getGlobalDiagnostics() { + sortAndDeduplicate(); + return nonFileDiagnostics; } - 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."); + function getDiagnostics(fileName) { + sortAndDeduplicate(); + if (fileName) { + return fileDiagnostics[fileName] || []; } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + var allDiagnostics = []; + function pushDiagnostic(d) { + allDiagnostics.push(d); } - 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, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: 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]; - } + ts.forEach(nonFileDiagnostics, pushDiagnostic); + for (var key in fileDiagnostics) { + ts.forEach(fileDiagnostics[key], pushDiagnostic); } + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { + function sortAndDeduplicate() { + if (!diagnosticsModified) { return; } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); + diagnosticsModified = false; + nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); + for (var key in fileDiagnostics) { + fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); } } - 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); + } + ts.createDiagnosticCollection = createDiagnosticCollection; + var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var escapedCharsMap = ts.createMap({ + "\0": "\\0", + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\r": "\\r", + "\n": "\\n", + "\\": "\\\\", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\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)); } - 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 throwLanguageServiceIsDisabledError() { - throw new Error("LanguageService is disabled"); - } - server.nullLanguageService = { - cleanupSemanticCache: throwLanguageServiceIsDisabledError, - getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, - getSemanticDiagnostics: throwLanguageServiceIsDisabledError, - getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, - getSyntacticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, - getSemanticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, - getCompletionsAtPosition: throwLanguageServiceIsDisabledError, - findReferences: throwLanguageServiceIsDisabledError, - getCompletionEntryDetails: throwLanguageServiceIsDisabledError, - getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, - findRenameLocations: throwLanguageServiceIsDisabledError, - getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, - getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, - getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, - getSignatureHelpItems: throwLanguageServiceIsDisabledError, - getDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getRenameInfo: throwLanguageServiceIsDisabledError, - getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getReferencesAtPosition: throwLanguageServiceIsDisabledError, - getDocumentHighlights: throwLanguageServiceIsDisabledError, - getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, - getNavigateToItems: throwLanguageServiceIsDisabledError, - getNavigationBarItems: throwLanguageServiceIsDisabledError, - getNavigationTree: throwLanguageServiceIsDisabledError, - getOutliningSpans: throwLanguageServiceIsDisabledError, - getTodoComments: throwLanguageServiceIsDisabledError, - getIndentationAtPosition: throwLanguageServiceIsDisabledError, - getFormattingEditsForRange: throwLanguageServiceIsDisabledError, - getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, - getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, - getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, - isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, - getEmitOutput: throwLanguageServiceIsDisabledError, - getProgram: throwLanguageServiceIsDisabledError, - getNonBoundSourceFile: throwLanguageServiceIsDisabledError, - dispose: throwLanguageServiceIsDisabledError, - getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, - getImplementationAtPosition: throwLanguageServiceIsDisabledError, - getSourceFile: throwLanguageServiceIsDisabledError, - getCodeFixesAtPosition: throwLanguageServiceIsDisabledError - }; - server.nullLanguageServiceHost = { - setCompilationSettings: function () { return undefined; }, - notifyFileRemoved: function () { return undefined; } - }; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - 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, message) { - host.trace(ts.formatMessage.apply(undefined, arguments)); } - ts.trace = trace; - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; } - ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + ts.isIntrinsicJsxName = isIntrinsicJsxName; + function get16BitUnicodeEscapeSequence(charCode) { + var hexCharCode = charCode.toString(16).toUpperCase(); + var paddedHexCode = ("0000" + hexCharCode).slice(-4); + return "\\u" + paddedHexCode; } - ts.createResolvedModule = createResolvedModule; - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + var nonAsciiCharacters = /[^\u0000-\u007F]/g; + function escapeNonAsciiCharacters(s) { + return nonAsciiCharacters.test(s) ? + s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : + s; } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } + ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; + var indentStrings = ["", " "]; + function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; + } + ts.getIndentString = getIndentString; + function getIndentSize() { + return indentStrings[1].length; + } + ts.getIndentSize = getIndentSize; + function createTextWriter(newLine) { + var output; + var indent; + var lineStart; + var lineCount; + var linePos; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; } + output += s; } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; + function reset() { + output = ""; + indent = 0; + lineStart = true; + lineCount = 0; + linePos = 0; } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; } - return undefined; - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.computeLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + } } - catch (e) { - return {}; + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeTextOfNode(text, node) { + write(getTextOfNodeFromSourceText(text, node)); } + reset(); + return { + write: write, + rawWrite: rawWrite, + writeTextOfNode: writeTextOfNode, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { indent++; }, + decreaseIndent: function () { indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; }, + isAtStartOfLine: function () { return lineStart; }, + reset: reset + }; } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; + ts.createTextWriter = createTextWriter; + function getResolvedExternalModuleName(host, file) { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + } + ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getExternalModuleNameFromDeclaration(host, resolver, declaration) { + var file = resolver.getExternalModuleFileFromDeclaration(declaration); + if (!file || isDeclarationFile(file)) { + return undefined; } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); + return getResolvedExternalModuleName(host, file); + } + ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; + function getExternalModuleNameFromPath(host, fileName) { + var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; + var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); + var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); + return ts.removeFileExtension(relativePath); + } + ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; + function getOwnEmitOutputFilePath(sourceFile, host, extension) { + var compilerOptions = host.getCompilerOptions(); + var emitOutputFilePathWithoutExtension; + if (compilerOptions.outDir) { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); + else { + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); } - return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + return emitOutputFilePathWithoutExtension + extension; } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; + function getDeclarationEmitOutputFilePath(sourceFile, host) { + var options = host.getCompilerOptions(); + var outputDir = options.declarationDir || options.outDir; + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; + } + ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; + function getSourceFilesToEmit(host, targetSourceFile) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + var moduleKind = ts.getEmitModuleKind(options); + var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; + var sourceFiles = host.getSourceFiles(); + return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_1 = ts.getDirectoryPath(currentDirectory); - if (parent_1 === currentDirectory) { - break; - } - currentDirectory = parent_1; + else { + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + return ts.filter(sourceFiles, isNonDeclarationFile); } - return typeRoots; } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + ts.getSourceFilesToEmit = getSourceFilesToEmit; + function isNonDeclarationFile(sourceFile) { + return !isDeclarationFile(sourceFile); + } + function isBundleEmitNonExternalModule(sourceFile) { + return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + } + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(sourceFiles); + } + else { + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + onSingleFileEmit(host, sourceFile); } } } - var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; + } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; } } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + function onBundledEmit(sourceFiles) { + if (sourceFiles.length) { + var jsFilePath = options.outFile || options.out; + var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); } } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } - if (initialLocationForSecondaryLookup !== undefined) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } + } + ts.forEachTransformedEmitFile = forEachTransformedEmitFile; + function getSourceMapFilePath(jsFilePath, options) { + return options.sourceMap ? jsFilePath + ".map" : undefined; + } + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { + var options = host.getCompilerOptions(); + if (options.outFile || options.out) { + onBundledEmit(host); } else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; + if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { + onSingleFileEmit(host, sourceFile); + } } } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } + function onSingleFileEmit(host, sourceFile) { + var extension = ".js"; + if (options.jsx === 1) { + if (isSourceFileJavaScript(sourceFile)) { + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + extension = ".jsx"; } } + else if (sourceFile.languageVariant === 1) { + extension = ".jsx"; + } + } + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: declarationFilePath + }; + action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); + } + function onBundledEmit(host) { + var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && + !host.isSourceFileFromExternalLibrary(sourceFile) && + (!ts.isExternalModule(sourceFile) || + !!ts.getEmitModuleKind(options)); }); + if (bundledSources.length) { + var jsFilePath = options.outFile || options.out; + var emitFileNames = { + jsFilePath: jsFilePath, + sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), + declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined + }; + action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); } } - return result; } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - 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; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + ts.forEachExpectedEmitFile = forEachExpectedEmitFile; + function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { + var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); + var commonSourceDirectory = host.getCommonSourceDirectory(); + var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; + sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; + return ts.combinePaths(newDirPath, sourceFilePath); + } + ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; + function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { + host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); + }, sourceFiles); + } + ts.writeFile = writeFile; + function getLineOfLocalPosition(currentSourceFile, pos) { + return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + } + ts.getLineOfLocalPosition = getLineOfLocalPosition; + function getLineOfLocalPositionFromLineMap(lineMap, pos) { + return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; + } + ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 149 && nodeIsPresent(member.body)) { + return member; } + }); + } + ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + if (accessor && accessor.parameters.length > 0) { + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); + return accessor.parameters[hasThis ? 1 : 0].type; } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; } } - 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) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 70 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 98; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; + function getAllAccessorDeclarations(declarations, accessor) { + var firstAccessor; + var secondAccessor; + var getAccessor; + var setAccessor; + if (hasDynamicName(accessor)) { + firstAccessor = accessor; + if (accessor.kind === 150) { + getAccessor = accessor; + } + else if (accessor.kind === 151) { + setAccessor = accessor; } else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + ts.Debug.fail("Accessor has wrong kind"); } } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + ts.forEach(declarations, function (member) { + if ((member.kind === 150 || member.kind === 151) + && hasModifier(member, 32) === hasModifier(accessor, 32)) { + var memberName = getPropertyNameForPropertyNameNode(member.name); + var accessorName = getPropertyNameForPropertyNameNode(accessor.name); + if (memberName === accessorName) { + if (!firstAccessor) { + firstAccessor = member; + } + else if (!secondAccessor) { + secondAccessor = member; + } + if (member.kind === 150 && !getAccessor) { + getAccessor = member; + } + if (member.kind === 151 && !setAccessor) { + setAccessor = member; + } + } + } + }); } + return { + firstAccessor: firstAccessor, + secondAccessor: secondAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + ts.getAllAccessorDeclarations = getAllAccessorDeclarations; + function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { + emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); + } + ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; + function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { + if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { + writer.writeLine(); } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } + } + ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; + function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { + if (pos !== commentPos && + getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { + writer.writeLine(); } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; + function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { + if (comments && comments.length > 0) { + if (leadingSeparator) { + writer.write(" "); } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; + var emitInterveningSeparator = false; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; + if (emitInterveningSeparator) { + writer.write(" "); + emitInterveningSeparator = false; } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; + else { + emitInterveningSeparator = true; } } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + if (emitInterveningSeparator && trailingSeparator) { + writer.write(" "); } } - return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + ts.emitComments = emitComments; + function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); } - matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + else { + leadingComments = ts.getLeadingCommentRanges(text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment = void 0; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); + var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); + emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return text.charCodeAt(comment.pos + 1) === 42 && + text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; + function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { + if (text.charCodeAt(commentPos + 1) === 42) { + var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); + var lineCount = lineMap.length; + var firstCommentLineIndent = void 0; + for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { + var nextLineStart = (currentLine + 1) === lineCount + ? text.length + 1 + : lineMap[currentLine + 1]; + if (pos !== commentPos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } } + writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); + pos = nextLineStart; } - return undefined; } else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + writer.write(text.substring(commentPos, commentEnd)); + } + } + ts.writeCommentRange = writeCommentRange; + function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { + var end = Math.min(commentEnd, nextLineStart - 1); + var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + if (currentLineText) { + writer.write(currentLineText); + if (end !== commentEnd) { + writer.writeLine(); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + else { + writer.writeLiteral(newLine); } } - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); - isExternalLibraryImport = resolvedFileName !== undefined; + function calculateIndent(text, pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { + if (text.charCodeAt(pos) === 9) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); - } - } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + currentLineIndent++; } } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); + return currentLineIndent; } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + function hasModifiers(node) { + return getModifierFlags(node) !== 0; } - function directoryProbablyExists(directoryName, host) { - return !host.directoryExists || host.directoryExists(directoryName); + ts.hasModifiers = hasModifiers; + function hasModifier(node, flags) { + return (getModifierFlags(node) & flags) !== 0; } - ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; + ts.hasModifier = hasModifier; + function getModifierFlags(node) { + if (node.modifierFlagsCache & 536870912) { + return node.modifierFlagsCache & ~536870912; } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + var flags = 0; + if (node.modifiers) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + flags |= modifierToFlag(modifier.kind); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); } + if (node.flags & 4) { + flags |= 1; + } + node.modifierFlagsCache = flags | 536870912; + return flags; } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } + ts.getModifierFlags = getModifierFlags; + function modifierToFlag(token) { + switch (token) { + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 129: return 64; } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + return 0; } - function tryFile(fileName, failedLookupLocation, 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); - } - return fileName; + ts.modifierToFlag = modifierToFlag; + function isLogicalOperator(token) { + return token === 53 + || token === 52 + || token === 50; + } + ts.isLogicalOperator = isLogicalOperator; + function isAssignmentOperator(token) { + return token >= 57 && token <= 69; + } + ts.isAssignmentOperator = isAssignmentOperator; + function tryGetClassExtendingExpressionWithTypeArguments(node) { + if (node.kind === 195 && + node.parent.token === 84 && + isClassLike(node.parent.parent)) { + return node.parent.parent; } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isDestructuringAssignment(node) { + if (isBinaryExpression(node)) { + if (node.operatorToken.kind === 57) { + var kind = node.left.kind; + return kind === 172 + || kind === 171; } - failedLookupLocation.push(fileName); - return undefined; } + return false; } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } + ts.isDestructuringAssignment = isDestructuringAssignment; + function isSupportedExpressionWithTypeArguments(node) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); + } + ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; + function isSupportedExpressionWithTypeArgumentsRest(node) { + if (node.kind === 70) { + return true; + } + else if (isPropertyAccessExpression(node)) { + return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocation.push(packageJsonPath); + return false; } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); + function isExpressionWithTypeArgumentsInClassExtendsClause(node) { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; + ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isEntityNameExpression(node) { + return node.kind === 70 || + node.kind === 173 && isEntityNameExpression(node.expression); + } + ts.isEntityNameExpression = isEntityNameExpression; + function isRightSideOfQualifiedNameOrPropertyAccess(node) { + return (node.parent.kind === 140 && node.parent.right === node) || + (node.parent.kind === 173 && node.parent.name === node); + } + ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isEmptyObjectLiteralOrArrayLiteral(expression) { + var kind = expression.kind; + if (kind === 172) { + return expression.properties.length === 0; } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; + if (kind === 171) { + return expression.elements.length === 0; } + return false; } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + function getLocalSymbolForExportDefault(symbol) { + return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; - function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; + function tryExtractTypeScriptExtension(fileName) { + return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - } - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; - } + ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; + function getExpandedCharCodes(input) { + var output = []; + var length = input.length; + for (var i = 0; i < length; i++) { + var charCode = input.charCodeAt(i); + if (charCode < 0x80) { + output.push(charCode); } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory || checkOneLevel) { - break; + else if (charCode < 0x800) { + output.push((charCode >> 6) | 192); + output.push((charCode & 63) | 128); } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); - } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - return referencedSourceFile; + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 224); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - return undefined; + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 240); + output.push(((charCode >> 12) & 63) | 128); + output.push(((charCode >> 6) & 63) | 128); + output.push((charCode & 63) | 128); } - containingDirectory = parentPath; - } - } -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.externalHelpersModuleNameText = "tslib"; - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - if (declarations) { - for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { - var declaration = declarations_1[_i]; - if (declaration.kind === kind) { - return declaration; - } + else { + ts.Debug.assert(false, "Unexpected code point"); } } - return undefined; + return output; } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length === 0) { - var str_1 = ""; - var writeText = function (text) { return str_1 += text; }; - return { - string: function () { return str_1; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str_1 += " "; }, - increaseIndent: function () { }, - decreaseIndent: function () { }, - clear: function () { return str_1 = ""; }, - trackSymbol: function () { }, - reportInaccessibleThisError: function () { } - }; - } - return stringWriters.pop(); + ts.stringify = typeof JSON !== "undefined" && JSON.stringify + ? JSON.stringify + : stringifyFallback; + function stringifyFallback(value) { + return value === undefined ? undefined : stringifyValue(value); } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); + function stringifyValue(value) { + return typeof value === "string" ? "\"" + escapeString(value) + "\"" + : typeof value === "number" ? isFinite(value) ? String(value) : "null" + : typeof value === "boolean" ? value ? "true" : "false" + : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) + : "null"; } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; + function cycleCheck(cb, value) { + ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); + value.__cycle = true; + var result = cb(value); + delete value.__cycle; + return result; } - ts.getFullWidth = getFullWidth; - function arrayIsEqualTo(array1, array2, equaler) { - if (!array1 || !array2) { - return array1 === array2; - } - if (array1.length !== array2.length) { - return false; - } - for (var i = 0; i < array1.length; i++) { - var equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i]; - if (!equals) { - return false; - } - } - return true; + function stringifyArray(value) { + return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; } - ts.arrayIsEqualTo = arrayIsEqualTo; - function hasResolvedModule(sourceFile, moduleNameText) { - return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); + function stringifyElement(memo, value) { + return (memo ? memo + "," : memo) + stringifyValue(value); } - ts.hasResolvedModule = hasResolvedModule; - function getResolvedModule(sourceFile, moduleNameText) { - return hasResolvedModule(sourceFile, moduleNameText) ? sourceFile.resolvedModules[moduleNameText] : undefined; + function stringifyObject(value) { + return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; } - ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { - if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = ts.createMap(); - } - sourceFile.resolvedModules[moduleNameText] = resolvedModule; + function stringifyProperty(memo, value, key) { + return value === undefined || typeof value === "function" || key === "__cycle" ? memo + : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); } - ts.setResolvedModule = setResolvedModule; - function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { - if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap(); + var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + function convertToBase64(input) { + var result = ""; + var charCodes = getExpandedCharCodes(input); + var i = 0; + var length = charCodes.length; + var byte1, byte2, byte3, byte4; + while (i < length) { + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 63; + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + i += 3; } - sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; - } - ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; - function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; - } - ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; - function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return result; } - ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { - if (names.length !== newResolutions.length) { - return false; + ts.convertToBase64 = convertToBase64; + var carriageReturnLineFeed = "\r\n"; + var lineFeed = "\n"; + function getNewLineCharacter(options) { + if (options.newLine === 0) { + return carriageReturnLineFeed; } - for (var i = 0; i < names.length; i++) { - var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions[names[i]]; - var changed = oldResolution - ? !newResolution || !comparer(oldResolution, newResolution) - : newResolution; - if (changed) { - return true; - } + else if (options.newLine === 1) { + return lineFeed; } - return false; - } - ts.hasChangesInResolutions = hasChangesInResolutions; - function containsParseError(node) { - aggregateChildData(node); - return (node.flags & 2097152) !== 0; - } - ts.containsParseError = containsParseError; - function aggregateChildData(node) { - if (!(node.flags & 4194304)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || - ts.forEachChild(node, containsParseError); - if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152; - } - node.flags |= 4194304; + else if (ts.sys) { + return ts.sys.newLine; } + return carriageReturnLineFeed; } - function getSourceFileOfNode(node) { - while (node && node.kind !== 256) { - node = node.parent; - } - return node; + ts.getNewLineCharacter = getNewLineCharacter; + function isSimpleExpression(node) { + return isSimpleExpressionWorker(node, 0); } - ts.getSourceFileOfNode = getSourceFileOfNode; - function isStatementWithLocals(node) { - switch (node.kind) { - case 199: - case 227: - case 206: - case 207: - case 208: + ts.isSimpleExpression = isSimpleExpression; + function isSimpleExpressionWorker(node, depth) { + if (depth <= 5) { + var kind = node.kind; + if (kind === 9 + || kind === 8 + || kind === 11 + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { + return true; + } + else if (kind === 173) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 174) { + return isSimpleExpressionWorker(node.expression, depth + 1) + && isSimpleExpressionWorker(node.argumentExpression, depth + 1); + } + else if (kind === 186 + || kind === 187) { + return isSimpleExpressionWorker(node.operand, depth + 1); + } + else if (kind === 188) { + return node.operatorToken.kind !== 39 + && isSimpleExpressionWorker(node.left, depth + 1) + && isSimpleExpressionWorker(node.right, depth + 1); + } + else if (kind === 189) { + return isSimpleExpressionWorker(node.condition, depth + 1) + && isSimpleExpressionWorker(node.whenTrue, depth + 1) + && isSimpleExpressionWorker(node.whenFalse, depth + 1); + } + else if (kind === 184 + || kind === 183 + || kind === 182) { + return isSimpleExpressionWorker(node.expression, depth + 1); + } + else if (kind === 171) { + return node.elements.length === 0; + } + else if (kind === 172) { + return node.properties.length === 0; + } + else if (kind === 175) { + if (!isSimpleExpressionWorker(node.expression, depth + 1)) { + return false; + } + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + if (!isSimpleExpressionWorker(argument, depth + 1)) { + return false; + } + } return true; + } } return false; } - ts.isStatementWithLocals = isStatementWithLocals; - function getStartPositionOfLine(line, sourceFile) { - ts.Debug.assert(line >= 0); - return ts.getLineStarts(sourceFile)[line]; - } - ts.getStartPositionOfLine = getStartPositionOfLine; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isDefined(value) { - return value !== undefined; - } - ts.isDefined = isDefined; - function getEndLinePosition(line, sourceFile) { - ts.Debug.assert(line >= 0); - var lineStarts = ts.getLineStarts(sourceFile); - var lineIndex = line; - var sourceText = sourceFile.text; - if (lineIndex + 1 === lineStarts.length) { - return sourceText.length - 1; + var syntaxKindCache = ts.createMap(); + function formatSyntaxKind(kind) { + var syntaxKindEnum = ts.SyntaxKind; + if (syntaxKindEnum) { + if (syntaxKindCache[kind]) { + return syntaxKindCache[kind]; + } + for (var name_6 in syntaxKindEnum) { + if (syntaxKindEnum[name_6] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_6 + ")"; + } + } } else { - var start = lineStarts[lineIndex]; - var pos = lineStarts[lineIndex + 1] - 1; - ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos))); - while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) { - pos--; - } - return pos; + return kind.toString(); } } - ts.getEndLinePosition = getEndLinePosition; - function nodeIsMissing(node) { - if (node === undefined) { - return true; - } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1; + ts.formatSyntaxKind = formatSyntaxKind; + function movePos(pos, value) { + return ts.positionIsSynthesized(pos) ? -1 : pos + value; } - ts.nodeIsMissing = nodeIsMissing; - function nodeIsPresent(node) { - return !nodeIsMissing(node); + ts.movePos = movePos; + function createRange(pos, end) { + return { pos: pos, end: end }; } - ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { - if (nodeIsMissing(node)) { - return node.pos; - } - if (isJSDocNode(node)) { - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); - } - if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { - return getTokenPosOfNode(node.jsDocComments[0]); - } - if (node.kind === 286 && node._children.length > 0) { - return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + ts.createRange = createRange; + function moveRangeEnd(range, end) { + return createRange(range.pos, end); } - ts.getTokenPosOfNode = getTokenPosOfNode; - function isJSDocNode(node) { - return node.kind >= 257 && node.kind <= 282; + ts.moveRangeEnd = moveRangeEnd; + function moveRangePos(range, pos) { + return createRange(pos, range.end); } - ts.isJSDocNode = isJSDocNode; - function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; + ts.moveRangePos = moveRangePos; + function moveRangePastDecorators(node) { + return node.decorators && node.decorators.length > 0 + ? moveRangePos(node, node.decorators.end) + : node; } - ts.isJSDocTag = isJSDocTag; - function getNonDecoratorTokenPosOfNode(node, sourceFile) { - if (nodeIsMissing(node) || !node.decorators) { - return getTokenPosOfNode(node, sourceFile); - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + ts.moveRangePastDecorators = moveRangePastDecorators; + function moveRangePastModifiers(node) { + return node.modifiers && node.modifiers.length > 0 + ? moveRangePos(node, node.modifiers.end) + : moveRangePastDecorators(node); } - ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - if (nodeIsMissing(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); + ts.moveRangePastModifiers = moveRangePastModifiers; + function isCollapsedRange(range) { + return range.pos === range.end; } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (nodeIsMissing(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); + ts.isCollapsedRange = isCollapsedRange; + function collapseRangeToStart(range) { + return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node, includeTrivia) { - if (includeTrivia === void 0) { includeTrivia = false; } - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); + ts.collapseRangeToStart = collapseRangeToStart; + function collapseRangeToEnd(range) { + return isCollapsedRange(range) ? range : moveRangePos(range, range.end); } - ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } - if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; - } - switch (node.kind) { - case 9: - return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14: - return getQuotedEscapedLiteralText("}", node.text, "`"); - case 8: - return node.text; - } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + ts.collapseRangeToEnd = collapseRangeToEnd; + function createTokenRange(pos, token) { + return createRange(pos, pos + ts.tokenToString(token).length); } - ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - if (node.kind === 8 && text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - case 111: - case 79: - return true; - } - } - return false; + ts.createTokenRange = createTokenRange; + function rangeIsOnSingleLine(range, sourceFile) { + return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { - return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + ts.rangeIsOnSingleLine = rangeIsOnSingleLine; + function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); } - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier; + ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; + function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, range2.end, sourceFile); } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 && identifier.charCodeAt(2) === 95 ? identifier.substr(1) : identifier; + ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; + function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); } - ts.unescapeIdentifier = unescapeIdentifier; - function makeIdentifierFromModuleName(moduleName) { - return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_"); + ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; + function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { + return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); } - ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; - function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 || - isCatchClauseVariableDeclaration(declaration); + ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; + function positionsAreOnSameLine(pos1, pos2, sourceFile) { + return pos1 === pos2 || + getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); } - ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - function isAmbientModule(node) { - return node && node.kind === 225 && - (node.name.kind === 9 || isGlobalScopeAugmentation(node)); - } - ts.isAmbientModule = isAmbientModule; - function isShorthandAmbientModuleSymbol(moduleSymbol) { - return isShorthandAmbientModule(moduleSymbol.valueDeclaration); - } - ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; - function isShorthandAmbientModule(node) { - return node.kind === 225 && (!node.body); + ts.positionsAreOnSameLine = positionsAreOnSameLine; + function getStartPositionOfRange(range, sourceFile) { + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } - function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 225 || - isFunctionLike(node); + ts.getStartPositionOfRange = getStartPositionOfRange; + function collectExternalModuleInfo(sourceFile) { + var externalImports = []; + var exportSpecifiers = ts.createMap(); + var exportEquals = undefined; + var hasExportStarsToExportValues = false; + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 231: + externalImports.push(node); + break; + case 230: + if (node.moduleReference.kind === 241) { + externalImports.push(node); + } + break; + case 237: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStarsToExportValues = true; + } + else { + externalImports.push(node); + } + } + else { + for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { + var specifier = _c[_b]; + var name_7 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_7] || (exportSpecifiers[name_7] = [])).push(specifier); + } + } + break; + case 236: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + } + } + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; } - ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; - function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); + ts.collectExternalModuleInfo = collectExternalModuleInfo; + function getInitializedVariables(node) { + return ts.filter(node.declarations, isInitializedVariable); } - ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; - function isExternalModuleAugmentation(node) { - if (!node || !isAmbientModule(node)) { - return false; - } - switch (node.parent.kind) { - case 256: - return ts.isExternalModule(node.parent); - case 226: - return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); - } - return false; + ts.getInitializedVariables = getInitializedVariables; + function isInitializedVariable(node) { + return node.initializer !== undefined; } - ts.isExternalModuleAugmentation = isExternalModuleAugmentation; - function isBlockScope(node, parentNode) { - switch (node.kind) { - case 256: - case 227: - case 252: - case 225: - case 206: - case 207: - case 208: - case 148: - case 147: - case 149: - case 150: - case 220: - case 179: - case 180: - return true; - case 199: - return parentNode && !isFunctionLike(parentNode); + function isMergedWithClass(node) { + if (node.symbol) { + for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 222 && declaration !== node) { + return true; + } + } } return false; } - ts.isBlockScope = isBlockScope; - function getEnclosingBlockScopeContainer(node) { - var current = node.parent; - while (current) { - if (isBlockScope(current, current.parent)) { - return current; - } - current = current.parent; - } + ts.isMergedWithClass = isMergedWithClass; + function isFirstDeclarationOfKind(node, kind) { + return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; } - ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; - function isCatchClauseVariableDeclaration(declaration) { - return declaration && - declaration.kind === 218 && - declaration.parent && - declaration.parent.kind === 252; + ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; + function isNodeArray(array) { + return array.hasOwnProperty("pos") + && array.hasOwnProperty("end"); } - ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); + ts.isNodeArray = isNodeArray; + function isNoSubstitutionTemplateLiteral(node) { + return node.kind === 12; } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); + ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; + function isLiteralKind(kind) { + return 8 <= kind && kind <= 12; } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain) { - var sourceFile = getSourceFileOfNode(node); - var span = getErrorSpanForNode(sourceFile, node); - return { - file: sourceFile, - start: span.start, - length: span.length, - code: messageChain.code, - category: messageChain.category, - messageText: messageChain.next ? messageChain : messageChain.messageText - }; + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 9 || kind === 12; } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); - scanner.scan(); - var start = scanner.getTokenPos(); - return ts.createTextSpanFromBounds(start, scanner.getTextPos()); + ts.isTextualLiteralKind = isTextualLiteralKind; + function isLiteralExpression(node) { + return isLiteralKind(node.kind); } - ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; - function getErrorSpanForArrowFunction(sourceFile, node) { - var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199) { - var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; - var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; - if (startLine < endLine) { - return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1); - } - } - return ts.createTextSpanFromBounds(pos, node.end); + ts.isLiteralExpression = isLiteralExpression; + function isTemplateLiteralKind(kind) { + return 12 <= kind && kind <= 15; } - function getErrorSpanForNode(sourceFile, node) { - var errorNode = node; - switch (node.kind) { - case 256: - 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 218: - case 169: - case 221: - case 192: - case 222: - case 225: - case 224: - case 255: - case 220: - case 179: - case 147: - case 149: - case 150: - case 223: - errorNode = node.name; - break; - case 180: - return getErrorSpanForArrowFunction(sourceFile, node); - } - if (errorNode === undefined) { - return getSpanOfTokenAtPosition(sourceFile, node.pos); - } - var pos = nodeIsMissing(errorNode) - ? errorNode.pos - : ts.skipTrivia(sourceFile.text, errorNode.pos); - return ts.createTextSpanFromBounds(pos, errorNode.end); + ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateHead(node) { + return node.kind === 13; } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalOrCommonJsModule(file) { - return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 14 + || kind === 15; } - ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; - function isDeclarationFile(file) { - return file.isDeclarationFile; + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; + function isIdentifier(node) { + return node.kind === 70; } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 224 && isConst(node); + ts.isIdentifier = isIdentifier; + function isGeneratedIdentifier(node) { + return isIdentifier(node) && node.autoGenerateKind > 0; } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2) - || !!(ts.getCombinedModifierFlags(node) & 2048); + ts.isGeneratedIdentifier = isGeneratedIdentifier; + function isModifier(node) { + return isModifierKind(node.kind); } - ts.isConst = isConst; - function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1); + ts.isModifier = isModifier; + function isQualifiedName(node) { + return node.kind === 140; } - ts.isLet = isLet; - function isSuperCall(n) { - return n.kind === 174 && n.expression.kind === 95; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 141; } - ts.isSuperCall = isSuperCall; - function isPrologueDirective(node) { - return node.kind === 202 && node.expression.kind === 9; + ts.isComputedPropertyName = isComputedPropertyName; + function isEntityName(node) { + var kind = node.kind; + return kind === 140 + || kind === 70; } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); + ts.isEntityName = isEntityName; + function isPropertyName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9 + || kind === 8 + || kind === 141; } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getLeadingCommentRangesOfNodeFromText(node, text) { - return ts.getLeadingCommentRanges(text, node.pos); + ts.isPropertyName = isPropertyName; + function isModuleName(node) { + var kind = node.kind; + return kind === 70 + || kind === 9; } - ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; - function getJsDocComments(node, sourceFileOfNode) { - return getJsDocCommentsFromText(node, sourceFileOfNode.text); + ts.isModuleName = isModuleName; + function isBindingName(node) { + var kind = node.kind; + return kind === 70 + || kind === 168 + || kind === 169; } - ts.getJsDocComments = getJsDocComments; - function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 || - node.kind === 141 || - node.kind === 179 || - node.kind === 180) ? - ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 42 && - text.charCodeAt(comment.pos + 3) !== 47; - } + ts.isBindingName = isBindingName; + function isTypeParameter(node) { + return node.kind === 142; } - ts.getJsDocCommentsFromText = getJsDocCommentsFromText; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - function isPartOfTypeNode(node) { - if (154 <= node.kind && node.kind <= 166) { - return true; - } - switch (node.kind) { - case 117: - case 130: - case 132: - case 120: - case 133: - case 135: - case 127: - return true; - case 103: - return node.parent.kind !== 183; - case 194: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 139 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 172 && node.parent.name === node) { - node = node.parent; - } - ts.Debug.assert(node.kind === 69 || node.kind === 139 || node.kind === 172, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139: - case 172: - case 97: - var parent_2 = node.parent; - if (parent_2.kind === 158) { - return false; - } - if (154 <= parent_2.kind && parent_2.kind <= 166) { - return true; - } - switch (parent_2.kind) { - case 194: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 141: - return node === parent_2.constraint; - case 145: - case 144: - case 142: - case 218: - return node === parent_2.type; - case 220: - case 179: - case 180: - case 148: - case 147: - case 146: - case 149: - case 150: - return node === parent_2.type; - case 151: - case 152: - case 153: - return node === parent_2.type; - case 177: - return node === parent_2.type; - case 174: - case 175: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; - case 176: - return false; - } - } - return false; + ts.isTypeParameter = isTypeParameter; + function isParameter(node) { + return node.kind === 143; } - ts.isPartOfTypeNode = isPartOfTypeNode; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 211: - return visitor(node); - case 227: - case 199: - case 203: - case 204: - case 205: - case 206: - case 207: - case 208: - case 212: - case 213: - case 249: - case 250: - case 214: - case 216: - case 252: - return ts.forEachChild(node, traverse); - } - } + ts.isParameter = isParameter; + function isDecorator(node) { + return node.kind === 144; } - ts.forEachReturnStatement = forEachReturnStatement; - function forEachYieldExpression(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 190: - visitor(node); - var operand = node.expression; - if (operand) { - traverse(operand); - } - case 224: - case 222: - case 225: - case 223: - case 221: - case 192: - return; - default: - if (isFunctionLike(node)) { - var name_8 = node.name; - if (name_8 && name_8.kind === 140) { - traverse(name_8.expression); - return; - } - } - else if (!isPartOfTypeNode(node)) { - ts.forEachChild(node, traverse); - } - } - } + ts.isDecorator = isDecorator; + function isMethodDeclaration(node) { + return node.kind === 148; } - ts.forEachYieldExpression = forEachYieldExpression; - function isVariableLike(node) { - if (node) { - switch (node.kind) { - case 169: - case 255: - case 142: - case 253: - case 145: - case 144: - case 254: - case 218: - return true; - } - } - return false; + ts.isMethodDeclaration = isMethodDeclaration; + function isClassElement(node) { + var kind = node.kind; + return kind === 149 + || kind === 146 + || kind === 148 + || kind === 150 + || kind === 151 + || kind === 154 + || kind === 199; } - ts.isVariableLike = isVariableLike; - function isAccessor(node) { - return node && (node.kind === 149 || node.kind === 150); + ts.isClassElement = isClassElement; + function isObjectLiteralElementLike(node) { + var kind = node.kind; + return kind === 253 + || kind === 254 + || kind === 148 + || kind === 150 + || kind === 151 + || kind === 240; } - ts.isAccessor = isAccessor; - function isClassLike(node) { - return node && (node.kind === 221 || node.kind === 192); + ts.isObjectLiteralElementLike = isObjectLiteralElementLike; + function isTypeNodeKind(kind) { + return (kind >= 155 && kind <= 167) + || kind === 118 + || kind === 131 + || kind === 121 + || kind === 133 + || kind === 134 + || kind === 104 + || kind === 128 + || kind === 195; } - ts.isClassLike = isClassLike; - function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + function isTypeNode(node) { + return isTypeNodeKind(node.kind); } - ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { - switch (kind) { - case 148: - case 179: - case 220: - case 180: - case 147: - case 146: - case 149: - case 150: - case 151: - case 152: - case 153: - case 156: - case 157: - return true; + ts.isTypeNode = isTypeNode; + function isBindingPattern(node) { + if (node) { + var kind = node.kind; + return kind === 169 + || kind === 168; } return false; } - ts.isFunctionLikeKind = isFunctionLikeKind; - function introducesArgumentsExoticObject(node) { - switch (node.kind) { - case 147: - case 146: - case 148: - case 149: - case 150: - case 220: - case 179: - return true; - } - return false; + ts.isBindingPattern = isBindingPattern; + function isBindingElement(node) { + return node.kind === 170; } - ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 206: - case 207: - case 208: - case 204: - case 205: - return true; - case 214: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; + ts.isBindingElement = isBindingElement; + function isArrayBindingElement(node) { + var kind = node.kind; + return kind === 170 + || kind === 194; } - ts.isIterationStatement = isIterationStatement; - function isFunctionBlock(node) { - return node && node.kind === 199 && isFunctionLike(node.parent); + ts.isArrayBindingElement = isArrayBindingElement; + function isPropertyAccessExpression(node) { + return node.kind === 173; } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node && node.kind === 147 && node.parent.kind === 171; + ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isElementAccessExpression(node) { + return node.kind === 174; } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 && - (node.parent.kind === 171 || - node.parent.kind === 192); + ts.isElementAccessExpression = isElementAccessExpression; + function isBinaryExpression(node) { + return node.kind === 188; } - ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; - function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1; + ts.isBinaryExpression = isBinaryExpression; + function isConditionalExpression(node) { + return node.kind === 189; } - ts.isIdentifierTypePredicate = isIdentifierTypePredicate; - function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0; - } - ts.isThisTypePredicate = isThisTypePredicate; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isFunctionLike(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getContainingClass(node) { - while (true) { - node = node.parent; - if (!node || isClassLike(node)) { - return node; - } - } - } - ts.getContainingClass = getContainingClass; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 140: - if (isClassLike(node.parent.parent)) { - return node; - } - node = node.parent; - break; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - case 180: - if (!includeArrowFunctions) { - continue; - } - case 220: - case 179: - case 225: - case 145: - case 144: - case 147: - case 146: - case 148: - case 149: - case 150: - case 151: - case 152: - case 153: - case 224: - case 256: - return node; - } - } + ts.isConditionalExpression = isConditionalExpression; + function isCallExpression(node) { + return node.kind === 175; } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node, stopOnFunctions) { - while (true) { - node = node.parent; - if (!node) { - return node; - } - switch (node.kind) { - case 140: - node = node.parent; - break; - case 220: - case 179: - case 180: - if (!stopOnFunctions) { - continue; - } - case 145: - case 144: - case 147: - case 146: - case 148: - case 149: - case 150: - return node; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { - node = node.parent.parent; - } - else if (isClassElement(node.parent)) { - node = node.parent; - } - break; - } - } + ts.isCallExpression = isCallExpression; + function isTemplateLiteral(node) { + var kind = node.kind; + return kind === 190 + || kind === 12; } - ts.getSuperContainer = getSuperContainer; - function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 || func.kind === 180) { - var prev = func; - var parent_3 = func.parent; - while (parent_3.kind === 178) { - prev = parent_3; - parent_3 = parent_3.parent; - } - if (parent_3.kind === 174 && parent_3.expression === prev) { - return parent_3; - } - } + ts.isTemplateLiteral = isTemplateLiteral; + function isSpreadElementExpression(node) { + return node.kind === 192; } - ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; - function isSuperProperty(node) { - var kind = node.kind; - return (kind === 172 || kind === 173) - && node.expression.kind === 95; + ts.isSpreadElementExpression = isSpreadElementExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 195; } - ts.isSuperProperty = isSuperProperty; - function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 155: - return node.typeName; - case 194: - ts.Debug.assert(isEntityNameExpression(node.expression)); - return node.expression; - case 69: - case 139: - return node; - } - } - return undefined; + ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; + function isLeftHandSideExpressionKind(kind) { + return kind === 173 + || kind === 174 + || kind === 176 + || kind === 175 + || kind === 242 + || kind === 243 + || kind === 177 + || kind === 171 + || kind === 179 + || kind === 172 + || kind === 193 + || kind === 180 + || kind === 70 + || kind === 11 + || kind === 8 + || kind === 9 + || kind === 12 + || kind === 190 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 197; } - ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; - function isCallLikeExpression(node) { - switch (node.kind) { - case 174: - case 175: - case 176: - case 143: - return true; - default: - return false; - } + function isLeftHandSideExpression(node) { + return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } - ts.isCallLikeExpression = isCallLikeExpression; - function getInvokedExpression(node) { - if (node.kind === 176) { - return node.tag; - } - return node.expression; + ts.isLeftHandSideExpression = isLeftHandSideExpression; + function isUnaryExpressionKind(kind) { + return kind === 186 + || kind === 187 + || kind === 182 + || kind === 183 + || kind === 184 + || kind === 185 + || kind === 178 + || isLeftHandSideExpressionKind(kind); } - ts.getInvokedExpression = getInvokedExpression; - function nodeCanBeDecorated(node) { - switch (node.kind) { - case 221: - return true; - case 145: - return node.parent.kind === 221; - case 149: - case 150: - case 147: - return node.body !== undefined - && node.parent.kind === 221; - case 142: - return node.parent.body !== undefined - && (node.parent.kind === 148 - || node.parent.kind === 147 - || node.parent.kind === 150) - && node.parent.parent.kind === 221; - } - return false; + function isUnaryExpression(node) { + return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } - ts.nodeCanBeDecorated = nodeCanBeDecorated; - function nodeIsDecorated(node) { - return node.decorators !== undefined - && nodeCanBeDecorated(node); + ts.isUnaryExpression = isUnaryExpression; + function isExpressionKind(kind) { + return kind === 189 + || kind === 191 + || kind === 181 + || kind === 188 + || kind === 192 + || kind === 196 + || kind === 194 + || isUnaryExpressionKind(kind); } - ts.nodeIsDecorated = nodeIsDecorated; - function nodeOrChildIsDecorated(node) { - return nodeIsDecorated(node) || childIsDecorated(node); + function isExpression(node) { + return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } - ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; - function childIsDecorated(node) { - switch (node.kind) { - case 221: - return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147: - case 150: - return ts.forEach(node.parameters, nodeIsDecorated); - } + ts.isExpression = isExpression; + function isAssertionExpression(node) { + var kind = node.kind; + return kind === 178 + || kind === 196; } - ts.childIsDecorated = childIsDecorated; - function isJSXTagName(node) { - var parent = node.parent; - if (parent.kind === 243 || - parent.kind === 242 || - parent.kind === 245) { - return parent.tagName === node; - } - return false; + ts.isAssertionExpression = isAssertionExpression; + function isPartiallyEmittedExpression(node) { + return node.kind === 288; } - ts.isJSXTagName = isJSXTagName; - function isPartOfExpression(node) { - switch (node.kind) { - case 97: - case 95: - case 93: - case 99: - case 84: - case 10: - case 170: - case 171: - case 172: - case 173: - case 174: - case 175: - case 176: - case 195: - case 177: - case 196: - case 178: - case 179: - case 192: - case 180: - case 183: - case 181: - case 182: - case 185: - case 186: - case 187: - case 188: - case 191: - case 189: - case 11: - case 193: - case 241: - case 242: - case 190: - case 184: - return true; - case 139: - while (node.parent.kind === 139) { - node = node.parent; - } - return node.parent.kind === 158 || isJSXTagName(node); - case 69: - if (node.parent.kind === 158 || isJSXTagName(node)) { - return true; - } - case 8: - case 9: - case 97: - var parent_4 = node.parent; - switch (parent_4.kind) { - case 218: - case 142: - case 145: - case 144: - case 255: - case 253: - case 169: - return parent_4.initializer === node; - case 202: - case 203: - case 204: - case 205: - case 211: - case 212: - case 213: - case 249: - case 215: - case 213: - return parent_4.expression === node; - case 206: - var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || - forStatement.condition === node || - forStatement.incrementor === node; - case 207: - case 208: - var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || - forInStatement.expression === node; - case 177: - case 195: - return node === parent_4.expression; - case 197: - return node === parent_4.expression; - case 140: - return node === parent_4.expression; - case 143: - case 248: - case 247: - return true; - case 194: - return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); - default: - if (isPartOfExpression(parent_4)) { - return true; - } - } - } - return false; + ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; + function isNotEmittedStatement(node) { + return node.kind === 287; } - ts.isPartOfExpression = isPartOfExpression; - function isInstantiatedModule(node, preserveConstEnums) { - var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 || - (preserveConstEnums && moduleState === 2); + ts.isNotEmittedStatement = isNotEmittedStatement; + function isNotEmittedOrPartiallyEmittedNode(node) { + return isNotEmittedStatement(node) + || isPartiallyEmittedExpression(node); } - ts.isInstantiatedModule = isInstantiatedModule; - function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind === 240; + ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; + function isOmittedExpression(node) { + return node.kind === 194; } - ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; - function getExternalModuleImportEqualsDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node)); - return node.moduleReference.expression; + ts.isOmittedExpression = isOmittedExpression; + function isTemplateSpan(node) { + return node.kind === 198; } - ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; - function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind !== 240; + ts.isTemplateSpan = isTemplateSpan; + function isBlock(node) { + return node.kind === 200; } - ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; - function isSourceFileJavaScript(file) { - return isInJavaScriptFile(file); + ts.isBlock = isBlock; + function isConciseBody(node) { + return isBlock(node) + || isExpression(node); } - ts.isSourceFileJavaScript = isSourceFileJavaScript; - function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576); + ts.isConciseBody = isConciseBody; + function isFunctionBody(node) { + return isBlock(node); } - ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 174 && - expression.expression.kind === 69 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + ts.isFunctionBody = isFunctionBody; + function isForInitializer(node) { + return isVariableDeclarationList(node) + || isExpression(node); } - ts.isRequireCall = isRequireCall; - function isSingleOrDoubleQuote(charCode) { - return charCode === 39 || charCode === 34; + ts.isForInitializer = isForInitializer; + function isVariableDeclaration(node) { + return node.kind === 219; } - ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218) { - var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179; - } - return false; + ts.isVariableDeclaration = isVariableDeclaration; + function isVariableDeclarationList(node) { + return node.kind === 220; } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; - function getSpecialPropertyAssignmentKind(expression) { - if (!isInJavaScriptFile(expression)) { - return 0; - } - if (expression.kind !== 187) { - return 0; - } - var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 172) { - return 0; - } - var lhs = expr.left; - if (lhs.expression.kind === 69) { - var lhsId = lhs.expression; - if (lhsId.text === "exports") { - return 1; - } - else if (lhsId.text === "module" && lhs.name.text === "exports") { - return 2; - } - } - else if (lhs.expression.kind === 97) { - return 4; - } - else if (lhs.expression.kind === 172) { - var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69) { - var innerPropertyAccessIdentifier = innerPropertyAccess.expression; - if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { - return 1; - } - if (innerPropertyAccess.name.text === "prototype") { - return 3; - } - } - } - return 0; + ts.isVariableDeclarationList = isVariableDeclarationList; + function isCaseBlock(node) { + return node.kind === 228; } - ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; - function getExternalModuleName(node) { - if (node.kind === 230) { - return node.moduleSpecifier; - } - if (node.kind === 229) { - var reference = node.moduleReference; - if (reference.kind === 240) { - return reference.expression; - } - } - if (node.kind === 236) { - return node.moduleSpecifier; - } - if (node.kind === 225 && node.name.kind === 9) { - return node.name; - } + ts.isCaseBlock = isCaseBlock; + function isModuleBody(node) { + var kind = node.kind; + return kind === 227 + || kind === 226; } - ts.getExternalModuleName = getExternalModuleName; - function getNamespaceDeclarationNode(node) { - if (node.kind === 229) { - return node; - } - var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232) { - return importClause.namedBindings; - } + ts.isModuleBody = isModuleBody; + function isImportEqualsDeclaration(node) { + return node.kind === 230; } - ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; - function isDefaultImport(node) { - return node.kind === 230 - && node.importClause - && !!node.importClause.name; + ts.isImportEqualsDeclaration = isImportEqualsDeclaration; + function isImportClause(node) { + return node.kind === 232; } - ts.isDefaultImport = isDefaultImport; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 142: - case 147: - case 146: - case 254: - case 253: - case 145: - case 144: - return node.questionToken !== undefined; - } - } - return false; + ts.isImportClause = isImportClause; + function isNamedImportBindings(node) { + var kind = node.kind; + return kind === 234 + || kind === 233; } - ts.hasQuestionToken = hasQuestionToken; - function isJSDocConstructSignature(node) { - return node.kind === 269 && - node.parameters.length > 0 && - node.parameters[0].type.kind === 271; + ts.isNamedImportBindings = isNamedImportBindings; + function isImportSpecifier(node) { + return node.kind === 235; } - ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind, checkParentVariableStatement) { - if (!node) { - return undefined; - } - var jsDocTags = getJSDocTags(node, checkParentVariableStatement); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { - var tag = jsDocTags_1[_i]; - if (tag.kind === kind) { - return tag; - } - } + ts.isImportSpecifier = isImportSpecifier; + function isNamedExports(node) { + return node.kind === 238; } - function append(previous, additional) { - if (additional) { - if (!previous) { - previous = []; - } - for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { - var x = additional_1[_i]; - previous.push(x); - } - } - return previous; + ts.isNamedExports = isNamedExports; + function isExportSpecifier(node) { + return node.kind === 239; } - function getJSDocComments(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); + ts.isExportSpecifier = isExportSpecifier; + function isModuleOrEnumDeclaration(node) { + return node.kind === 226 || node.kind === 225; } - ts.getJSDocComments = getJSDocComments; - function getJSDocTags(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { - var result = []; - for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { - var doc = docs_1[_i]; - if (doc.tags) { - result.push.apply(result, doc.tags); - } - } - return result; - }, function (tags) { return tags; }); - } - function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { - var result = undefined; - if (checkParentVariableStatement) { - var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && - (node.parent).initializer === node && - node.parent.parent.parent.kind === 200; - var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200; - var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : - isVariableOfVariableDeclarationStatement ? node.parent.parent : - undefined; - if (variableStatementNode) { - result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); - } - if (node.kind === 225 && - node.parent && node.parent.kind === 225) { - result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); - } - var parent_5 = node.parent; - var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && - parent_5.kind === 187 && - parent_5.operatorToken.kind === 56 && - parent_5.parent.kind === 202; - if (isSourceOfAssignmentExpressionStatement) { - result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); - } - var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; - if (isPropertyAssignmentExpression) { - result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); - } - if (node.kind === 142) { - var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); - if (paramTags) { - result = append(result, getTags(paramTags)); - } - } - } - if (isVariableLike(node) && node.initializer) { - result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); - } - if (node.jsDocComments) { - if (result) { - result = append(result, getDocs(node.jsDocComments)); - } - else { - return getDocs(node.jsDocComments); - } - } - return result; + ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; + function isDeclarationKind(kind) { + return kind === 181 + || kind === 170 + || kind === 222 + || kind === 193 + || kind === 149 + || kind === 225 + || kind === 255 + || kind === 239 + || kind === 221 + || kind === 180 + || kind === 150 + || kind === 232 + || kind === 230 + || kind === 235 + || kind === 223 + || kind === 148 + || kind === 147 + || kind === 226 + || kind === 229 + || kind === 233 + || kind === 143 + || kind === 253 + || kind === 146 + || kind === 145 + || kind === 151 + || kind === 254 + || kind === 224 + || kind === 142 + || kind === 219 + || kind === 279; } - function getJSDocParameterTag(param, checkParentVariableStatement) { - var func = param.parent; - var tags = getJSDocTags(func, checkParentVariableStatement); - if (!param.name) { - var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275; }); - if (paramTags && 0 <= i && i < paramTags.length) { - return [paramTags[i]]; - } - } - else if (param.name.kind === 69) { - var name_9 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); - if (paramTags) { - return paramTags; - } - } - else { - return undefined; - } + function isDeclarationStatementKind(kind) { + return kind === 221 + || kind === 240 + || kind === 222 + || kind === 223 + || kind === 224 + || kind === 225 + || kind === 226 + || kind === 231 + || kind === 230 + || kind === 237 + || kind === 236 + || kind === 229; } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); + function isStatementKindButNotDeclarationKind(kind) { + return kind === 211 + || kind === 210 + || kind === 218 + || kind === 205 + || kind === 203 + || kind === 202 + || kind === 208 + || kind === 209 + || kind === 207 + || kind === 204 + || kind === 215 + || kind === 212 + || kind === 214 + || kind === 216 + || kind === 217 + || kind === 201 + || kind === 206 + || kind === 213 + || kind === 287; } - ts.getJSDocTypeTag = getJSDocTypeTag; - function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); + function isDeclaration(node) { + return isDeclarationKind(node.kind); } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); + ts.isDeclaration = isDeclaration; + function isDeclarationStatement(node) { + return isDeclarationStatementKind(node.kind); } - ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { - var parameterName = parameter.name.text; - var jsDocTags = getJSDocTags(parameter.parent, true); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { - var tag = jsDocTags_2[_i]; - if (tag.kind === 275) { - var parameterTag = tag; - if (parameterTag.parameterName.text === parameterName) { - return parameterTag; - } - } - } - } - return undefined; + ts.isDeclarationStatement = isDeclarationStatement; + function isStatementButNotDeclaration(node) { + return isStatementKindButNotDeclarationKind(node.kind); } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; - function hasRestParameter(s) { - return isRestParameter(ts.lastOrUndefined(s.parameters)); + ts.isStatementButNotDeclaration = isStatementButNotDeclaration; + function isStatement(node) { + var kind = node.kind; + return isStatementKindButNotDeclarationKind(kind) + || isDeclarationStatementKind(kind) + || kind === 200; } - ts.hasRestParameter = hasRestParameter; - function hasDeclaredRestParameter(s) { - return isDeclaredRestParam(ts.lastOrUndefined(s.parameters)); + ts.isStatement = isStatement; + function isModuleReference(node) { + var kind = node.kind; + return kind === 241 + || kind === 140 + || kind === 70; } - ts.hasDeclaredRestParameter = hasDeclaredRestParameter; - function isRestParameter(node) { - if (node && (node.flags & 1048576)) { - if (node.type && node.type.kind === 270) { - return true; - } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; - } - } - return isDeclaredRestParam(node); + ts.isModuleReference = isModuleReference; + function isJsxOpeningElement(node) { + return node.kind === 244; } - ts.isRestParameter = isRestParameter; - function isDeclaredRestParam(node) { - return node && node.dotDotDotToken !== undefined; + ts.isJsxOpeningElement = isJsxOpeningElement; + function isJsxClosingElement(node) { + return node.kind === 245; } - ts.isDeclaredRestParam = isDeclaredRestParam; - function isAssignmentTarget(node) { - while (node.parent.kind === 178) { - node = node.parent; - } - while (true) { - var parent_6 = node.parent; - if (parent_6.kind === 170 || parent_6.kind === 191) { - node = parent_6; - continue; - } - if (parent_6.kind === 253 || parent_6.kind === 254) { - node = parent_6.parent; - continue; - } - return parent_6.kind === 187 && - isAssignmentOperator(parent_6.operatorToken.kind) && - parent_6.left === node || - (parent_6.kind === 207 || parent_6.kind === 208) && - parent_6.initializer === node; - } + ts.isJsxClosingElement = isJsxClosingElement; + function isJsxTagNameExpression(node) { + var kind = node.kind; + return kind === 98 + || kind === 70 + || kind === 173; } - ts.isAssignmentTarget = isAssignmentTarget; - function isNodeDescendantOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; + ts.isJsxTagNameExpression = isJsxTagNameExpression; + function isJsxChild(node) { + var kind = node.kind; + return kind === 242 + || kind === 248 + || kind === 243 + || kind === 10; } - ts.isNodeDescendantOf = isNodeDescendantOf; - function isInAmbientContext(node) { - while (node) { - if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { - return true; - } - node = node.parent; - } - return false; + ts.isJsxChild = isJsxChild; + function isJsxAttributeLike(node) { + var kind = node.kind; + return kind === 246 + || kind === 247; } - ts.isInAmbientContext = isInAmbientContext; - function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { - return false; - } - var parent = name.parent; - if (parent.kind === 234 || parent.kind === 238) { - if (parent.propertyName) { - return true; - } - } - if (isDeclaration(parent)) { - return parent.name === name; - } - return false; + ts.isJsxAttributeLike = isJsxAttributeLike; + function isJsxSpreadAttribute(node) { + return node.kind === 247; } - ts.isDeclarationName = isDeclarationName; - function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 140 && - isDeclaration(node.parent.parent); + ts.isJsxSpreadAttribute = isJsxSpreadAttribute; + function isJsxAttribute(node) { + return node.kind === 246; } - ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; - function isIdentifierName(node) { - var parent = node.parent; - switch (parent.kind) { - case 145: - case 144: - case 147: - case 146: - case 149: - case 150: - case 255: - case 253: - case 172: - return parent.name === node; - case 139: - if (parent.right === node) { - while (parent.kind === 139) { - parent = parent.parent; - } - return parent.kind === 158; - } - return false; - case 169: - case 234: - return parent.propertyName === node; - case 238: - return true; - } - return false; + ts.isJsxAttribute = isJsxAttribute; + function isStringLiteralOrJsxExpression(node) { + var kind = node.kind; + return kind === 9 + || kind === 248; } - ts.isIdentifierName = isIdentifierName; - function isAliasSymbolDeclaration(node) { - return node.kind === 229 || - node.kind === 228 || - node.kind === 231 && !!node.name || - node.kind === 232 || - node.kind === 234 || - node.kind === 238 || - node.kind === 235 && exportAssignmentIsAlias(node); + ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isCaseOrDefaultClause(node) { + var kind = node.kind; + return kind === 249 + || kind === 250; } - ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - return isEntityNameExpression(node.expression); + ts.isCaseOrDefaultClause = isCaseOrDefaultClause; + function isHeritageClause(node) { + return node.kind === 251; } - ts.exportAssignmentIsAlias = exportAssignmentIsAlias; - function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; + ts.isHeritageClause = isHeritageClause; + function isCatchClause(node) { + return node.kind === 252; } - ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); - return heritageClause ? heritageClause.types : undefined; + ts.isCatchClause = isCatchClause; + function isPropertyAssignment(node) { + return node.kind === 253; } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); - return heritageClause ? heritageClause.types : undefined; + ts.isPropertyAssignment = isPropertyAssignment; + function isShorthandPropertyAssignment(node) { + return node.kind === 254; } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { - var clause = clauses_1[_i]; - if (clause.token === kind) { - return clause; - } - } - } - return undefined; + ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; + function isEnumMember(node) { + return node.kind === 255; } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(host, sourceFile, reference) { - if (!host.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - return host.getSourceFile(referenceFileName); - } + ts.isEnumMember = isEnumMember; + function isSourceFile(node) { + return node.kind === 256; } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - return undefined; + ts.isSourceFile = isSourceFile; + function isWatchSet(options) { + return options.watch && options.hasOwnProperty("watch"); } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.test(comment)) { - if (isNoDefaultLibRegEx.test(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var refMatchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - var refLibResult = !refMatchResult && ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment); - if (refMatchResult || refLibResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - fileName: (refMatchResult || refLibResult)[3] - }, - isNoDefaultLib: false, - isTypeReferenceDirective: !!refLibResult - }; - } - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } + ts.isWatchSet = isWatchSet; +})(ts || (ts = {})); +(function (ts) { + function getDefaultLibFileName(options) { + switch (options.target) { + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 70 <= token && token <= 138; } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 <= token && token <= 7; - } - ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + ts.getDefaultLibFileName = getDefaultLibFileName; + function textSpanEnd(span) { + return span.start + span.length; } - ts.isAsyncFunctionLike = isAsyncFunctionLike; - function isStringOrNumericLiteral(kind) { - return kind === 9 || kind === 8; + ts.textSpanEnd = textSpanEnd; + function textSpanIsEmpty(span) { + return span.length === 0; } - ts.isStringOrNumericLiteral = isStringOrNumericLiteral; - function hasDynamicName(declaration) { - return declaration.name && isDynamicName(declaration.name); + ts.textSpanIsEmpty = textSpanIsEmpty; + function textSpanContainsPosition(span, position) { + return position >= span.start && position < textSpanEnd(span); } - ts.hasDynamicName = hasDynamicName; - function isDynamicName(name) { - return name.kind === 140 && - !isStringOrNumericLiteral(name.expression.kind) && - !isWellKnownSymbolSyntactically(name.expression); + ts.textSpanContainsPosition = textSpanContainsPosition; + function textSpanContainsTextSpan(span, other) { + return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); } - ts.isDynamicName = isDynamicName; - function isWellKnownSymbolSyntactically(node) { - return isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); + ts.textSpanContainsTextSpan = textSpanContainsTextSpan; + function textSpanOverlapsWith(span, other) { + var overlapStart = Math.max(span.start, other.start); + var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); + return overlapStart < overlapEnd; } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; - function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) { - return name.text; - } - if (name.kind === 140) { - var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - var rightHandSideName = nameExpression.name.text; - return getPropertyNameForKnownSymbolName(rightHandSideName); - } - else if (nameExpression.kind === 9 || nameExpression.kind === 8) { - return nameExpression.text; - } + ts.textSpanOverlapsWith = textSpanOverlapsWith; + function textSpanOverlap(span1, span2) { + var overlapStart = Math.max(span1.start, span2.start); + var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (overlapStart < overlapEnd) { + return createTextSpanFromBounds(overlapStart, overlapEnd); } return undefined; } - ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; + ts.textSpanOverlap = textSpanOverlap; + function textSpanIntersectsWithTextSpan(span, other) { + return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; - function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; + ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; + function textSpanIntersectsWith(span, start, length) { + var end = start + length; + return start <= textSpanEnd(span) && end >= span.start; } - ts.isESSymbolIdentifier = isESSymbolIdentifier; - function isModifierKind(token) { - switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 128: - case 113: - return true; - } - return false; + ts.textSpanIntersectsWith = textSpanIntersectsWith; + function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { + var end1 = start1 + length1; + var end2 = start2 + length2; + return start2 <= end1 && end2 >= start1; } - ts.isModifierKind = isModifierKind; - function isParameterDeclaration(node) { - var root = getRootDeclaration(node); - return root.kind === 142; + ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; + function textSpanIntersectsWithPosition(span, position) { + return position <= textSpanEnd(span) && position >= span.start; } - ts.isParameterDeclaration = isParameterDeclaration; - function getRootDeclaration(node) { - while (node.kind === 169) { - node = node.parent.parent; + ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; + function textSpanIntersection(span1, span2) { + var intersectStart = Math.max(span1.start, span2.start); + var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); + if (intersectStart <= intersectEnd) { + return createTextSpanFromBounds(intersectStart, intersectEnd); } - return node; + return undefined; } - ts.getRootDeclaration = getRootDeclaration; - function nodeStartsNewLexicalEnvironment(node) { - var kind = node.kind; - return kind === 148 - || kind === 179 - || kind === 220 - || kind === 180 - || kind === 147 - || kind === 149 - || kind === 150 - || kind === 225 - || kind === 256; + ts.textSpanIntersection = textSpanIntersection; + function createTextSpan(start, length) { + if (start < 0) { + throw new Error("start < 0"); + } + if (length < 0) { + throw new Error("length < 0"); + } + return { start: start, length: length }; } - ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + ts.createTextSpan = createTextSpan; + function createTextSpanFromBounds(start, end) { + return createTextSpan(start, end - start); } - ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { - if (node) { - while (node.original !== undefined) { - node = node.original; - } - } - return node; + ts.createTextSpanFromBounds = createTextSpanFromBounds; + function textChangeRangeNewSpan(range) { + return createTextSpan(range.span.start, range.newLength); } - ts.getOriginalNode = getOriginalNode; - function isParseTreeNode(node) { - return (node.flags & 8) === 0; + ts.textChangeRangeNewSpan = textChangeRangeNewSpan; + function textChangeRangeIsUnchanged(range) { + return textSpanIsEmpty(range.span) && range.newLength === 0; } - ts.isParseTreeNode = isParseTreeNode; - function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { - return node; + ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; + function createTextChangeRange(span, newLength) { + if (newLength < 0) { + throw new Error("newLength < 0"); } - node = getOriginalNode(node); - if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) { - return node; + return { span: span, newLength: newLength }; + } + ts.createTextChangeRange = createTextChangeRange; + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + function collapseTextChangeRangesAcrossMultipleVersions(changes) { + if (changes.length === 0) { + return ts.unchangedTextChangeRange; } - return undefined; + if (changes.length === 1) { + return changes[0]; + } + var change0 = changes[0]; + var oldStartN = change0.span.start; + var oldEndN = textSpanEnd(change0.span); + var newEndN = oldStartN + change0.newLength; + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + var oldStart2 = nextChange.span.start; + var oldEnd2 = textSpanEnd(nextChange.span); + var newEnd2 = oldStart2 + nextChange.newLength; + oldStartN = Math.min(oldStart1, oldStart2); + oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); } - ts.getParseTreeNode = getParseTreeNode; - function getOriginalSourceFiles(sourceFiles) { - var originalSourceFiles = []; - for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { - var sourceFile = sourceFiles_1[_i]; - var originalSourceFile = getParseTreeNode(sourceFile, isSourceFile); - if (originalSourceFile) { - originalSourceFiles.push(originalSourceFile); + ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; + function getTypeParameterOwner(d) { + if (d && d.kind === 142) { + for (var current = d; current; current = current.parent) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { + return current; + } } } - return originalSourceFiles; - } - ts.getOriginalSourceFiles = getOriginalSourceFiles; - function getOriginalNodeId(node) { - node = getOriginalNode(node); - return node ? ts.getNodeId(node) : 0; } - ts.getOriginalNodeId = getOriginalNodeId; - function getExpressionAssociativity(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; - return getOperatorAssociativity(expression.kind, operator, hasArguments); + ts.getTypeParameterOwner = getTypeParameterOwner; + function isParameterPropertyDeclaration(node) { + return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); } - ts.getExpressionAssociativity = getExpressionAssociativity; - function getOperatorAssociativity(kind, operator, hasArguments) { - switch (kind) { - case 175: - return hasArguments ? 0 : 1; - case 185: - case 182: - case 183: - case 181: - case 184: - case 188: - case 190: - return 1; - case 187: - switch (operator) { - case 38: - case 56: - case 57: - case 58: - case 60: - case 59: - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - case 68: - case 67: - return 1; - } + ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; + function walkUpBindingElementsAndPatterns(node) { + while (node && (node.kind === 170 || ts.isBindingPattern(node))) { + node = node.parent; } - return 0; - } - ts.getOperatorAssociativity = getOperatorAssociativity; - function getExpressionPrecedence(expression) { - var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; - return getOperatorPrecedence(expression.kind, operator, hasArguments); + return node; } - ts.getExpressionPrecedence = getExpressionPrecedence; - function getOperator(expression) { - if (expression.kind === 187) { - return expression.operatorToken.kind; + function getCombinedModifierFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = ts.getModifierFlags(node); + if (node.kind === 219) { + node = node.parent; } - else if (expression.kind === 185 || expression.kind === 186) { - return expression.operator; + if (node && node.kind === 220) { + flags |= ts.getModifierFlags(node); + node = node.parent; } - else { - return expression.kind; + if (node && node.kind === 201) { + flags |= ts.getModifierFlags(node); } + return flags; } - ts.getOperator = getOperator; - function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { - switch (nodeKind) { - case 97: - case 95: - case 69: - case 93: - case 99: - case 84: - case 8: - case 9: - case 170: - case 171: - case 179: - case 180: - case 192: - case 241: - case 242: - case 10: - case 11: - case 189: - case 178: - case 193: - return 19; - case 176: - case 172: - case 173: - return 18; - case 175: - return hasArguments ? 18 : 17; - case 174: - return 17; - case 186: - return 16; - case 185: - case 182: - case 183: - case 181: - case 184: - return 15; - case 187: - switch (operatorKind) { - case 49: - case 50: - return 15; - case 38: - case 37: - case 39: - case 40: - return 14; - case 35: - case 36: - return 13; - case 43: - case 44: - case 45: - return 12; - case 25: - case 28: - case 27: - case 29: - case 90: - case 91: - return 11; - case 30: - case 32: - case 31: - case 33: - return 10; - case 46: - return 9; - case 48: - return 8; - case 47: - return 7; - case 51: - return 6; - case 52: - return 5; - case 56: - case 57: - case 58: - case 60: - case 59: - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - case 68: - case 67: - return 3; - case 24: - return 0; - default: - return -1; - } - case 188: - return 4; - case 190: - return 2; - case 191: - return 1; - default: - return -1; + ts.getCombinedModifierFlags = getCombinedModifierFlags; + function getCombinedNodeFlags(node) { + node = walkUpBindingElementsAndPatterns(node); + var flags = node.flags; + if (node.kind === 219) { + node = node.parent; } + if (node && node.kind === 220) { + flags |= node.flags; + node = node.parent; + } + if (node && node.kind === 201) { + flags |= node.flags; + } + return flags; } - ts.getOperatorPrecedence = getOperatorPrecedence; - function createDiagnosticCollection() { - var nonFileDiagnostics = []; - var fileDiagnostics = ts.createMap(); - var diagnosticsModified = false; - var modificationCount = 0; - return { - add: add, - getGlobalDiagnostics: getGlobalDiagnostics, - getDiagnostics: getDiagnostics, - getModificationCount: getModificationCount, - reattachFileDiagnostics: reattachFileDiagnostics - }; - function getModificationCount() { - return modificationCount; + ts.getCombinedNodeFlags = getCombinedNodeFlags; +})(ts || (ts = {})); +var ts; +(function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 70; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = ts.createMap({ + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, + }); + var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + function lookupInUnicodeMap(code, map) { + if (code < map[0]) { + return false; } - function reattachFileDiagnostics(newFile) { - if (!ts.hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - for (var _i = 0, _a = fileDiagnostics[newFile.fileName]; _i < _a.length; _i++) { - var diagnostic = _a[_i]; - diagnostic.file = newFile; + var lo = 0; + var hi = map.length; + var mid; + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; } - } - function add(diagnostic) { - var diagnostics; - if (diagnostic.file) { - diagnostics = fileDiagnostics[diagnostic.file.fileName]; - if (!diagnostics) { - diagnostics = []; - fileDiagnostics[diagnostic.file.fileName] = diagnostics; - } + if (code < map[mid]) { + hi = mid; } else { - diagnostics = nonFileDiagnostics; + lo = mid + 2; } - diagnostics.push(diagnostic); - diagnosticsModified = true; - modificationCount++; - } - function getGlobalDiagnostics() { - sortAndDeduplicate(); - return nonFileDiagnostics; } - function getDiagnostics(fileName) { - sortAndDeduplicate(); - if (fileName) { - return fileDiagnostics[fileName] || []; - } - var allDiagnostics = []; - function pushDiagnostic(d) { - allDiagnostics.push(d); - } - ts.forEach(nonFileDiagnostics, pushDiagnostic); - for (var key in fileDiagnostics) { - ts.forEach(fileDiagnostics[key], pushDiagnostic); - } - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + return false; + } + function isUnicodeIdentifierStart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); + } + ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; + function isUnicodeIdentifierPart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); + } + function makeReverseMap(source) { + var result = []; + for (var name_8 in source) { + result[source[name_8]] = name_8; } - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - diagnosticsModified = false; - nonFileDiagnostics = ts.sortAndDeduplicateDiagnostics(nonFileDiagnostics); - for (var key in fileDiagnostics) { - fileDiagnostics[key] = ts.sortAndDeduplicateDiagnostics(fileDiagnostics[key]); + return result; + } + var tokenStrings = makeReverseMap(textToToken); + function tokenToString(t) { + return tokenStrings[t]; + } + ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; + function computeLineStarts(text) { + var result = new Array(); + var pos = 0; + var lineStart = 0; + while (pos < text.length) { + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 13: + if (text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > 127 && isLineBreak(ch)) { + result.push(lineStart); + lineStart = pos; + } + break; } } + result.push(lineStart); + return result; } - ts.createDiagnosticCollection = createDiagnosticCollection; - var escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var escapedCharsMap = ts.createMap({ - "\0": "\\0", - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\r": "\\r", - "\n": "\\n", - "\\": "\\\\", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\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)); + ts.computeLineStarts = computeLineStarts; + function getPositionOfLineAndCharacter(sourceFile, line, character) { + return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); + } + ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; + function computePositionOfLineAndCharacter(lineStarts, line, character) { + ts.Debug.assert(line >= 0 && line < lineStarts.length); + return lineStarts[line] + character; + } + ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; + function getLineStarts(sourceFile) { + return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); + } + ts.getLineStarts = getLineStarts; + function computeLineAndCharacterOfPosition(lineStarts, position) { + var lineNumber = ts.binarySearch(lineStarts, position); + if (lineNumber < 0) { + lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } + return { + line: lineNumber, + character: position - lineStarts[lineNumber] + }; } - ts.escapeString = escapeString; - function isIntrinsicJsxName(name) { - var ch = name.substr(0, 1); - return ch.toLowerCase() === ch; + ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; + function getLineAndCharacterOfPosition(sourceFile, position) { + return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } - ts.isIntrinsicJsxName = isIntrinsicJsxName; - function get16BitUnicodeEscapeSequence(charCode) { - var hexCharCode = charCode.toString(16).toUpperCase(); - var paddedHexCode = ("0000" + hexCharCode).slice(-4); - return "\\u" + paddedHexCode; + ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function isWhiteSpace(ch) { + return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - var nonAsciiCharacters = /[^\u0000-\u007F]/g; - function escapeNonAsciiCharacters(s) { - return nonAsciiCharacters.test(s) ? - s.replace(nonAsciiCharacters, function (c) { return get16BitUnicodeEscapeSequence(c.charCodeAt(0)); }) : - s; + ts.isWhiteSpace = isWhiteSpace; + function isWhiteSpaceSingleLine(ch) { + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; } - ts.escapeNonAsciiCharacters = escapeNonAsciiCharacters; - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; + ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; + function isLineBreak(ch) { + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; + ts.isLineBreak = isLineBreak; + function isDigit(ch) { + return ch >= 48 && ch <= 57; } - ts.getIndentSize = getIndentSize; - function createTextWriter(newLine) { - var output; - var indent; - var lineStart; - var lineCount; - var linePos; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function reset() { - output = ""; - indent = 0; - lineStart = true; - lineCount = 0; - linePos = 0; + function isOctalDigit(ch) { + return ch >= 48 && ch <= 55; + } + ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + case 35: + return pos === 0; + default: + return ch > 127; } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; + } + ts.couldStartTrivia = couldStartTrivia; + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { + if (stopAtComments === void 0) { stopAtComments = false; } + if (ts.positionIsSynthesized(pos)) { + return pos; + } + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + if (stopAtComments) { + break; + } + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; + case 60: + case 61: + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + pos++; + continue; + } + break; } + return pos; } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + } + ts.skipTrivia = skipTrivia; + var mergeConflictMarkerLength = "<<<<<<<".length; + function isConflictMarkerTrivia(text, pos) { + ts.Debug.assert(pos >= 0); + 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++) { + if (text.charCodeAt(pos + i) !== ch) { + return false; + } } + return ch === 61 || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32; } } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; + return false; + } + function scanConflictMarkerTrivia(text, pos, error) { + if (error) { + error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); + } + var ch = text.charCodeAt(pos); + var len = text.length; + if (ch === 60 || ch === 62) { + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; } } - function writeTextOfNode(text, node) { - write(getTextOfNodeFromSourceText(text, node)); + else { + ts.Debug.assert(ch === 61); + while (pos < len) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { + break; + } + pos++; + } } - reset(); - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { indent++; }, - decreaseIndent: function () { indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; }, - isAtStartOfLine: function () { return lineStart; }, - reset: reset - }; - } - ts.createTextWriter = createTextWriter; - function getResolvedExternalModuleName(host, file) { - return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + return pos; } - ts.getResolvedExternalModuleName = getResolvedExternalModuleName; - function getExternalModuleNameFromDeclaration(host, resolver, declaration) { - var file = resolver.getExternalModuleFileFromDeclaration(declaration); - if (!file || isDeclarationFile(file)) { - return undefined; - } - return getResolvedExternalModuleName(host, file); + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); } - ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; - function getExternalModuleNameFromPath(host, fileName) { - var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = ts.toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); - var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); - var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); - return ts.removeFileExtension(relativePath); + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; } - ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath; - function getOwnEmitOutputFilePath(sourceFile, host, extension) { - var compilerOptions = host.getCompilerOptions(); - var emitOutputFilePathWithoutExtension; - if (compilerOptions.outDir) { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir)); + function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { + var pendingPos; + var pendingEnd; + var pendingKind; + var pendingHasTrailingNewLine; + var hasPendingCommentRange = false; + var collecting = trailing || pos === 0; + var accumulator = initial; + scan: while (pos >= 0 && pos < text.length) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (trailing) { + break scan; + } + collecting = true; + if (hasPendingCommentRange) { + pendingHasTrailingNewLine = true; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + var nextChar = text.charCodeAt(pos + 1); + var hasTrailingNewLine = false; + if (nextChar === 47 || nextChar === 42) { + var kind = nextChar === 47 ? 2 : 3; + var startPos = pos; + pos += 2; + if (nextChar === 47) { + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + hasTrailingNewLine = true; + break; + } + pos++; + } + } + else { + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + } + if (collecting) { + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + if (!reduce && accumulator) { + return accumulator; + } + hasPendingCommentRange = false; + } + pendingPos = startPos; + pendingEnd = pos; + pendingKind = kind; + pendingHasTrailingNewLine = hasTrailingNewLine; + hasPendingCommentRange = true; + } + continue; + } + break scan; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + if (hasPendingCommentRange && isLineBreak(ch)) { + pendingHasTrailingNewLine = true; + } + pos++; + continue; + } + break scan; + } } - else { - emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); } - return emitOutputFilePathWithoutExtension + extension; + return accumulator; } - ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath; - function getDeclarationEmitOutputFilePath(sourceFile, host) { - var options = host.getCompilerOptions(); - var outputDir = options.declarationDir || options.outDir; - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; + function forEachLeadingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, false, cb, state); } - ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getSourceFilesToEmit(host, targetSourceFile) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - var moduleKind = ts.getEmitModuleKind(options); - var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); - return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); - } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - return ts.filter(sourceFiles, isNonDeclarationFile); + ts.forEachLeadingCommentRange = forEachLeadingCommentRange; + function forEachTrailingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, true, cb, state); + } + ts.forEachTrailingCommentRange = forEachTrailingCommentRange; + function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, false, cb, state, initial); + } + ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; + function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, true, cb, state, initial); + } + ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { + if (!comments) { + comments = []; } + comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + return comments; } - ts.getSourceFilesToEmit = getSourceFilesToEmit; - function isNonDeclarationFile(sourceFile) { - return !isDeclarationFile(sourceFile); + function getLeadingCommentRanges(text, pos) { + return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - function isBundleEmitNonExternalModule(sourceFile) { - return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); } - function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; + function isIdentifierStart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); + } + ts.isIdentifierStart = isIdentifierStart; + function isIdentifierPart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); + } + ts.isIdentifierPart = isIdentifierPart; + function isIdentifierText(name, languageVersion) { + if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + return false; } - else { - for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { - var sourceFile = sourceFiles_2[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } + for (var i = 1, n = name.length; i < n; i++) { + if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + return false; } } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } + return true; + } + ts.isIdentifierText = isIdentifierText; + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0; } + var pos; + var end; + var startPos; + var tokenPos; + var token; + var tokenValue; + var precedingLineBreak; + var hasExtendedUnicodeEscape; + var tokenIsUnterminated; + setText(text, start, length); + return { + getStartPos: function () { return startPos; }, + getTextPos: function () { return pos; }, + getToken: function () { return token; }, + getTokenPos: function () { return tokenPos; }, + getTokenText: function () { return text.substring(tokenPos, pos); }, + getTokenValue: function () { return tokenValue; }, + hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, + hasPrecedingLineBreak: function () { return precedingLineBreak; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, + isUnterminated: function () { return tokenIsUnterminated; }, + reScanGreaterToken: reScanGreaterToken, + reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + scanJsxAttributeValue: scanJsxAttributeValue, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, + scan: scan, + getText: getText, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead, + scanRange: scanRange, + }; + function error(message, length) { + if (onError) { + onError(message, length || 0); + } + } + function scanNumber() { + var start = pos; + while (isDigit(text.charCodeAt(pos))) + pos++; + if (text.charCodeAt(pos) === 46) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + } + var end = pos; + if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { + pos++; + if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) + pos++; + if (isDigit(text.charCodeAt(pos))) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + end = pos; } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; + else { + error(ts.Diagnostics.Digit_expected); } } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); + return "" + +(text.substring(start, end)); } - function onBundledEmit(host, sourceFiles) { - if (sourceFiles.length) { - var jsFilePath = options.outFile || options.out; - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; - action(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, true); + function scanOctalDigits() { + var start = pos; + while (isOctalDigit(text.charCodeAt(pos))) { + pos++; } + return +(text.substring(start, pos)); } - } - ts.forEachTransformedEmitFile = forEachTransformedEmitFile; - function getSourceMapFilePath(jsFilePath, options) { - return options.sourceMap ? jsFilePath + ".map" : undefined; - } - function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { - var options = host.getCompilerOptions(); - if (options.outFile || options.out) { - onBundledEmit(host); + function scanExactNumberOfHexDigits(count) { + return scanHexDigits(count, false); } - else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var sourceFile = sourceFiles_3[_i]; - if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { - onSingleFileEmit(host, sourceFile); - } - } + function scanMinimumNumberOfHexDigits(count) { + return scanHexDigits(count, true); } - function onSingleFileEmit(host, sourceFile) { - var extension = ".js"; - if (options.jsx === 1) { - if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { - extension = ".jsx"; - } + function scanHexDigits(minCount, scanAsManyAsPossible) { + var digits = 0; + var value = 0; + while (digits < minCount || scanAsManyAsPossible) { + var ch = text.charCodeAt(pos); + if (ch >= 48 && ch <= 57) { + value = value * 16 + ch - 48; } - else if (sourceFile.languageVariant === 1) { - extension = ".jsx"; + else if (ch >= 65 && ch <= 70) { + value = value * 16 + ch - 65 + 10; } + else if (ch >= 97 && ch <= 102) { + value = value * 16 + ch - 97 + 10; + } + else { + break; + } + pos++; + digits++; } - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: declarationFilePath - }; - action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); - } - function onBundledEmit(host) { - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (!ts.isExternalModule(sourceFile) || - !!ts.getEmitModuleKind(options)); }); - if (bundledSources.length) { - var jsFilePath = options.outFile || options.out; - var emitFileNames = { - jsFilePath: jsFilePath, - sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined - }; - action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); + if (digits < minCount) { + value = -1; } + return value; } - } - ts.forEachExpectedEmitFile = forEachExpectedEmitFile; - function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); - var commonSourceDirectory = host.getCommonSourceDirectory(); - var isSourceFileInCommonSourceDirectory = host.getCanonicalFileName(sourceFilePath).indexOf(host.getCanonicalFileName(commonSourceDirectory)) === 0; - sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath; - return ts.combinePaths(newDirPath, sourceFilePath); - } - ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir; - function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) { - host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage)); - }, sourceFiles); - } - ts.writeFile = writeFile; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; - } - ts.getLineOfLocalPosition = getLineOfLocalPosition; - function getLineOfLocalPositionFromLineMap(lineMap, pos) { - return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; - } - ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 148 && nodeIsPresent(member.body)) { - return member; + function scanString(allowEscapes) { + if (allowEscapes === void 0) { allowEscapes = true; } + var quote = text.charCodeAt(pos); + pos++; + var result = ""; + var start = pos; + while (true) { + if (pos >= end) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + var ch = text.charCodeAt(pos); + if (ch === quote) { + result += text.substring(start, pos); + pos++; + break; + } + if (ch === 92 && allowEscapes) { + result += text.substring(start, pos); + result += scanEscapeSequence(); + start = pos; + continue; + } + if (isLineBreak(ch)) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + pos++; } - }); - } - ts.getFirstConstructorWithBody = getFirstConstructorWithBody; - function getSetAccessorTypeAnnotationNode(accessor) { - if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); - return accessor.parameters[hasThis ? 1 : 0].type; + return result; } - } - ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; - function getThisParameter(signature) { - if (signature.parameters.length) { - var thisParameter = signature.parameters[0]; - if (parameterIsThisKeyword(thisParameter)) { - return thisParameter; + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96; + pos++; + var start = pos; + var contents = ""; + var resultingToken; + while (true) { + if (pos >= end) { + contents += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_template_literal); + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + var currChar = text.charCodeAt(pos); + if (currChar === 96) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { + contents += text.substring(start, pos); + pos += 2; + resultingToken = startedWithBacktick ? 13 : 14; + break; + } + if (currChar === 92) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + if (currChar === 13) { + contents += text.substring(start, pos); + pos++; + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + contents += "\n"; + start = pos; + continue; + } + pos++; } + ts.Debug.assert(resultingToken !== undefined); + tokenValue = contents; + return resultingToken; } - } - ts.getThisParameter = getThisParameter; - function parameterIsThisKeyword(parameter) { - return isThisIdentifier(parameter.name); - } - ts.parameterIsThisKeyword = parameterIsThisKeyword; - function isThisIdentifier(node) { - return node && node.kind === 69 && identifierIsThisKeyword(node); - } - ts.isThisIdentifier = isThisIdentifier; - function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97; - } - ts.identifierIsThisKeyword = identifierIsThisKeyword; - function getAllAccessorDeclarations(declarations, accessor) { - var firstAccessor; - var secondAccessor; - var getAccessor; - var setAccessor; - if (hasDynamicName(accessor)) { - firstAccessor = accessor; - if (accessor.kind === 149) { - getAccessor = accessor; + function scanEscapeSequence() { + pos++; + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + return ""; } - else if (accessor.kind === 150) { - setAccessor = accessor; + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 48: + return "\0"; + case 98: + return "\b"; + case 116: + return "\t"; + case 110: + return "\n"; + case 118: + return "\v"; + case 102: + return "\f"; + case 114: + return "\r"; + case 39: + return "\'"; + case 34: + return "\""; + case 117: + if (pos < end && text.charCodeAt(pos) === 123) { + hasExtendedUnicodeEscape = true; + pos++; + return scanExtendedUnicodeEscape(); + } + return scanHexadecimalEscape(4); + case 120: + return scanHexadecimalEscape(2); + case 13: + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + case 8232: + case 8233: + return ""; + default: + return String.fromCharCode(ch); + } + } + function scanHexadecimalEscape(numDigits) { + var escapedValue = scanExactNumberOfHexDigits(numDigits); + if (escapedValue >= 0) { + return String.fromCharCode(escapedValue); } else { - ts.Debug.fail("Accessor has wrong kind"); + error(ts.Diagnostics.Hexadecimal_digit_expected); + return ""; } } - else { - ts.forEach(declarations, function (member) { - if ((member.kind === 149 || member.kind === 150) - && hasModifier(member, 32) === hasModifier(accessor, 32)) { - var memberName = getPropertyNameForPropertyNameNode(member.name); - var accessorName = getPropertyNameForPropertyNameNode(accessor.name); - if (memberName === accessorName) { - if (!firstAccessor) { - firstAccessor = member; - } - else if (!secondAccessor) { - secondAccessor = member; - } - if (member.kind === 149 && !getAccessor) { - getAccessor = member; - } - if (member.kind === 150 && !setAccessor) { - setAccessor = member; - } - } - } - }); - } - return { - firstAccessor: firstAccessor, - secondAccessor: secondAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - ts.getAllAccessorDeclarations = getAllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) { - emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments); - } - ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) { - if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) { - if (pos !== commentPos && - getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) { - writer.writeLine(); - } - } - ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition; - function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) { - if (comments && comments.length > 0) { - if (leadingSeparator) { - writer.write(" "); + function scanExtendedUnicodeEscape() { + var escapedValue = scanMinimumNumberOfHexDigits(1); + var isInvalidExtendedEscape = false; + if (escapedValue < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + isInvalidExtendedEscape = true; } - var emitInterveningSeparator = false; - for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { - var comment = comments_1[_i]; - if (emitInterveningSeparator) { - writer.write(" "); - emitInterveningSeparator = false; - } - writeComment(text, lineMap, writer, comment.pos, comment.end, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else { - emitInterveningSeparator = true; - } + else if (escapedValue > 0x10FFFF) { + error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); + isInvalidExtendedEscape = true; } - if (emitInterveningSeparator && trailingSeparator) { - writer.write(" "); + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + isInvalidExtendedEscape = true; + } + else if (text.charCodeAt(pos) === 125) { + pos++; + } + else { + error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); + isInvalidExtendedEscape = true; + } + if (isInvalidExtendedEscape) { + return ""; } + return utf16EncodeAsString(escapedValue); } - } - ts.emitComments = emitComments; - function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) { - var leadingComments; - var currentDetachedCommentInfo; - if (removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment); + function utf16EncodeAsString(codePoint) { + ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); + if (codePoint <= 65535) { + return String.fromCharCode(codePoint); } + var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; + var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; + return String.fromCharCode(codeUnit1, codeUnit2); } - else { - leadingComments = ts.getLeadingCommentRanges(text, node.pos); + function peekUnicodeEscape() { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { + var start_1 = pos; + pos += 2; + var value = scanExactNumberOfHexDigits(4); + pos = start_1; + return value; + } + return -1; } - if (leadingComments) { - var detachedComments = []; - var lastComment = void 0; - for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { - var comment = leadingComments_1[_i]; - if (lastComment) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end); - var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos); - if (commentLine >= lastCommentLine + 2) { + function scanIdentifierParts() { + var result = ""; + var start = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (isIdentifierPart(ch, languageVersion)) { + pos++; + } + else if (ch === 92) { + ch = peekUnicodeEscape(); + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + result += text.substring(start, pos); + result += String.fromCharCode(ch); + pos += 6; + start = pos; } - detachedComments.push(comment); - lastComment = comment; - } - if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); - var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); - emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + else { + break; } } + result += text.substring(start, pos); + return result; } - return currentDetachedCommentInfo; - function isPinnedComment(comment) { - return text.charCodeAt(comment.pos + 1) === 42 && - text.charCodeAt(comment.pos + 2) === 33; - } - } - ts.emitDetachedComments = emitDetachedComments; - function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42) { - var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); - var lineCount = lineMap.length; - var firstCommentLineIndent = void 0; - for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) { - var nextLineStart = (currentLine + 1) === lineCount - ? text.length + 1 - : lineMap[currentLine + 1]; - if (pos !== commentPos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } + function getIdentifierToken() { + var len = tokenValue.length; + if (len >= 2 && len <= 11) { + var ch = tokenValue.charCodeAt(0); + if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { + return token = textToToken[tokenValue]; } - writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(text.substring(commentPos, commentEnd)); - } - } - ts.writeCommentRange = writeCommentRange; - function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { - var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); - if (currentLineText) { - writer.write(currentLineText); - if (end !== commentEnd) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(text, pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; } + return token = 70; } - return currentLineIndent; - } - function hasModifiers(node) { - return getModifierFlags(node) !== 0; - } - ts.hasModifiers = hasModifiers; - function hasModifier(node, flags) { - return (getModifierFlags(node) & flags) !== 0; - } - ts.hasModifier = hasModifier; - function getModifierFlags(node) { - if (node.modifierFlagsCache & 536870912) { - return node.modifierFlagsCache & ~536870912; - } - var flags = 0; - if (node.modifiers) { - for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - flags |= modifierToFlag(modifier.kind); + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; } - } - if (node.flags & 4) { - flags |= 1; - } - node.modifierFlagsCache = flags | 536870912; - return flags; - } - ts.getModifierFlags = getModifierFlags; - function modifierToFlag(token) { - switch (token) { - case 113: return 32; - case 112: return 4; - case 111: return 16; - case 110: return 8; - case 115: return 128; - case 82: return 1; - case 122: return 2; - case 74: return 2048; - case 77: return 512; - case 118: return 256; - case 128: return 64; - } - return 0; - } - ts.modifierToFlag = modifierToFlag; - function isLogicalOperator(token) { - return token === 52 - || token === 51 - || token === 49; - } - ts.isLogicalOperator = isLogicalOperator; - function isAssignmentOperator(token) { - return token >= 56 && token <= 68; - } - ts.isAssignmentOperator = isAssignmentOperator; - function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 && - node.parent.token === 83 && - isClassLike(node.parent.parent)) { - return node.parent.parent; - } - } - ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; - function isDestructuringAssignment(node) { - if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56) { - var kind = node.left.kind; - return kind === 171 - || kind === 170; + if (numberOfDigits === 0) { + return -1; } + return value; } - return false; - } - ts.isDestructuringAssignment = isDestructuringAssignment; - function isSupportedExpressionWithTypeArguments(node) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; - function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; - } - } - function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; - } - ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; - function isEntityNameExpression(node) { - return node.kind === 69 || - node.kind === 172 && isEntityNameExpression(node.expression); - } - ts.isEntityNameExpression = isEntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 && node.parent.right === node) || - (node.parent.kind === 172 && node.parent.name === node); - } - ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 171) { - return expression.properties.length === 0; - } - if (kind === 170) { - return expression.elements.length === 0; - } - return false; - } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; - function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; - } - ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function tryExtractTypeScriptExtension(fileName) { - return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.tryExtractTypeScriptExtension = tryExtractTypeScriptExtension; - function getExpandedCharCodes(input) { - var output = []; - var length = input.length; - for (var i = 0; i < length; i++) { - var charCode = input.charCodeAt(i); - if (charCode < 0x80) { - output.push(charCode); - } - else if (charCode < 0x800) { - output.push((charCode >> 6) | 192); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x10000) { - output.push((charCode >> 12) | 224); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else if (charCode < 0x20000) { - output.push((charCode >> 18) | 240); - output.push(((charCode >> 12) & 63) | 128); - output.push(((charCode >> 6) & 63) | 128); - output.push((charCode & 63) | 128); - } - else { - ts.Debug.assert(false, "Unexpected code point"); - } - } - return output; - } - ts.stringify = typeof JSON !== "undefined" && JSON.stringify - ? JSON.stringify - : stringifyFallback; - function stringifyFallback(value) { - return value === undefined ? undefined : stringifyValue(value); - } - function stringifyValue(value) { - return typeof value === "string" ? "\"" + escapeString(value) + "\"" - : typeof value === "number" ? isFinite(value) ? String(value) : "null" - : typeof value === "boolean" ? value ? "true" : "false" - : typeof value === "object" && value ? ts.isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value) - : "null"; - } - function cycleCheck(cb, value) { - ts.Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON"); - value.__cycle = true; - var result = cb(value); - delete value.__cycle; - return result; - } - function stringifyArray(value) { - return "[" + ts.reduceLeft(value, stringifyElement, "") + "]"; - } - function stringifyElement(memo, value) { - return (memo ? memo + "," : memo) + stringifyValue(value); - } - function stringifyObject(value) { - return "{" + ts.reduceOwnProperties(value, stringifyProperty, "") + "}"; - } - function stringifyProperty(memo, value, key) { - return value === undefined || typeof value === "function" || key === "__cycle" ? memo - : (memo ? memo + "," : memo) + ("\"" + escapeString(key) + "\":" + stringifyValue(value)); - } - var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - function convertToBase64(input) { - var result = ""; - var charCodes = getExpandedCharCodes(input); - var i = 0; - var length = charCodes.length; - var byte1, byte2, byte3, byte4; - while (i < length) { - byte1 = charCodes[i] >> 2; - byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4; - byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6; - byte4 = charCodes[i + 2] & 63; - if (i + 1 >= length) { - byte3 = byte4 = 64; - } - else if (i + 2 >= length) { - byte4 = 64; - } - result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); - i += 3; - } - return result; - } - ts.convertToBase64 = convertToBase64; - var carriageReturnLineFeed = "\r\n"; - var lineFeed = "\n"; - function getNewLineCharacter(options) { - if (options.newLine === 0) { - return carriageReturnLineFeed; - } - else if (options.newLine === 1) { - return lineFeed; - } - else if (ts.sys) { - return ts.sys.newLine; - } - return carriageReturnLineFeed; - } - ts.getNewLineCharacter = getNewLineCharacter; - function isSimpleExpression(node) { - return isSimpleExpressionWorker(node, 0); - } - ts.isSimpleExpression = isSimpleExpression; - function isSimpleExpressionWorker(node, depth) { - if (depth <= 5) { - var kind = node.kind; - if (kind === 9 - || kind === 8 - || kind === 10 - || kind === 11 - || kind === 69 - || kind === 97 - || kind === 95 - || kind === 99 - || kind === 84 - || kind === 93) { - return true; - } - else if (kind === 172) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 173) { - return isSimpleExpressionWorker(node.expression, depth + 1) - && isSimpleExpressionWorker(node.argumentExpression, depth + 1); - } - else if (kind === 185 - || kind === 186) { - return isSimpleExpressionWorker(node.operand, depth + 1); - } - else if (kind === 187) { - return node.operatorToken.kind !== 38 - && isSimpleExpressionWorker(node.left, depth + 1) - && isSimpleExpressionWorker(node.right, depth + 1); - } - else if (kind === 188) { - return isSimpleExpressionWorker(node.condition, depth + 1) - && isSimpleExpressionWorker(node.whenTrue, depth + 1) - && isSimpleExpressionWorker(node.whenFalse, depth + 1); - } - else if (kind === 183 - || kind === 182 - || kind === 181) { - return isSimpleExpressionWorker(node.expression, depth + 1); - } - else if (kind === 170) { - return node.elements.length === 0; - } - else if (kind === 171) { - return node.properties.length === 0; - } - else if (kind === 174) { - if (!isSimpleExpressionWorker(node.expression, depth + 1)) { - return false; - } - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - if (!isSimpleExpressionWorker(argument, depth + 1)) { - return false; - } - } - return true; - } - } - return false; - } - var syntaxKindCache = ts.createMap(); - function formatSyntaxKind(kind) { - var syntaxKindEnum = ts.SyntaxKind; - if (syntaxKindEnum) { - if (syntaxKindCache[kind]) { - return syntaxKindCache[kind]; - } - for (var name_10 in syntaxKindEnum) { - if (syntaxKindEnum[name_10] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; + function scan() { + startPos = pos; + hasExtendedUnicodeEscape = false; + precedingLineBreak = false; + tokenIsUnterminated = false; + while (true) { + tokenPos = pos; + if (pos >= end) { + return token = 1; } - } - } - else { - return kind.toString(); - } - } - ts.formatSyntaxKind = formatSyntaxKind; - function movePos(pos, value) { - return ts.positionIsSynthesized(pos) ? -1 : pos + value; - } - ts.movePos = movePos; - function createRange(pos, end) { - return { pos: pos, end: end }; - } - ts.createRange = createRange; - function moveRangeEnd(range, end) { - return createRange(range.pos, end); - } - ts.moveRangeEnd = moveRangeEnd; - function moveRangePos(range, pos) { - return createRange(pos, range.end); - } - ts.moveRangePos = moveRangePos; - function moveRangePastDecorators(node) { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) - : node; - } - ts.moveRangePastDecorators = moveRangePastDecorators; - function moveRangePastModifiers(node) { - return node.modifiers && node.modifiers.length > 0 - ? moveRangePos(node, node.modifiers.end) - : moveRangePastDecorators(node); - } - ts.moveRangePastModifiers = moveRangePastModifiers; - function isCollapsedRange(range) { - return range.pos === range.end; - } - ts.isCollapsedRange = isCollapsedRange; - function collapseRangeToStart(range) { - return isCollapsedRange(range) ? range : moveRangeEnd(range, range.pos); - } - ts.collapseRangeToStart = collapseRangeToStart; - function collapseRangeToEnd(range) { - return isCollapsedRange(range) ? range : moveRangePos(range, range.end); - } - ts.collapseRangeToEnd = collapseRangeToEnd; - function createTokenRange(pos, token) { - return createRange(pos, pos + ts.tokenToString(token).length); - } - ts.createTokenRange = createTokenRange; - function rangeIsOnSingleLine(range, sourceFile) { - return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile); - } - ts.rangeIsOnSingleLine = rangeIsOnSingleLine; - function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; - function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, range2.end, sourceFile); - } - ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; - function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); - } - ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; - function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); - } - ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; - function positionsAreOnSameLine(pos1, pos2, sourceFile) { - return pos1 === pos2 || - getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); - } - ts.positionsAreOnSameLine = positionsAreOnSameLine; - function getStartPositionOfRange(range, sourceFile) { - return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); - } - ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { - var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportEquals = undefined; - var hasExportStarsToExportValues = false; - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var node = _a[_i]; - switch (node.kind) { - case 230: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { - externalImports.push(node); + var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; } - break; - case 229: - if (node.moduleReference.kind === 240 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); + else { + return token = 6; } - break; - case 236: - if (node.moduleSpecifier) { - if (!node.exportClause) { - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; + } + switch (ch) { + case 10: + case 13: + precedingLineBreak = true; + if (skipTrivia) { + pos++; + continue; + } + else { + if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { + pos += 2; + } + else { + pos++; } + return token = 4; } - else if (resolver.isValueAliasDeclaration(node)) { - externalImports.push(node); + case 9: + case 11: + case 12: + case 32: + if (skipTrivia) { + pos++; + continue; } - } - else { - for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { - var specifier = _c[_b]; - var name_11 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); + else { + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; } - } - break; - case 235: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - } - } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; - } - ts.collectExternalModuleInfo = collectExternalModuleInfo; - function getInitializedVariables(node) { - return ts.filter(node.declarations, isInitializedVariable); - } - ts.getInitializedVariables = getInitializedVariables; - function isInitializedVariable(node) { - return node.initializer !== undefined; - } - function isMergedWithClass(node) { - if (node.symbol) { - for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 221 && declaration !== node) { - return true; - } - } - } - return false; - } - ts.isMergedWithClass = isMergedWithClass; - function isFirstDeclarationOfKind(node, kind) { - return node.symbol && getDeclarationOfKind(node.symbol, kind) === node; - } - ts.isFirstDeclarationOfKind = isFirstDeclarationOfKind; - function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); - } - ts.isNodeArray = isNodeArray; - function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11; - } - ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; - function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isLiteralExpression(node) { - return isLiteralKind(node.kind); - } - ts.isLiteralExpression = isLiteralExpression; - function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateHead(node) { - return node.kind === 12; - } - ts.isTemplateHead = isTemplateHead; - function isTemplateMiddleOrTemplateTail(node) { - var kind = node.kind; - return kind === 13 - || kind === 14; - } - ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; - function isIdentifier(node) { - return node.kind === 69; - } - ts.isIdentifier = isIdentifier; - function isGeneratedIdentifier(node) { - return isIdentifier(node) && node.autoGenerateKind > 0; - } - ts.isGeneratedIdentifier = isGeneratedIdentifier; - function isModifier(node) { - return isModifierKind(node.kind); - } - ts.isModifier = isModifier; - function isQualifiedName(node) { - return node.kind === 139; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 140; - } - ts.isComputedPropertyName = isComputedPropertyName; - function isEntityName(node) { - var kind = node.kind; - return kind === 139 - || kind === 69; - } - ts.isEntityName = isEntityName; - function isPropertyName(node) { - var kind = node.kind; - return kind === 69 - || kind === 9 - || kind === 8 - || kind === 140; - } - ts.isPropertyName = isPropertyName; - function isModuleName(node) { - var kind = node.kind; - return kind === 69 - || kind === 9; - } - ts.isModuleName = isModuleName; - function isBindingName(node) { - var kind = node.kind; - return kind === 69 - || kind === 167 - || kind === 168; - } - ts.isBindingName = isBindingName; - function isTypeParameter(node) { - return node.kind === 141; - } - ts.isTypeParameter = isTypeParameter; - function isParameter(node) { - return node.kind === 142; - } - ts.isParameter = isParameter; - function isDecorator(node) { - return node.kind === 143; - } - ts.isDecorator = isDecorator; - function isMethodDeclaration(node) { - return node.kind === 147; - } - ts.isMethodDeclaration = isMethodDeclaration; - function isClassElement(node) { - var kind = node.kind; - return kind === 148 - || kind === 145 - || kind === 147 - || kind === 149 - || kind === 150 - || kind === 153 - || kind === 198; - } - ts.isClassElement = isClassElement; - function isObjectLiteralElementLike(node) { - var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 147 - || kind === 149 - || kind === 150 - || kind === 239; - } - ts.isObjectLiteralElementLike = isObjectLiteralElementLike; - function isTypeNodeKind(kind) { - return (kind >= 154 && kind <= 166) - || kind === 117 - || kind === 130 - || kind === 120 - || kind === 132 - || kind === 133 - || kind === 103 - || kind === 127 - || kind === 194; - } - function isTypeNode(node) { - return isTypeNodeKind(node.kind); - } - ts.isTypeNode = isTypeNode; - function isBindingPattern(node) { - if (node) { - var kind = node.kind; - return kind === 168 - || kind === 167; - } - return false; - } - ts.isBindingPattern = isBindingPattern; - function isBindingElement(node) { - return node.kind === 169; - } - ts.isBindingElement = isBindingElement; - function isArrayBindingElement(node) { - var kind = node.kind; - return kind === 169 - || kind === 193; - } - ts.isArrayBindingElement = isArrayBindingElement; - function isPropertyAccessExpression(node) { - return node.kind === 172; - } - ts.isPropertyAccessExpression = isPropertyAccessExpression; - function isElementAccessExpression(node) { - return node.kind === 173; - } - ts.isElementAccessExpression = isElementAccessExpression; - function isBinaryExpression(node) { - return node.kind === 187; - } - ts.isBinaryExpression = isBinaryExpression; - function isConditionalExpression(node) { - return node.kind === 188; - } - ts.isConditionalExpression = isConditionalExpression; - function isCallExpression(node) { - return node.kind === 174; - } - ts.isCallExpression = isCallExpression; - function isTemplateLiteral(node) { - var kind = node.kind; - return kind === 189 - || kind === 11; - } - ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 191; - } - ts.isSpreadElementExpression = isSpreadElementExpression; - function isExpressionWithTypeArguments(node) { - return node.kind === 194; - } - ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; - function isLeftHandSideExpressionKind(kind) { - return kind === 172 - || kind === 173 - || kind === 175 - || kind === 174 - || kind === 241 - || kind === 242 - || kind === 176 - || kind === 170 - || kind === 178 - || kind === 171 - || kind === 192 - || kind === 179 - || kind === 69 - || kind === 10 - || kind === 8 - || kind === 9 - || kind === 11 - || kind === 189 - || kind === 84 - || kind === 93 - || kind === 97 - || kind === 99 - || kind === 95 - || kind === 196; - } - function isLeftHandSideExpression(node) { - return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 185 - || kind === 186 - || kind === 181 - || kind === 182 - || kind === 183 - || kind === 184 - || kind === 177 - || isLeftHandSideExpressionKind(kind); - } - function isUnaryExpression(node) { - return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isUnaryExpression = isUnaryExpression; - function isExpressionKind(kind) { - return kind === 188 - || kind === 190 - || kind === 180 - || kind === 187 - || kind === 191 - || kind === 195 - || kind === 193 - || isUnaryExpressionKind(kind); - } - function isExpression(node) { - return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); - } - ts.isExpression = isExpression; - function isAssertionExpression(node) { - var kind = node.kind; - return kind === 177 - || kind === 195; - } - ts.isAssertionExpression = isAssertionExpression; - function isPartiallyEmittedExpression(node) { - return node.kind === 288; - } - ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; - function isNotEmittedStatement(node) { - return node.kind === 287; - } - ts.isNotEmittedStatement = isNotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node) { - return isNotEmittedStatement(node) - || isPartiallyEmittedExpression(node); - } - ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; - function isOmittedExpression(node) { - return node.kind === 193; - } - ts.isOmittedExpression = isOmittedExpression; - function isTemplateSpan(node) { - return node.kind === 197; - } - ts.isTemplateSpan = isTemplateSpan; - function isBlock(node) { - return node.kind === 199; - } - ts.isBlock = isBlock; - function isConciseBody(node) { - return isBlock(node) - || isExpression(node); - } - ts.isConciseBody = isConciseBody; - function isFunctionBody(node) { - return isBlock(node); - } - ts.isFunctionBody = isFunctionBody; - function isForInitializer(node) { - return isVariableDeclarationList(node) - || isExpression(node); - } - ts.isForInitializer = isForInitializer; - function isVariableDeclaration(node) { - return node.kind === 218; - } - ts.isVariableDeclaration = isVariableDeclaration; - function isVariableDeclarationList(node) { - return node.kind === 219; - } - ts.isVariableDeclarationList = isVariableDeclarationList; - function isCaseBlock(node) { - return node.kind === 227; - } - ts.isCaseBlock = isCaseBlock; - function isModuleBody(node) { - var kind = node.kind; - return kind === 226 - || kind === 225; - } - ts.isModuleBody = isModuleBody; - function isImportEqualsDeclaration(node) { - return node.kind === 229; - } - ts.isImportEqualsDeclaration = isImportEqualsDeclaration; - function isImportClause(node) { - return node.kind === 231; - } - ts.isImportClause = isImportClause; - function isNamedImportBindings(node) { - var kind = node.kind; - return kind === 233 - || kind === 232; - } - ts.isNamedImportBindings = isNamedImportBindings; - function isImportSpecifier(node) { - return node.kind === 234; - } - ts.isImportSpecifier = isImportSpecifier; - function isNamedExports(node) { - return node.kind === 237; - } - ts.isNamedExports = isNamedExports; - function isExportSpecifier(node) { - return node.kind === 238; - } - ts.isExportSpecifier = isExportSpecifier; - function isModuleOrEnumDeclaration(node) { - return node.kind === 225 || node.kind === 224; - } - ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; - function isDeclarationKind(kind) { - return kind === 180 - || kind === 169 - || kind === 221 - || kind === 192 - || kind === 148 - || kind === 224 - || kind === 255 - || kind === 238 - || kind === 220 - || kind === 179 - || kind === 149 - || kind === 231 - || kind === 229 - || kind === 234 - || kind === 222 - || kind === 147 - || kind === 146 - || kind === 225 - || kind === 228 - || kind === 232 - || kind === 142 - || kind === 253 - || kind === 145 - || kind === 144 - || kind === 150 - || kind === 254 - || kind === 223 - || kind === 141 - || kind === 218 - || kind === 279; - } - function isDeclarationStatementKind(kind) { - return kind === 220 - || kind === 239 - || kind === 221 - || kind === 222 - || kind === 223 - || kind === 224 - || kind === 225 - || kind === 230 - || kind === 229 - || kind === 236 - || kind === 235 - || kind === 228; - } - function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 - || kind === 209 - || kind === 217 - || kind === 204 - || kind === 202 - || kind === 201 - || kind === 207 - || kind === 208 - || kind === 206 - || kind === 203 - || kind === 214 - || kind === 211 - || kind === 213 - || kind === 215 - || kind === 216 - || kind === 200 - || kind === 205 - || kind === 212 - || kind === 287; - } - function isDeclaration(node) { - return isDeclarationKind(node.kind); - } - ts.isDeclaration = isDeclaration; - function isDeclarationStatement(node) { - return isDeclarationStatementKind(node.kind); - } - ts.isDeclarationStatement = isDeclarationStatement; - function isStatementButNotDeclaration(node) { - return isStatementKindButNotDeclarationKind(node.kind); - } - ts.isStatementButNotDeclaration = isStatementButNotDeclaration; - function isStatement(node) { - var kind = node.kind; - return isStatementKindButNotDeclarationKind(kind) - || isDeclarationStatementKind(kind) - || kind === 199; - } - ts.isStatement = isStatement; - function isModuleReference(node) { - var kind = node.kind; - return kind === 240 - || kind === 139 - || kind === 69; - } - ts.isModuleReference = isModuleReference; - function isJsxOpeningElement(node) { - return node.kind === 243; - } - ts.isJsxOpeningElement = isJsxOpeningElement; - function isJsxClosingElement(node) { - return node.kind === 245; - } - ts.isJsxClosingElement = isJsxClosingElement; - function isJsxTagNameExpression(node) { - var kind = node.kind; - return kind === 97 - || kind === 69 - || kind === 172; - } - ts.isJsxTagNameExpression = isJsxTagNameExpression; - function isJsxChild(node) { - var kind = node.kind; - return kind === 241 - || kind === 248 - || kind === 242 - || kind === 244; - } - ts.isJsxChild = isJsxChild; - function isJsxAttributeLike(node) { - var kind = node.kind; - return kind === 246 - || kind === 247; - } - ts.isJsxAttributeLike = isJsxAttributeLike; - function isJsxSpreadAttribute(node) { - return node.kind === 247; - } - ts.isJsxSpreadAttribute = isJsxSpreadAttribute; - function isJsxAttribute(node) { - return node.kind === 246; - } - ts.isJsxAttribute = isJsxAttribute; - function isStringLiteralOrJsxExpression(node) { - var kind = node.kind; - return kind === 9 - || kind === 248; - } - ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; - function isCaseOrDefaultClause(node) { - var kind = node.kind; - return kind === 249 - || kind === 250; - } - ts.isCaseOrDefaultClause = isCaseOrDefaultClause; - function isHeritageClause(node) { - return node.kind === 251; - } - ts.isHeritageClause = isHeritageClause; - function isCatchClause(node) { - return node.kind === 252; - } - ts.isCatchClause = isCatchClause; - function isPropertyAssignment(node) { - return node.kind === 253; - } - ts.isPropertyAssignment = isPropertyAssignment; - function isShorthandPropertyAssignment(node) { - return node.kind === 254; - } - ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; - function isEnumMember(node) { - return node.kind === 255; - } - ts.isEnumMember = isEnumMember; - function isSourceFile(node) { - return node.kind === 256; - } - ts.isSourceFile = isSourceFile; - function isWatchSet(options) { - return options.watch && options.hasOwnProperty("watch"); - } - ts.isWatchSet = isWatchSet; -})(ts || (ts = {})); -(function (ts) { - function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; - } - ts.getDefaultLibFileName = getDefaultLibFileName; - function textSpanEnd(span) { - return span.start + span.length; - } - ts.textSpanEnd = textSpanEnd; - function textSpanIsEmpty(span) { - return span.length === 0; - } - ts.textSpanIsEmpty = textSpanIsEmpty; - function textSpanContainsPosition(span, position) { - return position >= span.start && position < textSpanEnd(span); - } - ts.textSpanContainsPosition = textSpanContainsPosition; - function textSpanContainsTextSpan(span, other) { - return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span); - } - ts.textSpanContainsTextSpan = textSpanContainsTextSpan; - function textSpanOverlapsWith(span, other) { - var overlapStart = Math.max(span.start, other.start); - var overlapEnd = Math.min(textSpanEnd(span), textSpanEnd(other)); - return overlapStart < overlapEnd; - } - ts.textSpanOverlapsWith = textSpanOverlapsWith; - function textSpanOverlap(span1, span2) { - var overlapStart = Math.max(span1.start, span2.start); - var overlapEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (overlapStart < overlapEnd) { - return createTextSpanFromBounds(overlapStart, overlapEnd); + case 33: + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 34; + } + return pos += 2, token = 32; + } + pos++; + return token = 50; + case 34: + case 39: + tokenValue = scanString(); + return token = 9; + case 96: + return token = scanTemplateAndSetTokenValue(); + case 37: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 63; + } + pos++; + return token = 41; + case 38: + if (text.charCodeAt(pos + 1) === 38) { + return pos += 2, token = 52; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 67; + } + pos++; + return token = 47; + case 40: + pos++; + return token = 18; + case 41: + pos++; + return token = 19; + case 42: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 61; + } + return pos += 2, token = 39; + } + pos++; + return token = 38; + case 43: + if (text.charCodeAt(pos + 1) === 43) { + return pos += 2, token = 42; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 58; + } + pos++; + return token = 36; + case 44: + pos++; + return token = 25; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 43; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + pos++; + return token = 37; + case 46: + if (isDigit(text.charCodeAt(pos + 1))) { + tokenValue = scanNumber(); + return token = 8; + } + if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { + return pos += 3, token = 23; + } + pos++; + return token = 22; + case 47: + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < end) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + if (skipTrivia) { + continue; + } + else { + return token = 2; + } + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + var commentClosed = false; + while (pos < end) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + commentClosed = true; + break; + } + if (isLineBreak(ch_2)) { + precedingLineBreak = true; + } + pos++; + } + if (!commentClosed) { + error(ts.Diagnostics.Asterisk_Slash_expected); + } + if (skipTrivia) { + continue; + } + else { + tokenIsUnterminated = !commentClosed; + return token = 3; + } + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 62; + } + pos++; + return token = 40; + case 48: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { + pos += 2; + var value = scanMinimumNumberOfHexDigits(1); + if (value < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { + tokenValue = "" + scanOctalDigits(); + return token = 8; + } + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + tokenValue = scanNumber(); + return token = 8; + case 58: + pos++; + return token = 55; + case 59: + pos++; + return token = 24; + case 60: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 60) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 64; + } + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 29; + } + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { + return pos += 2, token = 27; + } + pos++; + return token = 26; + case 61: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 33; + } + return pos += 2, token = 31; + } + if (text.charCodeAt(pos + 1) === 62) { + return pos += 2, token = 35; + } + pos++; + return token = 57; + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + pos++; + return token = 28; + case 63: + pos++; + return token = 54; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 69; + } + pos++; + return token = 49; + case 123: + pos++; + return token = 16; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 53; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 68; + } + pos++; + return token = 48; + case 125: + pos++; + return token = 17; + case 126: + pos++; + return token = 51; + case 64: + pos++; + return token = 56; + case 92: + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + default: + if (isIdentifierStart(ch, languageVersion)) { + pos++; + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) + pos++; + tokenValue = text.substring(tokenPos, pos); + if (ch === 92) { + tokenValue += scanIdentifierParts(); + } + return token = getIdentifierToken(); + } + else if (isWhiteSpaceSingleLine(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + } + } } - return undefined; - } - ts.textSpanOverlap = textSpanOverlap; - function textSpanIntersectsWithTextSpan(span, other) { - return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start; - } - ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan; - function textSpanIntersectsWith(span, start, length) { - var end = start + length; - return start <= textSpanEnd(span) && end >= span.start; - } - ts.textSpanIntersectsWith = textSpanIntersectsWith; - function decodedTextSpanIntersectsWith(start1, length1, start2, length2) { - var end1 = start1 + length1; - var end2 = start2 + length2; - return start2 <= end1 && end2 >= start1; - } - ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith; - function textSpanIntersectsWithPosition(span, position) { - return position <= textSpanEnd(span) && position >= span.start; - } - ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition; - function textSpanIntersection(span1, span2) { - var intersectStart = Math.max(span1.start, span2.start); - var intersectEnd = Math.min(textSpanEnd(span1), textSpanEnd(span2)); - if (intersectStart <= intersectEnd) { - return createTextSpanFromBounds(intersectStart, intersectEnd); + function reScanGreaterToken() { + if (token === 28) { + if (text.charCodeAt(pos) === 62) { + if (text.charCodeAt(pos + 1) === 62) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 66; + } + return pos += 2, token = 46; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 65; + } + pos++; + return token = 45; + } + if (text.charCodeAt(pos) === 61) { + pos++; + return token = 30; + } + } + return token; } - return undefined; - } - ts.textSpanIntersection = textSpanIntersection; - function createTextSpan(start, length) { - if (start < 0) { - throw new Error("start < 0"); + function reScanSlashToken() { + if (token === 40 || token === 62) { + var p = tokenPos + 1; + var inEscape = false; + var inCharacterClass = false; + while (true) { + if (p >= end) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + var ch = text.charCodeAt(p); + if (isLineBreak(ch)) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + if (inEscape) { + inEscape = false; + } + else if (ch === 47 && !inCharacterClass) { + p++; + break; + } + else if (ch === 91) { + inCharacterClass = true; + } + else if (ch === 92) { + inEscape = true; + } + else if (ch === 93) { + inCharacterClass = false; + } + p++; + } + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { + p++; + } + pos = p; + tokenValue = text.substring(tokenPos, pos); + token = 11; + } + return token; } - if (length < 0) { - throw new Error("length < 0"); + function reScanTemplateToken() { + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(); } - return { start: start, length: length }; - } - ts.createTextSpan = createTextSpan; - function createTextSpanFromBounds(start, end) { - return createTextSpan(start, end - start); - } - ts.createTextSpanFromBounds = createTextSpanFromBounds; - function textChangeRangeNewSpan(range) { - return createTextSpan(range.span.start, range.newLength); - } - ts.textChangeRangeNewSpan = textChangeRangeNewSpan; - function textChangeRangeIsUnchanged(range) { - return textSpanIsEmpty(range.span) && range.newLength === 0; - } - ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged; - function createTextChangeRange(span, newLength) { - if (newLength < 0) { - throw new Error("newLength < 0"); + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); } - return { span: span, newLength: newLength }; - } - ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); - function collapseTextChangeRangesAcrossMultipleVersions(changes) { - if (changes.length === 0) { - return ts.unchangedTextChangeRange; + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var char = text.charCodeAt(pos); + if (char === 60) { + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + return token = 27; + } + pos++; + return token = 26; + } + if (char === 123) { + pos++; + return token = 16; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123) || (char === 60)) { + break; + } + } + return token = 10; } - if (changes.length === 1) { - return changes[0]; + function scanJsxIdentifier() { + if (tokenIsIdentifierOrKeyword(token)) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; } - var change0 = changes[0]; - var oldStartN = change0.span.start; - var oldEndN = textSpanEnd(change0.span); - var newEndN = oldStartN + change0.newLength; - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - var oldStart2 = nextChange.span.start; - var oldEnd2 = textSpanEnd(nextChange.span); - var newEnd2 = oldStart2 + nextChange.newLength; - oldStartN = Math.min(oldStart1, oldStart2); - oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + function scanJsxAttributeValue() { + startPos = pos; + switch (text.charCodeAt(pos)) { + case 34: + case 39: + tokenValue = scanString(false); + return token = 9; + default: + return scan(); + } } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN); - } - ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; - function getTypeParameterOwner(d) { - if (d && d.kind === 141) { - for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222) { - return current; + function scanJSDocToken() { + if (pos >= end) { + return token = 1; + } + startPos = pos; + tokenPos = pos; + var ch = text.charCodeAt(pos); + switch (ch) { + case 9: + case 11: + case 12: + case 32: + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; + case 64: + pos++; + return token = 56; + case 10: + case 13: + pos++; + return token = 4; + case 42: + pos++; + return token = 38; + case 123: + pos++; + return token = 16; + case 125: + pos++; + return token = 17; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 61: + pos++; + return token = 57; + case 44: + pos++; + return token = 25; + } + if (isIdentifierStart(ch, 4)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + pos++; } + return token = 70; + } + else { + return pos += 1, token = 0; } } - } - ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 148 && ts.isClassLike(node.parent.parent); - } - ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; - function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 || ts.isBindingPattern(node))) { - node = node.parent; + function speculationHelper(callback, isLookahead) { + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var saveTokenValue = tokenValue; + var savePrecedingLineBreak = precedingLineBreak; + var result = callback(); + if (!result || isLookahead) { + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + tokenValue = saveTokenValue; + precedingLineBreak = savePrecedingLineBreak; + } + return result; } - return node; - } - function getCombinedModifierFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = ts.getModifierFlags(node); - if (node.kind === 218) { - node = node.parent; + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; } - if (node && node.kind === 219) { - flags |= ts.getModifierFlags(node); - node = node.parent; + function lookAhead(callback) { + return speculationHelper(callback, true); } - if (node && node.kind === 200) { - flags |= ts.getModifierFlags(node); + function tryScan(callback) { + return speculationHelper(callback, false); } - return flags; - } - ts.getCombinedModifierFlags = getCombinedModifierFlags; - function getCombinedNodeFlags(node) { - node = walkUpBindingElementsAndPatterns(node); - var flags = node.flags; - if (node.kind === 218) { - node = node.parent; + function getText() { + return text; } - if (node && node.kind === 219) { - flags |= node.flags; - node = node.parent; + function setText(newText, start, length) { + text = newText || ""; + end = length === undefined ? text.length : start + length; + setTextPos(start || 0); } - if (node && node.kind === 200) { - flags |= node.flags; + function setOnError(errorCallback) { + onError = errorCallback; + } + function setScriptTarget(scriptTarget) { + languageVersion = scriptTarget; + } + function setLanguageVariant(variant) { + languageVariant = variant; + } + function setTextPos(textPos) { + ts.Debug.assert(textPos >= 0); + pos = textPos; + startPos = textPos; + tokenPos = textPos; + token = 0; + precedingLineBreak = false; + tokenValue = undefined; + hasExtendedUnicodeEscape = false; + tokenIsUnterminated = false; } - return flags; } - ts.getCombinedNodeFlags = getCombinedNodeFlags; + ts.createScanner = createScanner; })(ts || (ts = {})); var ts; (function (ts) { @@ -10216,7 +9692,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 : 84, location, undefined); + return createNode(value ? 100 : 85, location, undefined); } else if (typeof value === "string") { var node = createNode(9, location, undefined); @@ -10233,7 +9709,7 @@ var ts; ts.createLiteral = createLiteral; var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69, location); + var node = createNode(70, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0; @@ -10242,7 +9718,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 1; @@ -10255,7 +9731,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 2; @@ -10265,7 +9741,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = text; name.originalKeywordKind = 0; name.autoGenerateKind = 3; @@ -10275,7 +9751,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.original = node; name.text = ""; name.originalKeywordKind = 0; @@ -10290,22 +9766,22 @@ var ts; } ts.createToken = createToken; function createSuper() { - var node = createNode(95); + var node = createNode(96); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97, location); + var node = createNode(98, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93); + var node = createNode(94); return node; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(140, location); + var node = createNode(141, location); node.expression = expression; return node; } @@ -10322,7 +9798,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142, location, flags); + var node = createNode(143, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10341,7 +9817,7 @@ var ts; } ts.updateParameterDeclaration = updateParameterDeclaration; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145, location); + var node = createNode(146, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10359,7 +9835,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147, location, flags); + var node = createNode(148, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10379,7 +9855,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10397,7 +9873,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10416,7 +9892,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10434,7 +9910,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(167, location); + var node = createNode(168, location); node.elements = createNodeArray(elements); return node; } @@ -10447,7 +9923,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(169, location); node.elements = createNodeArray(elements); return node; } @@ -10460,7 +9936,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169, location); + var node = createNode(170, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10476,7 +9952,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170, location); + var node = createNode(171, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10492,7 +9968,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171, location); + var node = createNode(172, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10508,7 +9984,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172, location, flags); + var node = createNode(173, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10525,7 +10001,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173, location); + var node = createNode(174, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10539,7 +10015,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174, location, flags); + var node = createNode(175, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10556,7 +10032,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10571,7 +10047,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176, location); + var node = createNode(177, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10585,7 +10061,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178, location); + var node = createNode(179, location); node.expression = expression; return node; } @@ -10597,9 +10073,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -10609,20 +10085,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(181, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); node.body = parenthesizeConciseBody(body); return node; } @@ -10635,7 +10111,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181, location); + var node = createNode(182, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10648,7 +10124,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182, location); + var node = createNode(183, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10661,7 +10137,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183, location); + var node = createNode(184, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10674,7 +10150,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10687,7 +10163,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185, location); + var node = createNode(186, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10701,7 +10177,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186, location); + var node = createNode(187, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10717,7 +10193,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187, location); + var node = createNode(188, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -10732,7 +10208,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188, location); + var node = createNode(189, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10749,7 +10225,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189, location); + var node = createNode(190, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10763,7 +10239,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190, location); + var node = createNode(191, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10777,7 +10253,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191, location); + var node = createNode(192, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10790,7 +10266,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192, location); + var node = createNode(193, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10808,12 +10284,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193, location); + var node = createNode(194, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194, location); + var node = createNode(195, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10827,7 +10303,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(197, location); + var node = createNode(198, location); node.expression = expression; node.literal = literal; return node; @@ -10841,7 +10317,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(199, location, flags); + var block = createNode(200, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10857,7 +10333,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200, location, flags); + var node = createNode(201, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10872,7 +10348,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(220, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10885,7 +10361,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218, location, flags); + var node = createNode(219, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10900,11 +10376,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201, location); + return createNode(202, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202, location, flags); + var node = createNode(203, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10917,7 +10393,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203, location); + var node = createNode(204, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -10932,7 +10408,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204, location); + var node = createNode(205, location); node.statement = statement; node.expression = expression; return node; @@ -10946,7 +10422,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205, location); + var node = createNode(206, location); node.expression = expression; node.statement = statement; return node; @@ -10960,7 +10436,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206, location, undefined); + var node = createNode(207, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -10976,7 +10452,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207, location); + var node = createNode(208, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -10991,7 +10467,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11006,7 +10482,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209, location); + var node = createNode(210, location); if (label) { node.label = label; } @@ -11021,7 +10497,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210, location); + var node = createNode(211, location); if (label) { node.label = label; } @@ -11036,7 +10512,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211, location); + var node = createNode(212, location); node.expression = expression; return node; } @@ -11049,7 +10525,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.expression = expression; node.statement = statement; return node; @@ -11063,7 +10539,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11077,7 +10553,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214, location); + var node = createNode(215, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11091,7 +10567,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -11104,7 +10580,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11119,7 +10595,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227, location); + var node = createNode(228, location); node.clauses = createNodeArray(clauses); return node; } @@ -11132,7 +10608,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(221, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11152,7 +10628,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11170,7 +10646,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230, location); + var node = createNode(231, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11186,7 +10662,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231, location); + var node = createNode(232, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11200,7 +10676,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.name = name; return node; } @@ -11213,7 +10689,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233, location); + var node = createNode(234, location); node.elements = createNodeArray(elements); return node; } @@ -11226,7 +10702,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234, location); + var node = createNode(235, location); node.propertyName = propertyName; node.name = name; return node; @@ -11240,7 +10716,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11256,7 +10732,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11272,7 +10748,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -11285,7 +10761,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11299,7 +10775,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11314,7 +10790,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11328,7 +10804,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11562,47 +11038,47 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createComma(left, right) { - return createBinary(left, 24, right); + return createBinary(left, 25, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25, right, location); + return createBinary(left, 26, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56, right, location); + return createBinary(left, 57, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32, right); + return createBinary(left, 33, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41, location); + return createPostfix(operand, 42, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51, right); + return createBinary(left, 52, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49, operand); + return createPrefix(50, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -11621,7 +11097,7 @@ var ts; } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -11735,7 +11211,7 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + var generatorFunc = createFunctionExpression(undefined, createToken(38), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), @@ -11779,7 +11255,7 @@ var ts; setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, [ + createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ createParameter("geti"), createParameter("seti") ], undefined, createBlock([ @@ -11801,19 +11277,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69: + case 70: return cacheIdentifiers; - case 97: + case 98: case 8: case 9: return false; - case 170: + case 171: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171: + case 172: return target.properties.length > 0; default: return true; @@ -11827,13 +11303,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95) { + else if (callee.kind === 96) { thisArg = createThis(); target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; } else { switch (callee.kind) { - case 172: { + case 173: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -11844,7 +11320,7 @@ var ts; } break; } - case 173: { + case 174: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -11894,14 +11370,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149: case 150: + case 151: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253: return createExpressionForPropertyAssignment(property, receiver); case 254: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147: + case 148: return createExpressionForMethodDeclaration(property, receiver); } } @@ -11911,13 +11387,13 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); + var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); setOriginalNode(getterFunction, getAccessor); var getter = createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); + var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); setOriginalNode(setterFunction, setAccessor); var setter = createPropertyAssignment("set", setterFunction); properties_1.push(setter); @@ -11940,13 +11416,13 @@ var ts; return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -11959,16 +11435,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -11999,7 +11479,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 178) { + if (skipped.kind === 179) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12008,15 +11488,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 190) { + && operand.kind === 191) { return false; } return true; @@ -12032,7 +11512,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 35) { + if (binaryOperator === 36) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12045,17 +11525,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 37 + return binaryOperator === 38 + || binaryOperator === 48 || binaryOperator === 47 - || binaryOperator === 46 - || binaryOperator === 48; + || binaryOperator === 49; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 && node.operatorToken.kind === 35) { + if (node.kind === 188 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12072,9 +11552,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174: - return createParen(expression); case 175: + return createParen(expression); + case 176: return emittedExpression.arguments ? expression : createParen(expression); @@ -12085,7 +11565,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 || emittedExpression.arguments) + && (emittedExpression.kind !== 176 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -12123,7 +11603,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187, 24); + var commaPrecedence = ts.getOperatorPrecedence(188, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -12134,7 +11614,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 || kind === 180) { + if (kind === 180 || kind === 181) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12142,7 +11622,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 || leftmostExpressionKind === 179) { + if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { return createParen(expression, expression); } } @@ -12160,18 +11640,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186: + case 187: node = node.operand; continue; - case 187: + case 188: node = node.left; continue; - case 188: + case 189: node = node.condition; continue; + case 175: case 174: case 173: - case 172: node = node.expression; continue; case 288: @@ -12183,12 +11663,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171) { + if (emittedBody.kind === 172) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + var OuterExpressionKinds = ts.OuterExpressionKinds; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -12208,7 +11695,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178) { + while (node.kind === 179) { node = node.expression; } return node; @@ -12368,13 +11855,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_12 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_9 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 && node.importClause) { + if (node.kind === 231 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 && node.moduleSpecifier) { + if (node.kind === 237 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12423,10 +11910,10 @@ var ts; if (kind === 256) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69) { + else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139) { + else if (kind < 140) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12462,10 +11949,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139: + case 140: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141: + case 142: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -12476,12 +11963,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142: + case 143: + case 146: case 145: - case 144: case 253: - case 218: - case 169: + case 219: + case 170: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12490,24 +11977,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156: case 157: - case 151: + case 158: case 152: case 153: + case 154: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: + case 221: + case 181: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12518,176 +12005,176 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155: + case 156: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154: + case 155: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158: - return visitNode(cbNode, node.exprName); case 159: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 160: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 161: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 162: + return visitNodes(cbNodes, node.elementTypes); case 163: - return visitNodes(cbNodes, node.types); case 164: + return visitNodes(cbNodes, node.types); + case 165: return visitNode(cbNode, node.type); - case 166: - return visitNode(cbNode, node.literal); case 167: + return visitNode(cbNode, node.literal); case 168: - return visitNodes(cbNodes, node.elements); - case 170: + case 169: return visitNodes(cbNodes, node.elements); case 171: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 172: + return visitNodes(cbNodes, node.properties); + case 173: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 173: + case 174: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 174: case 175: + case 176: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176: + case 177: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177: + case 178: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 181: + case 179: return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); case 183: return visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.operand); - case 190: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 184: return visitNode(cbNode, node.expression); case 186: return visitNode(cbNode, node.operand); + case 191: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 185: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.operand); + case 188: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 188: + case 189: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191: + case 192: return visitNode(cbNode, node.expression); - case 199: - case 226: + case 200: + case 227: return visitNodes(cbNodes, node.statements); case 256: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200: + case 201: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219: + case 220: return visitNodes(cbNodes, node.declarations); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204: + case 205: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205: + case 206: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 206: + case 207: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 207: + case 208: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208: + case 209: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209: case 210: - return visitNode(cbNode, node.label); case 211: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.label); case 212: + return visitNode(cbNode, node.expression); + case 213: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213: + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227: + case 228: return visitNodes(cbNodes, node.clauses); case 249: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250: return visitNodes(cbNodes, node.statements); - case 214: + case 215: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 221: - case 192: + case 222: + case 193: 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 222: + case 223: 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 223: + case 224: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 224: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12695,65 +12182,65 @@ var ts; case 255: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229: + case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231: + case 232: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228: - return visitNode(cbNode, node.name); - case 232: + case 229: return visitNode(cbNode, node.name); case 233: - case 237: + return visitNode(cbNode, node.name); + case 234: + case 238: return visitNodes(cbNodes, node.elements); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234: - case 238: + case 235: + case 239: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189: + case 190: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140: + case 141: return visitNode(cbNode, node.expression); case 251: return visitNodes(cbNodes, node.types); - case 194: + case 195: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240: + case 241: return visitNode(cbNode, node.expression); - case 239: + case 240: return visitNodes(cbNodes, node.decorators); - case 241: + case 242: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242: case 243: + case 244: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246: @@ -12855,7 +12342,7 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(2, true); + var scanner = ts.createScanner(4, true); var disallowInAndDecoratorContext = 32768 | 131072; var NodeConstructor; var TokenConstructor; @@ -12872,9 +12359,9 @@ var ts; var parsingContext; var contextFlags; var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -12883,7 +12370,7 @@ var ts; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -13126,16 +12613,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 69) { + if (token() === 70) { return true; } - if (token() === 114 && inYieldContext()) { + if (token() === 115 && inYieldContext()) { return false; } - if (token() === 119 && inAwaitContext()) { + if (token() === 120 && inAwaitContext()) { return false; } - return token() > 105; + return token() > 106; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13176,20 +12663,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 23) { + if (token() === 24) { return true; } - return token() === 16 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23) { + if (token() === 24) { nextToken(); } return true; } else { - return parseExpected(23); + return parseExpected(24); } } function createNode(kind, pos) { @@ -13197,8 +12684,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 ? new NodeConstructor(kind, pos, pos) : - kind === 69 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13239,15 +12726,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69); - if (token() !== 69) { + var node = createNode(70); + if (token() !== 70) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13264,7 +12751,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 19) { + if (allowComputedPropertyNames && token() === 20) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13279,10 +12766,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(140); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(141); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); return finishNode(node); } function parseContextualModifier(t) { @@ -13296,20 +12783,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74) { - return nextToken() === 81; + if (token() === 75) { + return nextToken() === 82; } - if (token() === 82) { + if (token() === 83) { nextToken(); - if (token() === 77) { + if (token() === 78) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 && token() !== 116 && token() !== 15 && canFollowModifier(); + return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); } - if (token() === 77) { + if (token() === 78) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113) { + if (token() === 114) { nextToken(); return canFollowModifier(); } @@ -13319,16 +12806,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 - || token() === 15 - || token() === 37 - || token() === 22 + return token() === 20 + || token() === 16 + || token() === 38 + || token() === 23 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 || token() === 87 || - (token() === 118 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 || token() === 88 || + (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -13339,21 +12826,21 @@ var ts; case 0: case 1: case 3: - return !(token() === 23 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 71 || token() === 77; + return token() === 72 || token() === 78; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 23 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); case 6: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 19 || token() === 37 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || isLiteralPropertyName(); case 9: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 7: - if (token() === 15) { + if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13365,23 +12852,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 24 || token() === 22 || isIdentifierOrPattern(); + return token() === 25 || token() === 23 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token() === 24 || token() === 22 || isStartOfExpression(); + return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token() === 24 || isStartOfType(); + return token() === 25 || isStartOfType(); case 20: return isHeritageClause(); case 21: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; case 22: @@ -13394,10 +12881,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15); - if (nextToken() === 16) { + ts.Debug.assert(token() === 16); + if (nextToken() === 17) { var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; + return next === 25 || next === 16 || next === 84 || next === 107; } return true; } @@ -13410,8 +12897,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 || - token() === 83) { + if (token() === 107 || + token() === 84) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -13433,39 +12920,39 @@ var ts; case 12: case 9: case 21: - return token() === 16; + return token() === 17; case 3: - return token() === 16 || token() === 71 || token() === 77; + return token() === 17 || token() === 72 || token() === 78; case 7: - return token() === 15 || token() === 83 || token() === 106; + return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token() === 27 || token() === 17 || token() === 15 || token() === 83 || token() === 106; + return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: - return token() === 18 || token() === 23; + return token() === 19 || token() === 24; case 15: case 19: case 10: - return token() === 20; + return token() === 21; case 16: - return token() === 18 || token() === 20; + return token() === 19 || token() === 21; case 18: - return token() !== 24; + return token() !== 25; case 20: - return token() === 15 || token() === 16; + return token() === 16 || token() === 17; case 13: - return token() === 27 || token() === 39; + return token() === 28 || token() === 40; case 14: - return token() === 25 && lookAhead(nextTokenIsSlash); + return token() === 26 && lookAhead(nextTokenIsSlash); case 22: - return token() === 18 || token() === 54 || token() === 16; + return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 27 || token() === 16; + return token() === 28 || token() === 17; case 25: - return token() === 20 || token() === 16; + return token() === 21 || token() === 17; case 24: - return token() === 16; + return token() === 17; } } function isVariableDeclaratorListTerminator() { @@ -13475,7 +12962,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 34) { + if (token() === 35) { return true; } return false; @@ -13579,17 +13066,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148: - case 153: case 149: + case 154: case 150: - case 145: - case 198: + case 151: + case 146: + case 199: return true; - case 147: + case 148: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; + var nameIsConstructor = methodDeclaration.name.kind === 70 && + methodDeclaration.name.originalKeywordKind === 122; return !nameIsConstructor; } } @@ -13608,35 +13095,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220: + case 221: + case 201: case 200: - case 199: + case 204: case 203: - case 202: - case 215: + case 216: + case 212: + case 214: case 211: - case 213: case 210: + case 208: case 209: case 207: - case 208: case 206: - case 205: - case 212: - case 201: - case 216: - case 214: - case 204: + case 213: + case 202: case 217: + case 215: + case 205: + case 218: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 225: - case 221: + case 226: case 222: - case 224: case 223: + case 225: + case 224: return true; } } @@ -13648,25 +13135,25 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152: - case 146: case 153: - case 144: - case 151: + case 147: + case 154: + case 145: + case 152: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218) { + if (node.kind !== 219) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var parameter = node; @@ -13720,15 +13207,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { + if (parseOptional(25)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(24); - if (considerSemicolonAsDelimiter && token() === 23 && !scanner.hasPrecedingLineBreak()) { + parseExpected(25); + if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -13760,8 +13247,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(139, entity.pos); + while (parseOptional(22)) { + var node = createNode(140, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -13772,33 +13259,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189); + var template = createNode(190); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197); + var span = createNode(198); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16) { + if (token() === 17) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); } span.literal = literal; return finishNode(span); @@ -13808,12 +13295,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -13838,35 +13325,35 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(155, typeName.pos); + var node = createNode(156, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (!scanner.hasPrecedingLineBreak() && token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154, lhs.pos); + var node = createNode(155, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165); + var node = createNode(166); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158); - parseExpected(101); + var node = createNode(159); + parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141); + var node = createNode(142); node.name = parseIdentifier(); - if (parseOptional(83)) { + if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -13877,34 +13364,34 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); + if (token() === 26) { + return parseBracketedList(17, parseTypeParameter, 26, 28); } } function parseParameterType() { - if (parseOptional(54)) { + if (parseOptional(55)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 || token() === 97; + return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(142); - if (token() === 97) { + var node = createNode(143); + if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(53); + node.questionToken = parseOptionalToken(54); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -13916,7 +13403,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; + var returnTokenRequired = returnToken === 35; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -13928,7 +13415,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { + if (parseExpected(18)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -13936,7 +13423,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { + if (!parseExpected(19) && requireCompleteParameterList) { return undefined; } return result; @@ -13944,29 +13431,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(24)) { + if (parseOptional(25)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152) { - parseExpected(92); + if (kind === 153) { + parseExpected(93); } - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19) { + if (token() !== 20) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 22 || token() === 20) { + if (token() === 23 || token() === 21) { return true; } if (ts.isModifierKind(token())) { @@ -13981,43 +13468,43 @@ var ts; else { nextToken(); } - if (token() === 54 || token() === 24) { + if (token() === 55 || token() === 25) { return true; } - if (token() !== 53) { + if (token() !== 54) { return false; } nextToken(); - return token() === 54 || token() === 24 || token() === 20; + return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153, fullStart); + var node = createNode(154, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.parameters = parseBracketedList(16, parseParameter, 20, 21); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token() === 17 || token() === 25) { - var method = createNode(146, fullStart); + var questionToken = parseOptionalToken(54); + if (token() === 18 || token() === 26) { + var method = createNode(147, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(54, false, false, false, method); + fillSignature(55, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144, fullStart); + var property = createNode(145, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56) { + if (token() === 57) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -14026,14 +13513,14 @@ var ts; } function isTypeMemberStart() { var idToken; - if (token() === 17 || token() === 25) { + if (token() === 18 || token() === 26) { return true; } while (ts.isModifierKind(token())) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (isLiteralPropertyName()) { @@ -14041,22 +13528,22 @@ var ts; nextToken(); } if (idToken) { - return token() === 17 || - token() === 25 || - token() === 53 || + return token() === 18 || + token() === 26 || token() === 54 || - token() === 24 || + token() === 55 || + token() === 25 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 || token() === 25) { - return parseSignatureMember(151); - } - if (token() === 92 && lookAhead(isStartOfConstructSignature)) { + if (token() === 18 || token() === 26) { return parseSignatureMember(152); } + if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -14066,18 +13553,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 || token() === 25; + return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(159); + var node = createNode(160); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15)) { + if (parseExpected(16)) { members = parseList(4, parseTypeMember); - parseExpected(16); + parseExpected(17); } else { members = createMissingList(); @@ -14085,31 +13572,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); + var node = createNode(162); + node.elementTypes = parseBracketedList(19, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164); - parseExpected(17); - node.type = parseType(); + var node = createNode(165); parseExpected(18); + node.type = parseType(); + parseExpected(19); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157) { - parseExpected(92); + if (kind === 158) { + parseExpected(93); } - fillSignature(34, false, false, false, node); + fillSignature(35, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 ? undefined : node; + return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166); + var node = createNode(167); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14119,41 +13606,41 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 135: - case 127: + case 131: + case 121: + case 134: + case 136: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseLiteralTypeNode(); - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103: - case 93: + case 104: + case 94: return parseTokenNode(); - case 97: { + case 98: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101: + case 102: return parseTypeQuery(); - case 15: + case 16: return parseTypeLiteral(); - case 19: + case 20: return parseTupleType(); - case 17: + case 18: return parseParenthesizedType(); default: return parseTypeReference(); @@ -14161,29 +13648,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 98: + case 102: + case 128: + case 16: + case 20: + case 26: case 93: - case 97: - case 101: - case 127: - case 15: - case 19: - case 25: - case 92: case 9: case 8: - case 99: - case 84: + case 100: + case 85: return true; - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral); - case 17: + case 18: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -14191,13 +13678,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 || isStartOfParameter() || isStartOfType(); + return token() === 19 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(160, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + parseExpected(21); + var node = createNode(161, type.pos); node.elementType = type; type = finishNode(node); } @@ -14218,26 +13705,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { - if (token() === 25) { + if (token() === 26) { return true; } - return token() === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 97) { + if (isIdentifier() || token() === 98) { nextToken(); return true; } - if (token() === 19 || token() === 15) { + if (token() === 20 || token() === 16) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -14246,17 +13733,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 || token() === 22) { + if (token() === 19 || token() === 23) { return true; } if (skipParameterStart()) { - if (token() === 54 || token() === 24 || - token() === 53 || token() === 56) { + if (token() === 55 || token() === 25 || + token() === 54 || token() === 57) { return true; } - if (token() === 18) { + if (token() === 19) { nextToken(); - if (token() === 34) { + if (token() === 35) { return true; } } @@ -14267,7 +13754,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154, typePredicateVariable.pos); + var node = createNode(155, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14278,7 +13765,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -14288,36 +13775,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156); - } - if (token() === 92) { return parseFunctionOrConstructorType(157); } + if (token() === 93) { + return parseFunctionOrConstructorType(158); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; + return parseOptional(55) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: case 8: case 9: - case 11: case 12: - case 17: - case 19: - case 15: - case 87: - case 73: - case 92: - case 39: - case 61: - case 69: + case 13: + case 18: + case 20: + case 16: + case 88: + case 74: + case 93: + case 40: + case 62: + case 70: return true; default: return isIdentifier(); @@ -14328,18 +13815,18 @@ var ts; return true; } switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 41: + case 79: + case 102: + case 104: case 42: - case 25: - case 119: - case 114: + case 43: + case 26: + case 120: + case 115: return true; default: if (isBinaryOperator()) { @@ -14349,10 +13836,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 15 && - token() !== 87 && - token() !== 73 && - token() !== 55 && + return token() !== 16 && + token() !== 88 && + token() !== 74 && + token() !== 56 && isStartOfExpression(); } function parseExpression() { @@ -14362,7 +13849,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { + while ((operatorToken = parseOptionalToken(25))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -14371,12 +13858,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15) || !isStartOfExpression()) { + if (token() !== 57) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { return undefined; } } - parseExpected(56); + parseExpected(57); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -14388,7 +13875,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token() === 34) { + if (expr.kind === 70 && token() === 35) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -14397,7 +13884,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114) { + if (token() === 115) { if (inYieldContext()) { return true; } @@ -14410,11 +13897,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); + (token() === 38 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14423,21 +13910,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180, asyncModifier.pos); + node = createNode(181, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180, identifier.pos); + node = createNode(181, identifier.pos); } - var parameter = createNode(142, identifier.pos); + var parameter = createNode(143, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -14454,78 +13941,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 || lastToken === 16) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 17 || token() === 25 || token() === 118) { + if (token() === 18 || token() === 26 || token() === 119) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34) { + if (token() === 35) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 17 && token() !== 25) { + if (token() !== 18 && token() !== 26) { return 0; } } var first = token(); var second = nextToken(); - if (first === 17) { - if (second === 18) { + if (first === 18) { + if (second === 19) { var third = nextToken(); switch (third) { - case 34: - case 54: - case 15: + case 35: + case 55: + case 16: return 1; default: return 0; } } - if (second === 19 || second === 15) { + if (second === 20 || second === 16) { return 2; } - if (second === 22) { + if (second === 23) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 54) { + if (nextToken() === 55) { return 1; } return 2; } else { - ts.Debug.assert(first === 25); + ts.Debug.assert(first === 26); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83) { + if (third === 84) { var fourth = nextToken(); switch (fourth) { - case 56: - case 27: + case 57: + case 28: return false; default: return true; } } - else if (third === 24) { + else if (third === 25) { return true; } return false; @@ -14542,7 +14029,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 118) { + if (token() === 119) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -14553,38 +14040,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 34) { + if (scanner.hasPrecedingLineBreak() || token() === 35) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 && token() === 34) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180); + var node = createNode(181); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(54, false, isAsync, !allowAmbiguity, node); + fillSignature(55, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 34 && token() !== 15) { + if (!allowAmbiguity && token() !== 35 && token() !== 16) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15) { + if (token() === 16) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 23 && - token() !== 87 && - token() !== 73 && + if (token() !== 24 && + token() !== 88 && + token() !== 74 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -14594,15 +14081,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); + var questionToken = parseOptionalToken(54); if (!questionToken) { return leftOperand; } - var node = createNode(188, leftOperand.pos); + var node = createNode(189, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); + node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14611,22 +14098,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 138; + return t === 91 || t === 139; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 38 ? + var consumeCurrentOperator = token() === 39 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 && inDisallowInContext()) { + if (token() === 91 && inDisallowInContext()) { break; } - if (token() === 116) { + if (token() === 117) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -14642,92 +14129,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90) { + if (inDisallowInContext() && token() === 91) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52: + case 53: return 1; - case 51: + case 52: return 2; - case 47: - return 3; case 48: + return 3; + case 49: return 4; - case 46: + case 47: return 5; - case 30: case 31: case 32: case 33: + case 34: return 6; - case 25: - case 27: + case 26: case 28: case 29: + case 30: + case 92: case 91: - case 90: - case 116: + case 117: return 7; - case 43: case 44: case 45: + case 46: return 8; - case 35: case 36: - return 9; case 37: - case 39: + return 9; + case 38: case 40: + case 41: return 10; - case 38: + case 39: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187, left.pos); + var node = createNode(188, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195, left.pos); + var node = createNode(196, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185); + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181); + var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(182); + var node = createNode(183); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(183); + var node = createNode(184); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 119) { + if (token() === 120) { if (inAwaitContext()) { return true; } @@ -14736,7 +14223,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14744,15 +14231,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 ? + return token() === 39 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38) { + if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177) { + if (simpleUnaryExpression.kind === 178) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -14763,20 +14250,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: return parsePrefixUnaryExpression(); - case 78: + case 79: return parseDeleteExpression(); - case 101: + case 102: return parseTypeOfExpression(); - case 103: + case 104: return parseVoidExpression(); - case 25: + case 26: return parseTypeAssertion(); - case 119: + case 120: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -14786,16 +14273,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 119: + case 79: + case 102: + case 104: + case 120: return false; - case 25: + case 26: if (sourceFile.languageVariant !== 1) { return false; } @@ -14804,20 +14291,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 41 || token() === 42) { - var node = createNode(185); + if (token() === 42 || token() === 43) { + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 || token() === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186, expression.pos); + if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14826,7 +14313,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 95 + var expression = token() === 96 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -14837,12 +14324,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 || token() === 21 || token() === 19) { + if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(172, expression.pos); + var node = createNode(173, expression.pos); node.expression = expression; - parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -14850,10 +14337,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69) { + if (lhs.kind === 70) { return lhs.text === rhs.text; } - if (lhs.kind === 97) { + if (lhs.kind === 98) { return true; } return lhs.name.text === rhs.name.text && @@ -14862,8 +14349,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243) { - var node = createNode(241, opening.pos); + if (opening.kind === 244) { + var node = createNode(242, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14873,18 +14360,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242); + ts.Debug.assert(opening.kind === 243); result = opening; } - if (inExpressionContext && token() === 25) { + if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187, result.pos); + var badNode = createNode(188, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken = createMissingNode(25, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -14892,17 +14379,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(10, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244: + case 10: return parseJsxText(); - case 15: + case 16: return parseJsxExpression(false); - case 25: + case 26: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -14913,7 +14400,7 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26) { + if (token() === 27) { break; } else if (token() === 1) { @@ -14928,24 +14415,24 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25); + parseExpected(26); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (token() === 27) { - node = createNode(243, fullStart); + if (token() === 28) { + node = createNode(244, fullStart); scanJsxText(); } else { - parseExpected(39); + parseExpected(40); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(242, fullStart); + node = createNode(243, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -14953,10 +14440,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 97 ? + var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21)) { - var propertyAccess = createNode(172, expression.pos); + while (parseOptional(22)) { + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14965,27 +14452,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); - parseExpected(15); - if (token() !== 16) { + parseExpected(16); + if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16); + parseExpected(17); } else { - parseExpected(16, undefined, false); + parseExpected(17, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15) { + if (token() === 16) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246); node.name = parseIdentifierName(); - if (token() === 56) { + if (token() === 57) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -14999,68 +14486,68 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); parseExpected(16); + parseExpected(23); + node.expression = parseExpression(); + parseExpected(17); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245); - parseExpected(26); + parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177); - parseExpected(25); + var node = createNode(178); + parseExpected(26); node.type = parseType(); - parseExpected(27); + parseExpected(28); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21); + var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(172, expression.pos); + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196, expression.pos); + var nonNullExpression = createNode(197, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(173, expression.pos); + if (!inDecoratorContext() && parseOptional(20)) { + var indexedAccess = createNode(174, expression.pos); indexedAccess.expression = expression; - if (token() !== 20) { + if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20); + parseExpected(21); expression = finishNode(indexedAccess); continue; } - if (token() === 11 || token() === 12) { - var tagExpression = createNode(176, expression.pos); + if (token() === 12 || token() === 13) { + var tagExpression = createNode(177, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 + tagExpression.template = token() === 12 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -15072,20 +14559,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25) { + if (token() === 26) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(174, expression.pos); + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17) { - var callExpr = createNode(174, expression.pos); + else if (token() === 18) { + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15095,17 +14582,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(18); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(19); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { + if (!parseOptional(26)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { + if (!parseExpected(28)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -15114,27 +14601,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17: - case 21: case 18: - case 20: + case 22: + case 19: + case 21: + case 55: + case 24: case 54: - case 23: - case 53: - case 30: - case 32: case 31: case 33: - case 51: + case 32: + case 34: case 52: - case 48: - case 46: + case 53: + case 49: case 47: - case 16: + case 48: + case 17: case 1: return true; - case 24: - case 15: + case 25: + case 16: default: return false; } @@ -15143,80 +14630,80 @@ var ts; switch (token()) { case 8: case 9: - case 11: + case 12: return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: return parseTokenNode(); - case 17: + case 18: return parseParenthesizedExpression(); - case 19: + case 20: return parseArrayLiteralExpression(); - case 15: + case 16: return parseObjectLiteralExpression(); - case 118: + case 119: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 73: + case 74: return parseClassExpression(); - case 87: + case 88: return parseFunctionExpression(); - case 92: + case 93: return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { + case 40: + case 62: + if (reScanSlashToken() === 11) { return parseLiteralNode(); } break; - case 12: + case 13: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(179); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 ? parseSpreadElement() : - token() === 24 ? createNode(193) : + return token() === 23 ? parseSpreadElement() : + token() === 25 ? createNode(194) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170); - parseExpected(19); + var node = createNode(171); + parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); + parseExpected(21); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(149, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(131)) { + if (parseContextualModifier(124)) { return parseAccessorDeclaration(150, fullStart, decorators, modifiers); } + else if (parseContextualModifier(132)) { + return parseAccessorDeclaration(151, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -15227,19 +14714,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 || token() === 16 || token() === 56); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); + var equalsToken = parseOptionalToken(57); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15251,19 +14738,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54); + parseExpected(55); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171); - parseExpected(15); + var node = createNode(172); + parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); + parseExpected(17); return finishNode(node); } function parseFunctionExpression() { @@ -15271,10 +14758,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(179); + var node = createNode(180); node.modifiers = parseModifiers(); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -15282,7 +14769,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -15293,23 +14780,23 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175); - parseExpected(92); + var node = createNode(176); + parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17) { + if (node.typeArguments || token() === 18) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200); + if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -15334,47 +14821,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201); - parseExpected(23); + var node = createNode(202); + parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(203); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(89); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204); - parseExpected(79); + var node = createNode(205); + parseExpected(80); node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + parseExpected(105); parseExpected(18); - parseOptional(23); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + parseOptional(24); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(206); + parseExpected(105); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86); - parseExpected(17); + parseExpected(87); + parseExpected(18); var initializer = undefined; - if (token() !== 23) { - if (token() === 102 || token() === 108 || token() === 74) { + if (token() !== 24) { + if (token() === 103 || token() === 109 || token() === 75) { initializer = parseVariableDeclarationList(true); } else { @@ -15382,32 +14869,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(207, pos); + if (parseOptional(91)) { + var forInStatement = createNode(208, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138)) { - var forOfStatement = createNode(208, pos); + else if (parseOptional(139)) { + var forOfStatement = createNode(209, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206, pos); + var forStatement = createNode(207, pos); forStatement.initializer = initializer; - parseExpected(23); - if (token() !== 23 && token() !== 18) { + parseExpected(24); + if (token() !== 24 && token() !== 19) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23); - if (token() !== 18) { + parseExpected(24); + if (token() !== 19) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -15415,7 +14902,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 ? 70 : 75); + parseExpected(kind === 211 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15423,8 +14910,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211); - parseExpected(94); + var node = createNode(212); + parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -15432,90 +14919,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249); - parseExpected(71); + parseExpected(72); node.expression = allowInAnd(parseExpression); - parseExpected(54); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250); - parseExpected(77); - parseExpected(54); + parseExpected(78); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 ? parseCaseClause() : parseDefaultClause(); + return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(214); + parseExpected(97); parseExpected(18); - var caseBlock = createNode(227, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + var caseBlock = createNode(228, scanner.getStartPos()); parseExpected(16); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(17); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(215); - parseExpected(98); + var node = createNode(216); + parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(216); - parseExpected(100); + var node = createNode(217); + parseExpected(101); node.tryBlock = parseBlock(false); - node.catchClause = token() === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 85) { - parseExpected(85); + node.catchClause = token() === 73 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 86) { + parseExpected(86); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252); - parseExpected(72); - if (parseExpected(17)) { + parseExpected(73); + if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18); + parseExpected(19); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217); - parseExpected(76); + var node = createNode(218); + parseExpected(77); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(214, fullStart); + if (expression.kind === 70 && parseOptional(55)) { + var labeledStatement = createNode(215, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202, fullStart); + var expressionStatement = createNode(203, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15527,7 +15014,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 && !scanner.hasPrecedingLineBreak(); + return token() === 88 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -15536,47 +15023,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102: - case 108: + case 103: + case 109: + case 75: + case 88: case 74: - case 87: - case 73: - case 81: + case 82: return true; - case 107: - case 134: + case 108: + case 135: return nextTokenIsIdentifierOnSameLine(); - case 125: case 126: + case 127: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: + case 116: + case 119: + case 123: case 111: case 112: - case 128: + case 113: + case 129: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137: + case 138: nextToken(); - return token() === 15 || token() === 69 || token() === 82; - case 89: + return token() === 16 || token() === 70 || token() === 83; + case 90: nextToken(); - return token() === 9 || token() === 37 || - token() === 15 || ts.tokenIsIdentifierOrKeyword(token()); - case 82: + return token() === 9 || token() === 38 || + token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); + case 83: nextToken(); - if (token() === 56 || token() === 37 || - token() === 15 || token() === 77 || - token() === 116) { + if (token() === 57 || token() === 38 || + token() === 16 || token() === 78 || + token() === 117) { return true; } continue; - case 113: + case 114: nextToken(); continue; default: @@ -15589,46 +15076,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: + case 56: + case 24: + case 16: + case 103: + case 109: case 88: - case 79: - case 104: - case 86: - case 75: - case 70: - case 94: - case 105: - case 96: - case 98: - case 100: - case 76: - case 72: - case 85: - return true; case 74: case 82: case 89: + case 80: + case 105: + case 87: + case 76: + case 71: + case 95: + case 106: + case 97: + case 99: + case 101: + case 77: + case 73: + case 86: + return true; + case 75: + case 83: + case 90: return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: + case 119: + case 123: + case 108: case 126: - case 134: - case 137: + case 127: + case 135: + case 138: return true; - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -15636,73 +15123,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 || token() === 19; + return isIdentifier() || token() === 16 || token() === 20; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 23: + case 24: return parseEmptyStatement(); - case 15: + case 16: return parseBlock(false); - case 102: + case 103: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: + case 109: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 87: + case 88: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 73: + case 74: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 88: + case 89: return parseIfStatement(); - case 79: + case 80: return parseDoStatement(); - case 104: + case 105: return parseWhileStatement(); - case 86: + case 87: return parseForOrForInOrForOfStatement(); - case 75: - return parseBreakOrContinueStatement(209); - case 70: + case 76: return parseBreakOrContinueStatement(210); - case 94: + case 71: + return parseBreakOrContinueStatement(211); + case 95: return parseReturnStatement(); - case 105: + case 106: return parseWithStatement(); - case 96: + case 97: return parseSwitchStatement(); - case 98: + case 99: return parseThrowStatement(); - case 100: - case 72: - case 85: + case 101: + case 73: + case 86: return parseTryStatement(); - case 76: + case 77: return parseDebuggerStatement(); - case 55: + case 56: return parseDeclaration(); - case 118: - case 107: - case 134: - case 125: + case 119: + case 108: + case 135: case 126: - case 122: - case 74: - case 81: + case 127: + case 123: + case 75: case 82: - case 89: - case 110: + case 83: + case 90: case 111: case 112: - case 115: case 113: - case 128: - case 137: + case 116: + case 114: + case 129: + case 138: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15715,40 +15202,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: return parseVariableStatement(fullStart, decorators, modifiers); - case 87: + case 88: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: + case 74: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: + case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: + case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137: - case 125: + case 138: case 126: + case 127: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: + case 90: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82: + case 83: nextToken(); switch (token()) { - case 77: - case 56: + case 78: + case 57: return parseExportAssignment(fullStart, decorators, modifiers); - case 116: + case 117: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(239, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15761,31 +15248,31 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 && canParseSemicolon()) { + if (token() !== 16 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 24) { - return createNode(193); + if (token() === 25) { + return createNode(194); } - var node = createNode(169); - node.dotDotDotToken = parseOptionalToken(22); + var node = createNode(170); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169); + var node = createNode(170); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54) { + if (tokenIsIdentifier && token() !== 55) { node.name = propertyName; } else { - parseExpected(54); + parseExpected(55); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -15793,33 +15280,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(168); parseExpected(16); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(169); parseExpected(20); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(21); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 || token() === 19 || isIdentifier(); + return token() === 16 || token() === 20 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19) { + if (token() === 20) { return parseArrayBindingPattern(); } - if (token() === 15) { + if (token() === 16) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218); + var node = createNode(219); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15828,21 +15315,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219); + var node = createNode(220); switch (token()) { - case 102: + case 103: break; - case 108: + case 109: node.flags |= 1; break; - case 74: + case 75: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 138 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15854,10 +15341,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; + return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -15865,29 +15352,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148, pos); + var node = createNode(149, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121); - fillSignature(54, false, false, false, node); + parseExpected(122); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -15895,12 +15382,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(54, isGenerator, isAsync, false, method); + fillSignature(55, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -15913,10 +15400,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -15931,17 +15418,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return true; default: return false; @@ -15949,7 +15436,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55) { + if (token() === 56) { return true; } while (ts.isModifierKind(token())) { @@ -15959,26 +15446,26 @@ var ts; } nextToken(); } - if (token() === 37) { + if (token() === 38) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 131 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { return true; } switch (token()) { - case 17: - case 25: + case 18: + case 26: + case 55: + case 57: case 54: - case 56: - case 53: return true; default: return canParseSemicolon(); @@ -15990,10 +15477,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55)) { + if (!parseOptional(56)) { break; } - var decorator = createNode(143, decoratorStart); + var decorator = createNode(144, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16013,7 +15500,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 && permitInvalidConstAsModifier) { + if (token() === 75 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -16038,7 +15525,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118) { + if (token() === 119) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -16049,8 +15536,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23) { - var result = createNode(198); + if (token() === 24) { + var result = createNode(199); nextToken(); return finishNode(result); } @@ -16061,7 +15548,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121) { + if (token() === 122) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -16070,33 +15557,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 37 || - token() === 19) { + token() === 38 || + token() === 20) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name_10 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 192); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73); + parseExpected(74); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16)) { node.members = parseClassMembers(); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16109,16 +15596,16 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { if (isHeritageClause()) { return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClause() { - if (token() === 83 || token() === 106) { + if (token() === 84 || token() === 107) { var node = createNode(251); node.token = token(); nextToken(); @@ -16128,38 +15615,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194); + var node = createNode(195); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function isHeritageClause() { - return token() === 83 || token() === 106; + return token() === 84 || token() === 107; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222, fullStart); + var node = createNode(223, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107); + parseExpected(108); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134); + parseExpected(135); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56); + parseExpected(57); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -16171,14 +15658,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81); + parseExpected(82); node.name = parseIdentifier(); - if (parseExpected(15)) { + if (parseExpected(16)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16186,10 +15673,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226, scanner.getStartPos()); - if (parseExpected(15)) { + var node = createNode(227, scanner.getStartPos()); + if (parseExpected(16)) { node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -16197,29 +15684,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21) + node.body = parseOptional(22) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137) { + if (token() === 138) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 15) { + if (token() === 16) { node.body = parseModuleBlock(); } else { @@ -16229,14 +15716,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137) { + if (token() === 138) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126)) { + else if (parseOptional(127)) { flags |= 16; } else { - parseExpected(125); + parseExpected(126); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -16244,63 +15731,63 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 && + return token() === 130 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17; + return nextToken() === 18; } function nextTokenIsSlash() { - return nextToken() === 39; + return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228, fullStart); + var exportDeclaration = createNode(229, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116); - parseExpected(126); + parseExpected(117); + parseExpected(127); exportDeclaration.name = parseIdentifier(); - parseExpected(23); + parseExpected(24); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); + parseExpected(90); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 && token() !== 136) { - var importEqualsDeclaration = createNode(229, fullStart); + if (token() !== 25 && token() !== 137) { + var importEqualsDeclaration = createNode(230, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56); + parseExpected(57); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(230, fullStart); + var importDeclaration = createNode(231, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 37 || - token() === 15) { + token() === 38 || + token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136); + parseExpected(137); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(231, fullStart); + var importClause = createNode(232, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token() === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(233); + parseOptional(25)) { + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); } return finishNode(importClause); } @@ -16310,11 +15797,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(240); - parseExpected(129); - parseExpected(17); - node.expression = parseModuleSpecifier(); + var node = createNode(241); + parseExpected(130); parseExpected(18); + node.expression = parseModuleSpecifier(); + parseExpected(19); return finishNode(node); } function parseModuleSpecifier() { @@ -16328,22 +15815,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(232); - parseExpected(37); - parseExpected(116); + var namespaceImport = createNode(233); + parseExpected(38); + parseExpected(117); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 233 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238); + return parseImportOrExportSpecifier(239); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234); + return parseImportOrExportSpecifier(235); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16351,9 +15838,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116) { + if (token() === 117) { node.propertyName = identifierName; - parseExpected(116); + parseExpected(117); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -16362,23 +15849,23 @@ var ts; else { node.name = identifierName; } - if (kind === 234 && checkIdentifierIsKeyword) { + if (kind === 235 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(237, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37)) { - parseExpected(136); + if (parseOptional(38)) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237); - if (token() === 136 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(136); + node.exportClause = parseNamedImportsOrExports(238); + if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16386,14 +15873,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235, fullStart); + var node = createNode(236, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56)) { + if (parseOptional(57)) { node.isExportEquals = true; } else { - parseExpected(77); + parseExpected(78); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -16465,36 +15952,72 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 229 && node.moduleReference.kind === 240 - || node.kind === 230 - || node.kind === 235 + || node.kind === 230 && node.moduleReference.kind === 241 + || node.kind === 231 || node.kind === 236 + || node.kind === 237 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37: - case 53: - case 17: - case 19: - case 49: - case 15: - case 87: - case 22: - case 92: - case 97: + case 38: + case 54: + case 18: + case 20: + case 50: + case 16: + case 88: + case 23: + case 93: + case 98: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); - sourceFile = createSourceFile("file.js", 2, 1); + initializeState(content, 4, undefined, 1); + sourceFile = createSourceFile("file.js", 4, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -16505,21 +16028,21 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { var result = createNode(257, scanner.getTokenPos()); - parseExpected(15); - result.type = parseJSDocTopLevelType(); parseExpected(16); + result.type = parseJSDocTopLevelType(); + parseExpected(17); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47) { + if (token() === 48) { var unionType = createNode(261, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56) { + if (token() === 57) { var optionalType = createNode(268, type.pos); nextToken(); optionalType.type = type; @@ -16530,20 +16053,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19) { + if (token() === 20) { var arrayType = createNode(260, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20); + parseExpected(21); type = finishNode(arrayType); } - else if (token() === 53) { + else if (token() === 54) { var nullableType = createNode(263, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49) { + else if (token() === 50) { var nonNullableType = createNode(264, type.pos); nonNullableType.type = type; nextToken(); @@ -16557,40 +16080,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37: + case 38: return parseJSDocAllType(); - case 53: + case 54: return parseJSDocUnknownOrNullableType(); - case 17: + case 18: return parseJSDocUnionType(); - case 19: + case 20: return parseJSDocTupleType(); - case 49: + case 50: return parseJSDocNonNullableType(); - case 15: + case 16: return parseJSDocRecordType(); - case 87: + case 88: return parseJSDocFunctionType(); - case 22: + case 23: return parseJSDocVariadicType(); - case 92: + case 93: return parseJSDocConstructorType(); - case 97: + case 98: return parseJSDocThisType(); - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 93: - case 135: - case 127: + case 131: + case 121: + case 134: + case 104: + case 94: + case 136: + case 128: return parseTokenNode(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -16598,14 +16121,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } @@ -16618,33 +16141,33 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269); nextToken(); - parseExpected(17); + parseExpected(18); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18); - if (token() === 54) { + parseExpected(19); + if (token() === 55) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142); + var parameter = createNode(143); parameter.type = parseJSDocType(); - if (parseOptional(56)) { - parameter.questionToken = createNode(56); + if (parseOptional(57)) { + parameter.questionToken = createNode(57); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267); result.name = parseSimplePropertyName(); - if (token() === 25) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21)) { - if (token() === 25) { + while (parseOptional(22)) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); break; } @@ -16660,7 +16183,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27); + parseExpected(28); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -16671,7 +16194,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139, left.pos); + var result = createNode(140, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -16692,7 +16215,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20); + parseExpected(21); return finishNode(result); } function checkForTrailingComma(list) { @@ -16705,13 +16228,13 @@ var ts; var result = createNode(261); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); + parseExpected(19); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47)) { + while (parseOptional(48)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -16730,12 +16253,12 @@ var ts; function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 24 || - token() === 16 || - token() === 18 || - token() === 27 || - token() === 56 || - token() === 47) { + if (token() === 25 || + token() === 17 || + token() === 19 || + token() === 28 || + token() === 57 || + token() === 48) { var result = createNode(259, pos); return finishNode(result); } @@ -16746,7 +16269,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); + initializeState(content, 4, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -16768,6 +16291,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -16804,7 +16333,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 55: + case 56: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -16822,7 +16351,7 @@ var ts; state = 0; indent = 0; break; - case 37: + case 38: var asterisk = scanner.getTokenText(); if (state === 1) { state = 2; @@ -16833,7 +16362,7 @@ var ts; indent += asterisk.length; } break; - case 69: + case 70: pushComment(scanner.getTokenText()); state = 2; break; @@ -16890,8 +16419,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getTokenPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -16942,7 +16471,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 && token() !== 1) { + while (token() !== 56 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -16951,7 +16480,7 @@ var ts; } indent = 0; break; - case 55: + case 56: break; case 5: if (state === 2) { @@ -16965,7 +16494,7 @@ var ts; indent += whitespace.length; } break; - case 37: + case 38: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -16976,7 +16505,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55) { + if (token() === 56) { break; } nextJSDocToken(); @@ -17004,7 +16533,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15) { + if (token() !== 16) { return undefined; } return parseJSDocTypeExpression(); @@ -17015,14 +16544,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(19)) { + if (parseOptionalToken(20)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(56)) { + if (parseOptionalToken(57)) { parseExpression(); } - parseExpected(20); + parseExpected(21); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -17099,9 +16628,9 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + if (jsDocTypeReference.name.kind === 70) { + var name_11 = jsDocTypeReference.name; + if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17123,7 +16652,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55: + case 56: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -17137,13 +16666,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37: + case 38: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69: + case 70: canParseTag = false; case 1: break; @@ -17154,8 +16683,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getStartPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -17187,17 +16716,17 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name_12 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name_12) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(142, name_12.pos); + typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24) { + if (token() === 25) { nextJSDocToken(); skipWhitespace(); } @@ -17226,7 +16755,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69, pos); + var result = createNode(70, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -17297,8 +16826,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -17307,7 +16836,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 69: + case 70: return true; } return false; @@ -17370,8 +16899,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -17519,21 +17048,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - if (node.kind === 222 || node.kind === 223) { + if (node.kind === 223 || node.kind === 224) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 230 || node.kind === 229) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 226) { + else if (node.kind === 227) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17549,7 +17088,7 @@ var ts; }); return state_1; } - else if (node.kind === 225) { + else if (node.kind === 226) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -17558,6 +17097,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -17655,7 +17206,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { symbol.valueDeclaration = node; } } @@ -17665,7 +17216,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -17676,21 +17227,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148: + case 149: return "__constructor"; - case 156: - case 151: - return "__call"; case 157: case 152: - return "__new"; + return "__call"; + case 158: case 153: + return "__new"; + case 154: return "__index"; - case 236: + case 237: return "__export"; - case 235: + case 236: return node.isExportEquals ? "export=" : "default"; - case 187: + case 188: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17702,12 +17253,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220: case 221: + case 222: return ts.hasModifier(node, 512) ? "default" : undefined; case 269: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142: + case 143: ts.Debug.assert(node.parent.kind === 269); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); @@ -17715,10 +17266,10 @@ var ts; case 279: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { nameFromParentNode = nameIdentifier.text; } } @@ -17759,7 +17310,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17779,7 +17330,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 238 || (node.kind === 229 && hasExportModifier)) { + if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17896,64 +17447,64 @@ var ts; return; } switch (node.kind) { - case 205: + case 206: bindWhileStatement(node); break; - case 204: + case 205: bindDoStatement(node); break; - case 206: + case 207: bindForStatement(node); break; - case 207: case 208: + case 209: bindForInOrForOfStatement(node); break; - case 203: + case 204: bindIfStatement(node); break; - case 211: - case 215: + case 212: + case 216: bindReturnOrThrow(node); break; + case 211: case 210: - case 209: bindBreakOrContinueStatement(node); break; - case 216: + case 217: bindTryStatement(node); break; - case 213: + case 214: bindSwitchStatement(node); break; - case 227: + case 228: bindCaseBlock(node); break; case 249: bindCaseClause(node); break; - case 214: + case 215: bindLabeledStatement(node); break; - case 185: + case 186: bindPrefixUnaryExpressionFlow(node); break; - case 186: + case 187: bindPostfixUnaryExpressionFlow(node); break; - case 187: + case 188: bindBinaryExpressionFlow(node); break; - case 181: + case 182: bindDeleteExpressionFlow(node); break; - case 188: + case 189: bindConditionalExpressionFlow(node); break; - case 218: + case 219: bindVariableDeclarationFlow(node); break; - case 174: + case 175: bindCallExpressionFlow(node); break; default: @@ -17963,25 +17514,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return isNarrowableReference(expr); - case 174: + case 175: return hasNarrowableArgument(expr); - case 178: + case 179: return isNarrowingExpression(expr.expression); - case 187: + case 188: return isNarrowingBinaryExpression(expr); - case 185: - return expr.operator === 49 && isNarrowingExpression(expr.operand); + case 186: + return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 || - expr.kind === 97 || - expr.kind === 172 && isNarrowableReference(expr.expression); + return expr.kind === 70 || + expr.kind === 98 || + expr.kind === 173 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17992,41 +17543,41 @@ var ts; } } } - if (expr.expression.kind === 172 && + if (expr.expression.kind === 173 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableReference(expr.left); - case 30: case 31: case 32: case 33: + case 34: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91: + case 92: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178: + case 179: return isNarrowableOperand(expr.expression); - case 187: + case 188: switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowableOperand(expr.right); } } @@ -18045,7 +17596,7 @@ var ts; }; } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 256 ? 512 : 256; + flow.flags |= flow.flags & 512 ? 1024 : 512; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -18060,8 +17611,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 99 && flags & 64 || - expression.kind === 84 && flags & 32) { + if (expression.kind === 100 && flags & 64 || + expression.kind === 85 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -18095,6 +17646,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -18108,34 +17667,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203: - case 205: case 204: - return parent.expression === node; case 206: - case 188: + case 205: + return parent.expression === node; + case 207: + case 189: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178) { + if (node.kind === 179) { node = node.expression; } - else if (node.kind === 185 && node.operator === 49) { + else if (node.kind === 186 && node.operator === 50) { node = node.operand; } else { - return node.kind === 187 && (node.operatorToken.kind === 51 || - node.operatorToken.kind === 52); + return node.kind === 188 && (node.operatorToken.kind === 52 || + node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 || - node.parent.kind === 185 && - node.parent.operator === 49) { + while (node.parent.kind === 179 || + node.parent.kind === 186 && + node.parent.operator === 50) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -18208,7 +17767,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219) { + if (node.initializer.kind !== 220) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -18230,7 +17789,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211) { + if (node.kind === 212) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -18250,7 +17809,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -18270,21 +17829,32 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + if (!(currentFlow.flags & 1)) { + if ((flowAfterTry.flags & 1) && (flowAfterCatch.flags & 1)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - if (!node.finallyBlock || !(currentFlow.flags & 1)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -18361,7 +17931,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 && node.operatorToken.kind === 56) { + if (node.kind === 188 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -18372,10 +17942,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170) { + else if (node.kind === 171) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191) { + if (e.kind === 192) { bindAssignmentTargetFlow(e.expression); } else { @@ -18383,7 +17953,7 @@ var ts; } } } - else if (node.kind === 171) { + else if (node.kind === 172) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253) { @@ -18397,7 +17967,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -18408,7 +17978,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49) { + if (node.operator === 50) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -18418,20 +17988,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 || operator === 52) { + if (operator === 52 || operator === 53) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -18443,14 +18013,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 && !ts.isAssignmentTarget(node)) { + if (operator === 57 && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172) { + if (node.expression.kind === 173) { bindAssignmentTargetFlow(node.expression); } } @@ -18481,16 +18057,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 || node.parent.parent.kind === 208) { + if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 178) { + while (expr.kind === 179) { expr = expr.expression; } - if (expr.kind === 179 || expr.kind === 180) { + if (expr.kind === 180 || expr.kind === 181) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18498,54 +18074,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192: - case 221: - case 224: - case 171: - case 159: + case 193: + case 222: + case 225: + case 172: + case 160: case 281: case 265: return 1; - case 222: + case 223: return 1 | 64; case 269: - case 225: - case 223: + case 226: + case 224: return 1 | 32; case 256: return 1 | 4 | 32; - case 147: + case 148: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 148: - case 220: - case 146: case 149: + case 221: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return 1 | 4 | 32 | 8; - case 179: case 180: + case 181: return 1 | 4 | 32 | 8 | 16; - case 226: + case 227: return 4; - case 145: + case 146: return node.initializer ? 4 : 0; case 252: - case 206: case 207: case 208: - case 227: + case 209: + case 228: return 2; - case 199: + case 200: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18561,36 +18143,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 225: + case 226: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192: - case 221: + case 193: + case 222: return declareClassMember(node, symbolFlags, symbolExcludes); - case 224: + case 225: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159: - case 171: - case 222: + case 160: + case 172: + case 223: case 265: case 281: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156: case 157: - case 151: + case 158: case 152: case 153: - case 147: - case 146: + case 154: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 269: - case 223: + case 224: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18606,10 +18188,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 226)) { + if (body && (body.kind === 256 || body.kind === 227)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 || stat.kind === 235) { + if (stat.kind === 237 || stat.kind === 236) { return true; } } @@ -18681,15 +18263,20 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69) { + if (prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 147 + var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18711,7 +18298,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225: + case 226: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256: @@ -18732,8 +18319,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && + node.originalKeywordKind >= 107 && + node.originalKeywordKind <= 115 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -18761,17 +18348,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { + if (inStrictMode && node.expression.kind === 70) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && + return node.kind === 70 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { + if (name && name.kind === 70) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -18805,7 +18392,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 225 && + blockScopeContainer.kind !== 226 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18824,7 +18411,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -18848,7 +18435,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 138) { + if (node.kind > 139) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -18885,18 +18472,18 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172: + case 173: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187: + case 188: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -18921,30 +18508,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252: return checkStrictModeCatchClause(node); - case 181: + case 182: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 186: + case 187: return checkStrictModePostfixUnaryExpression(node); - case 185: + case 186: return checkStrictModePrefixUnaryExpression(node); - case 212: + case 213: return checkStrictModeWithStatement(node); - case 165: + case 166: seenThisKeyword = true; return; - case 154: + case 155: return checkTypePredicate(node); - case 141: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 142: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 143: return bindParameter(node); - case 218: - case 169: + case 219: + case 170: return bindVariableDeclarationOrBindingElement(node); + case 146: case 145: - case 144: case 266: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); case 280: @@ -18957,82 +18544,82 @@ var ts; case 247: emitFlags |= 16384; return; - case 151: case 152: case 153: + case 154: return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 148: case 147: - case 146: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 220: + case 221: return bindFunctionDeclaration(node); - case 148: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 149: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 150: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 151: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 156: case 157: + case 158: case 269: return bindFunctionOrConstructorType(node); - case 159: + case 160: case 281: case 265: return bindAnonymousDeclaration(node, 2048, "__type"); - case 171: + case 172: return bindObjectLiteralExpression(node); - case 179: case 180: + case 181: return bindFunctionExpression(node); - case 174: + case 175: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 192: - case 221: + case 193: + case 222: inStrictMode = true; return bindClassLikeDeclaration(node); - case 222: + case 223: return bindBlockScopedDeclaration(node, 64, 792968); case 279: - case 223: - return bindBlockScopedDeclaration(node, 524288, 793064); case 224: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 225: + return bindEnumDeclaration(node); + case 226: return bindModuleDeclaration(node); - case 229: - case 232: - case 234: - case 238: + case 230: + case 233: + case 235: + case 239: return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 228: + case 229: return bindNamespaceExportDeclaration(node); - case 231: + case 232: return bindImportClause(node); - case 236: + case 237: return bindExportDeclaration(node); - case 235: + case 236: return bindExportAssignment(node); case 256: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199: + case 200: if (!ts.isFunctionLike(node.parent)) { return; } - case 226: + case 227: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69) { + if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165) { + if (parameterName && parameterName.kind === 166) { seenThisKeyword = true; } bind(type); @@ -19051,7 +18638,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -19095,7 +18682,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -19108,11 +18697,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 220 || container.kind === 179) { + if (container.kind === 221 || container.kind === 180) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 148) { + else if (container.kind === 149) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -19152,7 +18741,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 221) { + if (node.kind === 222) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -19270,15 +18859,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 201) || - node.kind === 221 || - (node.kind === 225 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 224 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || + node.kind === 222 || + (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 || + (node.kind !== 201 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -19292,52 +18881,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174: + case 175: return computeCallExpression(node, subtreeFlags); - case 225: + case 176: + return computeNewExpression(node, subtreeFlags); + case 226: return computeModuleDeclaration(node, subtreeFlags); - case 178: + case 179: return computeParenthesizedExpression(node, subtreeFlags); - case 187: + case 188: return computeBinaryExpression(node, subtreeFlags); - case 202: + case 203: return computeExpressionStatement(node, subtreeFlags); - case 142: + case 143: return computeParameter(node, subtreeFlags); - case 180: + case 181: return computeArrowFunction(node, subtreeFlags); - case 179: + case 180: return computeFunctionExpression(node, subtreeFlags); - case 220: + case 221: return computeFunctionDeclaration(node, subtreeFlags); - case 218: - return computeVariableDeclaration(node, subtreeFlags); case 219: + return computeVariableDeclaration(node, subtreeFlags); + case 220: return computeVariableDeclarationList(node, subtreeFlags); - case 200: + case 201: return computeVariableStatement(node, subtreeFlags); - case 214: + case 215: return computeLabeledStatement(node, subtreeFlags); - case 221: + case 222: return computeClassDeclaration(node, subtreeFlags); - case 192: + case 193: return computeClassExpression(node, subtreeFlags); case 251: return computeHeritageClause(node, subtreeFlags); - case 194: + case 195: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148: + case 149: return computeConstructor(node, subtreeFlags); - case 145: + case 146: return computePropertyDeclaration(node, subtreeFlags); - case 147: + case 148: return computeMethod(node, subtreeFlags); - case 149: case 150: + case 151: return computeAccessor(node, subtreeFlags); - case 229: + case 230: return computeImportEquals(node, subtreeFlags); - case 172: + case 173: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -19348,40 +18939,54 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537133909; + return transformFlags & ~537922901; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95: + case 96: return true; - case 172: case 173: + case 174: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95; + return expressionKind === 96; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576) { + transformFlags |= 768; + } + node.transformFlags = transformFlags | 536870912; + return transformFlags & ~537922901; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 - && (leftKind === 171 - || leftKind === 170)) { - transformFlags |= 192 | 256; + if (operatorTokenKind === 57 + && (leftKind === 172 + || leftKind === 171)) { + transformFlags |= 768 | 1024; } - else if (operatorTokenKind === 38 - || operatorTokenKind === 60) { - transformFlags |= 48; + else if (operatorTokenKind === 39 + || operatorTokenKind === 61) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19389,35 +18994,35 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - if (node.questionToken) { - transformFlags |= 3; - } - if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { + if (node.questionToken + || node.type + || subtreeFlags & 8192 + || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 131072; + transformFlags |= 3 | 524288; } - if (subtreeFlags & 2097152 || initializer || dotDotDotToken) { - transformFlags |= 192 | 65536; + if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { + transformFlags |= 768 | 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 195 - || expressionKind === 177) { + if (expressionKind === 196 + || expressionKind === 178) { transformFlags |= 3; } - if (expressionTransformFlags & 256) { - transformFlags |= 256; + if (expressionTransformFlags & 1024) { + transformFlags |= 1024; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -19426,36 +19031,38 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 192; - if ((subtreeFlags & 137216) - || (modifierFlags & 1)) { + transformFlags = subtreeFlags | 768; + if ((subtreeFlags & 548864) + || (modifierFlags & 1) + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - if (subtreeFlags & 137216) { + var transformFlags = subtreeFlags | 768; + if (subtreeFlags & 548864 + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83: - transformFlags |= 192; + case 84: + transformFlags |= 768; break; - case 106: + case 107: transformFlags |= 3; break; default: @@ -19463,135 +19070,148 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; + var transformFlags = subtreeFlags | 768; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { + if (ts.hasModifier(node, 2270) + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - if (!body - || typeParameters - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + var transformFlags = subtreeFlags | 768; + if (node.decorators + || ts.hasModifier(node, 2270) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - if (!body - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + if (node.decorators + || ts.hasModifier(node, 2270) + || node.type + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 4096; + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2)) { transformFlags = 3; } else { - transformFlags = subtreeFlags | 8388608; + transformFlags = subtreeFlags | 33554432; if (modifierFlags & 1) { - transformFlags |= 3 | 192; + transformFlags |= 3 | 768; } - if (modifierFlags & 256) { + if (modifierFlags & 2270 + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (modifierFlags & 256) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - if (modifierFlags & 256) { + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 327680) { + transformFlags |= 768; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 256) { + var transformFlags = subtreeFlags | 768; + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 8192) { - transformFlags |= 16384; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 32768) { + transformFlags |= 65536; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550710101; + return transformFlags & ~592227669; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 95) { - transformFlags |= 8192; + if (expressionKind === 96) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 167 || nameKind === 168) { - transformFlags |= 192 | 2097152; + if (nameKind === 168 || nameKind === 169) { + transformFlags |= 768 | 8388608; + } + if (node.type) { + transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19603,23 +19223,23 @@ var ts; else { transformFlags = subtreeFlags; if (modifierFlags & 1) { - transformFlags |= 192 | 3; + transformFlags |= 768 | 3; } - if (declarationListTransformFlags & 2097152) { - transformFlags |= 192; + if (declarationListTransformFlags & 8388608) { + transformFlags |= 768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 1048576 + if (subtreeFlags & 4194304 && ts.isIterationStatement(node, true)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19627,15 +19247,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 256) { - transformFlags |= 192; + if (node.expression.transformFlags & 1024) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -19644,77 +19264,78 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~546335573; + return transformFlags & ~574729557; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608; - if (subtreeFlags & 2097152) { - transformFlags |= 192; + var transformFlags = subtreeFlags | 33554432; + if (subtreeFlags & 8388608) { + transformFlags |= 768; } if (node.flags & 3) { - transformFlags |= 192 | 1048576; + transformFlags |= 768 | 4194304; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536871765; + var excludeFlags = 536874325; switch (kind) { - case 112: - case 110: + case 119: + case 185: + transformFlags |= 48; + break; + case 113: case 111: - case 115: - case 122: - case 118: - case 74: - case 184: - case 224: + case 112: + case 116: + case 123: + case 75: + case 225: case 255: - case 177: - case 195: + case 178: case 196: - case 128: + case 197: + case 129: transformFlags |= 3; break; - case 241: case 242: case 243: case 244: + case 10: case 245: case 246: case 247: case 248: transformFlags |= 12; break; - case 82: - transformFlags |= 192 | 3; + case 83: + transformFlags |= 768 | 3; break; - case 77: - case 11: + case 78: case 12: case 13: case 14: - case 189: - case 176: + case 15: + case 190: + case 177: case 254: - case 208: - transformFlags |= 192; + case 209: + transformFlags |= 768; break; - case 190: - transformFlags |= 192 | 4194304; + case 191: + transformFlags |= 768 | 16777216; break; - case 117: - case 130: - case 127: - case 132: - case 120: + case 118: + case 131: + case 128: case 133: - case 103: - case 141: - case 144: - case 146: - case 151: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: case 154: @@ -19728,68 +19349,69 @@ var ts; case 162: case 163: case 164: - case 222: - case 223: case 165: + case 223: + case 224: case 166: + case 167: transformFlags = 3; excludeFlags = -3; break; - case 140: - transformFlags |= 524288; - if (subtreeFlags & 8192) { - transformFlags |= 32768; + case 141: + transformFlags |= 2097152; + if (subtreeFlags & 32768) { + transformFlags |= 131072; } break; - case 191: - transformFlags |= 262144; + case 192: + transformFlags |= 1048576; break; - case 95: - transformFlags |= 192; + case 96: + transformFlags |= 768; break; - case 97: - transformFlags |= 8192; + case 98: + transformFlags |= 32768; break; - case 167: case 168: - transformFlags |= 192 | 2097152; + case 169: + transformFlags |= 768 | 8388608; break; - case 143: - transformFlags |= 3 | 2048; + case 144: + transformFlags |= 3 | 8192; break; - case 171: - excludeFlags = 537430869; - if (subtreeFlags & 524288) { - transformFlags |= 192; + case 172: + excludeFlags = 539110741; + if (subtreeFlags & 2097152) { + transformFlags |= 768; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } break; - case 170: - case 175: - excludeFlags = 537133909; - if (subtreeFlags & 262144) { - transformFlags |= 192; + case 171: + case 176: + excludeFlags = 537922901; + if (subtreeFlags & 1048576) { + transformFlags |= 768; } break; - case 204: case 205: case 206: case 207: - if (subtreeFlags & 1048576) { - transformFlags |= 192; + case 208: + if (subtreeFlags & 4194304) { + transformFlags |= 768; } break; case 256: - if (subtreeFlags & 16384) { - transformFlags |= 192; + if (subtreeFlags & 65536) { + transformFlags |= 768; } break; - case 211: - case 209: + case 212: case 210: - transformFlags |= 8388608; + case 211: + transformFlags |= 33554432; break; } node.transformFlags = transformFlags | 536870912; @@ -19889,6 +19511,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); @@ -19932,6 +19555,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; var getGlobalTemplateStringsArrayType; var getGlobalESSymbolType; @@ -19972,6 +19596,66 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -20014,6 +19698,13 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -20098,7 +19789,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 && source.valueDeclaration.kind !== 225))) { + (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -20233,24 +19924,24 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 218 || + return declaration.kind !== 219 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200: - case 206: - case 208: + case 201: + case 207: + case 209: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 207: case 208: + case 209: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20268,7 +19959,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 && + current.parent.kind === 146 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -20294,15 +19985,15 @@ var ts; if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 142 || - lastLocation.kind === 141 + lastLocation.kind === 143 || + lastLocation.kind === 142 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 142 || + lastLocation.kind === 143 || (lastLocation === location.type && - result.valueDeclaration.kind === 142); + result.valueDeclaration.kind === 143); } } if (useResult) { @@ -20318,7 +20009,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225: + case 226: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { @@ -20330,7 +20021,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 238)) { + ts.getDeclarationOfKind(moduleExports[name], 239)) { break; } } @@ -20338,13 +20029,13 @@ var ts; break loop; } break; - case 224: + case 225: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 146: case 145: - case 144: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20354,9 +20045,9 @@ var ts; } } break; - case 221: - case 192: case 222: + case 193: + case 223: 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); @@ -20364,7 +20055,7 @@ var ts; } break loop; } - if (location.kind === 192 && meaning & 32) { + if (location.kind === 193 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20372,28 +20063,28 @@ var ts; } } break; - case 140: + case 141: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223) { 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; } } break; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 180: + case 151: + case 221: + case 181: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179: + case 180: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20406,8 +20097,8 @@ var ts; } } break; - case 143: - if (location.parent && location.parent.kind === 142) { + case 144: + if (location.parent && location.parent.kind === 143) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20449,7 +20140,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228) { + if (decls && decls.length === 1 && decls[0].kind === 229) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20457,7 +20148,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -20495,10 +20186,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69: - case 172: + case 70: + case 173: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194: + case 195: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20519,7 +20210,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, 218), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20536,10 +20227,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } - while (node && node.kind !== 230) { + while (node && node.kind !== 231) { node = node.parent; } return node; @@ -20549,10 +20240,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240) { + if (node.moduleReference.kind === 241) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -20610,28 +20301,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name_13 = specifier.propertyName || specifier.name; + if (name_13.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_13.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_13.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); } return symbol; } @@ -20653,19 +20344,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229: + case 230: return getTargetOfImportEqualsDeclaration(node); - case 231: - return getTargetOfImportClause(node); case 232: + return getTargetOfImportClause(node); + case 233: return getTargetOfNamespaceImport(node); - case 234: + case 235: return getTargetOfImportSpecifier(node); - case 238: + case 239: return getTargetOfExportSpecifier(node); - case 235: + case 236: return getTargetOfExportAssignment(node); - case 228: + case 229: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20709,10 +20400,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235) { + if (node.kind === 236) { checkExpressionCached(node.expression); } - else if (node.kind === 238) { + else if (node.kind === 239) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20720,15 +20411,15 @@ var ts; } } } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { + if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 139) { + if (entityName.kind === 70 || entityName.parent.kind === 140) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 229); + ts.Debug.assert(entityName.parent.kind === 230); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20740,16 +20431,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69) { + if (name.kind === 70) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 || name.kind === 172) { - var left = name.kind === 139 ? name.left : name.expression; - var right = name.kind === 139 ? name.right : name.name; + else if (name.kind === 140 || name.kind === 173) { + var left = name.kind === 140 ? name.left : name.expression; + var right = name.kind === 140 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -20932,7 +20623,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 && ts.nodeIsPresent(member.body)) { return member; } } @@ -21006,7 +20697,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225: + case 226: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -21039,7 +20730,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21070,7 +20761,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21084,10 +20775,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145: - case 147: - case 149: + case 146: + case 148: case 150: + case 151: continue; default: return false; @@ -21109,7 +20800,7 @@ var ts; return { accessibility: 1, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined, }; } return hasAccessibleDeclarations; @@ -21130,7 +20821,7 @@ var ts; } return { accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 }; @@ -21177,11 +20868,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 158 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 139 || entityName.kind === 172 || - entityName.parent.kind === 229) { + else if (entityName.kind === 140 || entityName.kind === 173 || + entityName.parent.kind === 230) { meaning = 1920; } else { @@ -21273,10 +20964,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164) { + while (node.kind === 165) { node = node.parent; } - if (node.kind === 223) { + if (node.kind === 224) { return getSymbolOfNode(node); } } @@ -21284,7 +20975,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 && + node.parent.kind === 227 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21298,10 +20989,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192: + case 193: return "(Anonymous class)"; - case 179: case 180: + case 181: return "(Anonymous function)"; } } @@ -21315,17 +21006,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } else { - writePunctuation(writer, 21); + writePunctuation(writer, 22); writer.writeSymbol(symbolName, symbol); } } @@ -21401,7 +21092,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 | 65536 | 16 | 16384)) { @@ -21422,23 +21113,23 @@ var ts; writer.writeStringLiteral(literalTypeToString(type)); } else { - writePunctuation(writer, 15); + writePunctuation(writer, 16); writeSpace(writer); - writePunctuation(writer, 22); + writePunctuation(writer, 23); writeSpace(writer); - writePunctuation(writer, 16); + writePunctuation(writer, 17); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24) { + if (delimiter !== 25) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 ? 0 : 64); + writeType(types[i], delimiter === 25 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -21446,29 +21137,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 19); writePunctuation(writer, 20); + writePunctuation(writer, 21); } else if (type.target.flags & 262144) { - writePunctuation(writer, 19); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24); writePunctuation(writer, 20); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); + writePunctuation(writer, 21); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -21483,7 +21174,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } } @@ -21493,16 +21184,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } if (type.flags & 524288) { - writeTypeList(formatUnionTypes(type.types), 47); + writeTypeList(formatUnionTypes(type.types), 48); } else { - writeTypeList(type.types, 46); + writeTypeList(type.types, 47); } if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } } function writeAnonymousType(type, flags) { @@ -21520,7 +21211,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 117); + writeKeyword(writer, 118); } } else { @@ -21541,7 +21232,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 226; + return declaration.parent.kind === 256 || declaration.parent.kind === 227; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21550,37 +21241,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); + writeKeyword(writer, 102); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20); - writePunctuation(writer, 54); + writePunctuation(writer, 21); + writePunctuation(writer, 55); writeSpace(writer); writeType(info.type, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -21598,53 +21289,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); writePunctuation(writer, 16); + writePunctuation(writer, 17); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15); + writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132); - writeIndexSignature(resolved.numberIndexInfo, 130); + writeIndexSignature(resolved.stringIndexInfo, 133); + writeIndexSignature(resolved.numberIndexInfo, 131); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -21654,21 +21345,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16); + writePunctuation(writer, 17); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -21683,7 +21374,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83); + writeKeyword(writer, 84); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -21691,7 +21382,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -21700,36 +21391,36 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 167) { - writePunctuation(writer, 15); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 168) { writePunctuation(writer, 16); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 17); } - else if (bindingPattern.kind === 168) { - writePunctuation(writer, 19); + else if (bindingPattern.kind === 169) { + writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169); + ts.Debug.assert(bindingElement.kind === 170); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -21737,75 +21428,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - var flags_1 = 256; + writePunctuation(writer, 26); + var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); - flags_1 = 0; + flags = 0; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18); + writePunctuation(writer, 19); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97); + writeKeyword(writer, 98); } writeSpace(writer); - writeKeyword(writer, 124); + writeKeyword(writer, 125); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 34); + writePunctuation(writer, 35); } else { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } writeSpace(writer); if (signature.typePredicate) { @@ -21818,7 +21509,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -21854,63 +21545,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169: + case 170: return isDeclarationVisible(node.parent.parent); - case 218: + case 219: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 225: - case 221: + case 226: case 222: case 223: - case 220: case 224: - case 229: + case 221: + case 225: + case 230: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } return isDeclarationVisible(parent_10); + case 146: case 145: - case 144: - case 149: case 150: + case 151: + case 148: case 147: - case 146: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 148: - case 152: - case 151: + case 149: case 153: - case 142: - case 226: - case 156: + case 152: + case 154: + case 143: + case 227: case 157: - case 159: - case 155: + case 158: case 160: + case 156: case 161: case 162: case 163: case 164: + case 165: return isDeclarationVisible(node.parent); - case 231: case 232: - case 234: + case 233: + case 235: return false; - case 141: + case 142: case 256: - case 228: + case 229: return true; - case 235: + case 236: return false; default: return false; @@ -21919,10 +21610,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235) { + if (node.parent && node.parent.kind === 236) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 239) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22001,12 +21692,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218: case 219: + case 220: + case 235: case 234: case 233: case 232: - case 231: node = node.parent; break; default: @@ -22034,12 +21725,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69: + case 70: return name.text; case 9: case 8: return name.text; - case 140: + case 141: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -22047,7 +21738,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -22062,20 +21753,20 @@ var ts; return parentType; } var type; - if (pattern.kind === 167) { - var name_17 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_17)) { + if (pattern.kind === 168) { + var name_14 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_14)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = getTextOfPropertyName(name_17); + var text = getTextOfPropertyName(name_14); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); + error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_14)); return unknownType; } } @@ -22118,15 +21809,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 && - declaration.parent.kind === 219 && - declaration.parent.parent.kind === 200) { + if (declaration.kind === 219 && + declaration.parent.kind === 220 && + declaration.parent.parent.kind === 201) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142) { + else if (declaration.kind === 143) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -22134,9 +21825,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; @@ -22148,10 +21843,10 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 207) { + if (declaration.parent.parent.kind === 208) { return stringType; } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 209) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -22160,15 +21855,19 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { + if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var func = declaration.parent; - if (func.kind === 150 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); + if (func.kind === 151 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22181,8 +21880,7 @@ var ts; } var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -22255,7 +21953,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 + return pattern.kind === 168 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22280,7 +21978,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 ? root.parent : root; + var memberDeclaration = root.kind === 143 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -22293,7 +21991,7 @@ var ts; if (declaration.parent.kind === 252) { return links.type = anyType; } - if (declaration.kind === 235) { + if (declaration.kind === 236) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { @@ -22303,15 +22001,15 @@ var ts; return unknownType; } var type = void 0; - if (declaration.kind === 187 || - declaration.kind === 172 && declaration.parent.kind === 187) { + if (declaration.kind === 188 || + declaration.kind === 173 && declaration.parent.kind === 188) { if (declaration.flags & 1048576) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22337,7 +22035,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149) { + if (accessor.kind === 150) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22357,8 +22055,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149); - var setter = ts.getDeclarationOfKind(symbol, 150); + var getter = ts.getDeclarationOfKind(symbol, 150); + var setter = ts.getDeclarationOfKind(symbol, 151); if (getter && getter.flags & 1048576) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -22399,7 +22097,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149); + var getter_1 = ts.getDeclarationOfKind(symbol, 150); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -22410,7 +22108,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -22495,9 +22193,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 || node.kind === 192 || - node.kind === 220 || node.kind === 179 || - node.kind === 147 || node.kind === 180) { + if (node.kind === 222 || node.kind === 193 || + node.kind === 221 || node.kind === 180 || + node.kind === 148 || node.kind === 181) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22506,15 +22204,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 222); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); 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 === 222 || node.kind === 221 || - node.kind === 192 || node.kind === 223) { + if (node.kind === 223 || node.kind === 222 || + node.kind === 193 || node.kind === 224) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22640,7 +22338,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 === 222 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -22669,7 +22367,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222) { + if (declaration.kind === 223) { if (declaration.flags & 64) { return false; } @@ -22731,7 +22429,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223); + declaration = ts.getDeclarationOfKind(symbol, 224); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -22755,14 +22453,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 69 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22790,7 +22488,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 === 224) { + if (declaration.kind === 225) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22828,7 +22526,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -22877,20 +22575,20 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 166: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: + case 167: return true; - case 160: + case 161: return isIndependentType(node.elementType); - case 155: + case 156: return isIndependentTypeReference(node); } return false; @@ -22899,7 +22597,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -22915,12 +22613,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { + case 146: case 145: - case 144: return isIndependentVariableLikeDeclaration(declaration); - case 147: - case 146: case 148: + case 147: + case 149: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23486,7 +23184,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69) { + if (node.parameterName.kind === 70) { var parameterName = node.parameterName; return { kind: 1, @@ -23525,7 +23223,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166) { + if (param.type && param.type.kind === 167) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23537,10 +23235,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 149 || declaration.kind === 150) && + if ((declaration.kind === 150 || declaration.kind === 151) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 ? 150 : 149; + var otherKind = declaration.kind === 150 ? 151 : 150; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -23552,24 +23250,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 ? + var classType = declaration.kind === 149 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -23585,8 +23280,8 @@ var ts; return type; } } - if (declaration.kind === 149 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150); + if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23600,19 +23295,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: + case 181: case 269: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; @@ -23693,7 +23388,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 || signature.declaration.kind === 152; + var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; var type = createObjectType(2097152); type.members = emptySymbols; type.properties = emptyArray; @@ -23707,7 +23402,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 130 : 132; + var syntaxKind = kind === 1 ? 131 : 133; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -23734,7 +23429,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141).constraint; + return ts.getDeclarationOfKind(type.symbol, 142).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -23767,7 +23462,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); } function getTypeListId(types) { var result = ""; @@ -23867,11 +23562,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155: + case 156: return node.typeName; case 267: return node.name; - case 194: + case 195: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23879,7 +23574,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -23907,11 +23602,11 @@ var ts; var type = void 0; if (node.kind === 267) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 155 + var typeNameOrExpression = node.kind === 156 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -23940,9 +23635,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221: case 222: - case 224: + case 223: + case 225: return declaration; } } @@ -24317,9 +24012,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 148 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24338,25 +24033,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117: + case 118: case 258: case 259: return anyType; - case 132: + case 133: return stringType; - case 130: + case 131: return numberType; - case 120: + case 121: return booleanType; - case 133: + case 134: return esSymbolType; - case 103: + case 104: return voidType; - case 135: + case 136: return undefinedType; - case 93: + case 94: return nullType; - case 127: + case 128: return neverType; case 283: return nullType; @@ -24364,33 +24059,33 @@ var ts; return undefinedType; case 285: return neverType; - case 165: - case 97: - return getTypeFromThisTypeNode(node); case 166: + case 98: + return getTypeFromThisTypeNode(node); + case 167: return getTypeFromLiteralTypeNode(node); case 282: return getTypeFromLiteralTypeNode(node.literal); - case 155: + case 156: case 267: return getTypeFromTypeReference(node); - case 154: + case 155: return booleanType; - case 194: + case 195: return getTypeFromTypeReference(node); - case 158: + case 159: return getTypeFromTypeQueryNode(node); - case 160: + case 161: case 260: return getTypeFromArrayTypeNode(node); - case 161: - return getTypeFromTupleTypeNode(node); case 162: + return getTypeFromTupleTypeNode(node); + case 163: case 261: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); case 164: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: case 263: case 264: case 271: @@ -24399,14 +24094,14 @@ var ts; return getTypeFromTypeNode(node.type); case 265: return getTypeFromTypeNode(node.literal); - case 156: case 157: - case 159: + case 158: + case 160: case 281: case 269: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); - case 69: - case 139: + case 70: + case 140: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262: @@ -24562,23 +24257,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: - case 221: - case 192: + case 181: case 222: + case 193: case 223: + case 224: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24588,14 +24283,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222) { + if (ts.isClassLike(node) || node.kind === 223) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225: + case 226: case 256: return false; } @@ -24630,35 +24325,43 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179: case 180: + case 181: return isContextSensitiveFunctionLikeDeclaration(node); - case 171: + case 172: return ts.forEach(node.properties, isContextSensitive); - case 170: + case 171: return ts.forEach(node.elements, isContextSensitive); - case 188: + case 189: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187: - return node.operatorToken.kind === 52 && + case 188: + return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253: return isContextSensitive(node.initializer); + case 148: case 147: - case 146: return isContextSensitiveFunctionLikeDeclaration(node); - case 178: + case 179: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + if (node.typeParameters) { + return false; + } + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + if (node.kind === 181) { + return false; + } + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -25078,8 +24781,8 @@ var ts; } if (source.flags & 524288 && target.flags & 524288 || source.flags & 1048576 && target.flags & 1048576) { - if (result = eachTypeRelatedToSomeType(source, target, false)) { - if (result &= eachTypeRelatedToSomeType(target, source, false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -25130,7 +24833,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -25727,7 +25430,7 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -25735,7 +25438,7 @@ var ts; type.flags & 64 && type.flags & 16777216 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { @@ -25846,10 +25549,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -25890,25 +25593,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 146: case 145: - case 144: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142: + case 143: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169: + case 170: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: - case 179: + case 151: case 180: + case 181: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -25953,7 +25656,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -25961,7 +25664,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } function couldContainTypeParameters(type) { @@ -26202,7 +25905,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; inferenceSucceeded = !!unionOrSuperType; @@ -26243,10 +25946,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 158: + case 159: return true; - case 69: - case 139: + case 70: + case 140: node = node.parent; continue; default: @@ -26256,14 +25959,14 @@ var ts; ts.Debug.fail("should not get here"); } function getFlowCacheKey(node) { - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97) { + if (node.kind === 98) { return "0"; } - if (node.kind === 172) { + if (node.kind === 173) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -26271,31 +25974,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: return node; - case 172: + case 173: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69: - return target.kind === 69 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 || target.kind === 169) && + case 70: + return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 || target.kind === 170) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97: - return target.kind === 97; - case 172: - return target.kind === 172 && + case 98: + return target.kind === 98; + case 173: + return target.kind === 173 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172) { + while (source.kind === 173) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26304,15 +26007,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 && + return target.kind === 173 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69) { + if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172) { + if (expr.kind === 173) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -26342,7 +26045,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 && + if (callExpression.expression.kind === 173 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26468,7 +26171,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 || node.parent.kind === 253 ? + return node.parent.kind === 171 || node.parent.kind === 253 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -26487,17 +26190,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207: - return stringType; case 208: + return stringType; + case 209: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187: + case 188: return getAssignedTypeOfBinaryExpression(parent); - case 181: + case 182: return undefinedType; - case 170: + case 171: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191: + case 192: return getAssignedTypeOfSpreadElement(parent); case 253: return getAssignedTypeOfPropertyAssignment(parent); @@ -26509,7 +26212,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 ? + var type = pattern.kind === 168 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -26524,38 +26227,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207) { + if (node.parent.parent.kind === 208) { return stringType; } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 209) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 ? + return node.kind === 219 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 || node.kind === 169 ? + return node.kind === 219 || node.kind === 170 ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 && node.parent.kind === 188 && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178: + case 179: return getReferenceCandidate(node.expression); - case 187: + case 188: switch (node.operatorToken.kind) { - case 56: + case 57: return getReferenceCandidate(node.left); - case 24: + case 25: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 || + parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -26626,24 +26342,88 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 ? + autoArrayType : + createArrayType(elementType.flags & 524288 ? + getUnionType(elementType.types, true) : + elementType); + } + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || + parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 && + parent.expression === root && + parent.parent.kind === 188 && + parent.parent.operatorToken.kind === 57 && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 && getTypeWithFacts(result, 524288).flags & 8192) { + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512) { + if (flow.flags & 1024) { for (var i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { return visitedFlowTypes[i]; @@ -26673,18 +26453,25 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172) { + if (container && container !== flowContainer && reference.kind !== 173) { flow = container.flowNode; continue; } type = initialType; } else { - type = declaredType; + type = convertAutoToAny(declaredType); } - if (flow.flags & 512) { + if (flow.flags & 1024) { visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; @@ -26695,30 +26482,70 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 || node.parent.kind === 186) { + if (node.parent.kind === 186 || node.parent.kind === 187) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; } return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | 2048)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192)) { - var assumeTrue = (flow.flags & 32) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + var assumeTrue = (flow.flags & 32) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -26753,7 +26580,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { var id = getFlowNodeId(flow); @@ -26765,8 +26592,8 @@ var ts; return cache[key]; } for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), true); } } var antecedentTypes = []; @@ -26797,14 +26624,14 @@ var ts; break; } } - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 && + return expr.kind === 173 && declaredType.flags & 524288 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -26829,19 +26656,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56: + case 57: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30: case 31: case 32: case 33: + case 34: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 && right_1.kind === 9) { + if (left_1.kind === 183 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 && left_1.kind === 9) { + if (right_1.kind === 183 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -26860,9 +26687,9 @@ var ts; return declaredType; } break; - case 91: + case 92: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24: + case 25: return narrowType(type, expr.right, assumeTrue); } return type; @@ -26871,7 +26698,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -26879,10 +26706,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 || operator === 31; + var doubleEquals = operator === 31 || operator === 32; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 93 ? + value.kind === 94 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -26908,7 +26735,7 @@ var ts; } return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288)) { @@ -27019,7 +26846,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 || invokedExpression.kind === 172) { + if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -27034,18 +26861,18 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174: + case 175: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178: + case 179: return narrowType(type, expr.expression, assumeTrue); - case 187: + case 188: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185: - if (expr.operator === 49) { + case 186: + if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -27054,7 +26881,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 69) { + if (location.kind === 70) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -27068,7 +26895,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178) { + while (expression.kind === 179) { expression = expression.expression; } return expression; @@ -27077,9 +26904,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 || + node.kind === 227 || node.kind === 256 || - node.kind === 145) { + node.kind === 146) { return node; } } @@ -27107,10 +26934,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69) { + if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { symbol.isAssigned = true; } } @@ -27119,12 +26946,15 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 180) { + if (container.kind === 181) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -27142,7 +26972,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 221 + && declaration_1.kind === 222 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27154,11 +26984,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192) { + else if (declaration_1.kind === 193) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 && ts.hasModifier(container, 32)) { + if (container.kind === 146 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -27176,28 +27006,26 @@ var ts; if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 142; + var isParameter = ts.getRootDeclaration(declaration).kind === 143; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || - flowContainer.kind === 180 || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || + flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { @@ -27237,8 +27065,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 206 && - ts.getAncestor(symbol.valueDeclaration, 219).parent === container && + if (container.kind === 207 && + ts.getAncestor(symbol.valueDeclaration, 220).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27250,16 +27078,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 178) { + while (current.parent.kind === 179) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 || current.parent.kind === 186)) { + else if ((current.parent.kind === 186 || current.parent.kind === 187)) { var expr = current.parent; - isAssigned = expr.operator === 41 || expr.operator === 42; + isAssigned = expr.operator === 42 || expr.operator === 43; } if (!isAssigned) { return false; @@ -27276,7 +27104,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 145 || container.kind === 148) { + if (container.kind === 146 || container.kind === 149) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -27310,7 +27138,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 148) { + if (container.kind === 149) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -27320,29 +27148,29 @@ var ts; } } } - if (container.kind === 180) { + if (container.kind === 181) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 225: + case 226: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 224: + case 225: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 148: + case 149: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 146: case 145: - case 144: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140: + case 141: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -27351,7 +27179,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 179 && + if (container.kind === 180 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27363,7 +27191,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -27395,18 +27223,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142) { + if (n.kind === 143) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 180) { + while (container && container.kind === 181) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27415,16 +27243,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 140) { + while (current && current !== container && current.kind !== 141) { current = current.parent; } - if (current && current.kind === 140) { + if (current && current.kind === 141) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27439,7 +27267,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 147 && ts.getModifierFlags(container) & 256) { + if (container.kind === 148 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -27450,7 +27278,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171) { + if (container.parent.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -27468,7 +27296,7 @@ var ts; } return unknownType; } - if (container.kind === 148 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -27480,35 +27308,38 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 148; + return container.kind === 149; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 171) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || - container.kind === 150; + return container.kind === 148 || + container.kind === 147 || + container.kind === 150 || + container.kind === 151; } else { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || + return container.kind === 148 || + container.kind === 147 || container.kind === 150 || + container.kind === 151 || + container.kind === 146 || container.kind === 145 || - container.kind === 144 || - container.kind === 148; + container.kind === 149; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -27558,7 +27389,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -27569,11 +27400,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_18 = declaration.propertyName || declaration.name; + var name_15 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_18)) { - var text = getTextOfPropertyName(name_18); + !ts.isBindingPattern(name_15)) { + var text = getTextOfPropertyName(name_15); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -27610,7 +27441,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 && node.parent.initializer === node) { + if (node.parent.kind === 143 && node.parent.initializer === node) { return true; } node = node.parent; @@ -27619,8 +27450,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 148 || - functionDecl.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150))) { + functionDecl.kind === 149 || + functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -27639,7 +27470,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176) { + if (template.parent.kind === 177) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -27647,7 +27478,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { + if (operator >= 57 && operator <= 69) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -27655,14 +27486,14 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52) { + else if (operator === 53) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); } return type; } - else if (operator === 51 || operator === 24) { + else if (operator === 52 || operator === 25) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -27676,8 +27507,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -27771,36 +27602,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: - case 169: + case 170: return getContextualTypeForInitializerExpression(node); - case 180: - case 211: + case 181: + case 212: return getContextualTypeForReturnExpression(node); - case 190: + case 191: return getContextualTypeForYieldOperand(parent); - case 174: case 175: + case 176: return getContextualTypeForArgument(parent, node); - case 177: - case 195: + case 178: + case 196: return getTypeFromTypeNode(parent.type); - case 187: + case 188: return getContextualTypeForBinaryOperand(node); case 253: case 254: return getContextualTypeForObjectLiteralElement(parent); - case 170: + case 171: return getContextualTypeForElementExpression(node); - case 188: + case 189: return getContextualTypeForConditionalOperand(node); - case 197: - ts.Debug.assert(parent.parent.kind === 189); + case 198: + ts.Debug.assert(parent.parent.kind === 190); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178: + case 179: return getContextualType(parent); case 248: return getContextualType(parent); @@ -27820,7 +27651,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 || node.kind === 180; + return node.kind === 180 || node.kind === 181; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -27833,7 +27664,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -27843,8 +27674,8 @@ var ts; } var signatureList; var types = type.types; - 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 signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -27874,8 +27705,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 169 && !!node.initializer) || - (node.kind === 187 && node.operatorToken.kind === 56); + return (node.kind === 170 && !!node.initializer) || + (node.kind === 188 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -27884,7 +27715,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191) { + if (inDestructuringPattern && e.kind === 192) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -27896,7 +27727,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191; + hasSpreadElement = hasSpreadElement || e.kind === 192; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -27907,7 +27738,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 168 || pattern.kind === 170)) { + if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -27915,7 +27746,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193) { + if (patternElement.kind !== 194) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -27932,7 +27763,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -27976,7 +27807,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 || contextualType.pattern.kind === 171); + (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -27991,7 +27822,7 @@ var ts; if (memberDecl.kind === 253) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147) { + else if (memberDecl.kind === 148) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -28030,7 +27861,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 149 || memberDecl.kind === 150); + ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -28089,10 +27920,10 @@ var ts; case 248: checkJsxExpression(child); break; - case 241: + case 242: checkJsxElement(child); break; - case 242: + case 243: checkJsxSelfClosingElement(child); break; } @@ -28103,7 +27934,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 172 || tagName.kind === 97) { + if (tagName.kind === 173 || tagName.kind === 98) { return false; } else { @@ -28206,7 +28037,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } function getJsxElementPropertiesName() { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -28235,7 +28066,7 @@ var ts; } if (elemType.flags & 524288) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), true); } @@ -28411,7 +28242,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145; + return s.valueDeclaration ? s.valueDeclaration.kind : 146; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -28422,11 +28253,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 || node.kind === 218 ? + var errorNode = node.kind === 173 || node.kind === 219 ? node.name : node.right; - if (left.kind === 95) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 147) { + if (left.kind === 96) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -28446,7 +28277,7 @@ var ts; } return true; } - if (left.kind === 95) { + if (left.kind === 96) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -28520,7 +28351,7 @@ var ts; checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 172 || ts.isAssignmentTarget(node) || + if (node.kind !== 173 || ts.isAssignmentTarget(node) || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 524288)) { return propType; @@ -28542,7 +28373,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 + var left = node.kind === 173 ? node.expression : node.left; var type = checkExpression(left); @@ -28556,13 +28387,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219) { + if (initializer.kind === 220) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69) { + else if (initializer.kind === 70) { return getResolvedSymbol(initializer); } return undefined; @@ -28572,13 +28403,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69) { + if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 && + if (node.kind === 208 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -28594,7 +28425,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 && node.parent.expression === node) { + if (node.parent.kind === 176 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -28617,15 +28448,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_19 !== undefined) { - var prop = getPropertyOfType(objectType, name_19); + var name_16 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_16 !== undefined) { + var prop = getPropertyOfType(objectType, name_16); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_16, symbolToString(objectType.symbol)); return unknownType; } } @@ -28658,7 +28489,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 || indexArgumentExpression.kind === 172) { + if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -28701,10 +28532,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176) { + if (node.kind === 177) { checkExpression(node.template); } - else if (node.kind !== 143) { + else if (node.kind !== 144) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -28755,7 +28586,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191) { + if (arg && arg.kind === 192) { return i; } } @@ -28768,11 +28599,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176) { + if (node.kind === 177) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189) { + if (tagExpression.template.kind === 190) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -28780,11 +28611,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); + ts.Debug.assert(templateLiteral.kind === 12); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143) { + else if (node.kind === 144) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -28792,7 +28623,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 175); + ts.Debug.assert(callExpression.kind === 176); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -28851,9 +28682,9 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); @@ -28898,7 +28729,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175) { + if (thisType && thisType !== voidType && node.kind !== 176) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -28911,9 +28742,9 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -28926,28 +28757,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 174) { + if (node.kind === 175) { var callee = node.expression; - if (callee.kind === 172) { + if (callee.kind === 173) { return callee.expression; } - else if (callee.kind === 173) { + else if (callee.kind === 174) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 176) { + if (node.kind === 177) { var template = node.template; args = [undefined]; - if (template.kind === 189) { + if (template.kind === 190) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143) { + else if (node.kind === 144) { return undefined; } else { @@ -28956,21 +28787,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143) { + if (node.kind === 144) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return 1; - case 145: + case 146: return 2; - case 147: - case 149: + case 148: case 150: + case 151: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 142: + case 143: return 3; } } @@ -28979,48 +28810,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { return anyType; } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var element = node; switch (element.name.kind) { - case 69: + case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 140: + case 141: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -29037,20 +28868,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { return numberType; } - if (node.kind === 145) { + if (node.kind === 146) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -29070,27 +28901,27 @@ var ts; ts.Debug.fail("Decorators should not have a fourth synthetic argument."); return unknownType; } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 143) { + function getEffectiveArgumentType(node, argIndex) { + if (node.kind === 144) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 143 || - (argIndex === 0 && node.kind === 176)) { + if (node.kind === 144 || + (argIndex === 0 && node.kind === 177)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143) { + if (node.kind === 144) { return node.expression; } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return node.template; } else { @@ -29098,12 +28929,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176; - var isDecorator = node.kind === 143; + var isTaggedTemplate = node.kind === 177; + var isDecorator = node.kind === 144; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { + if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); } } @@ -29129,7 +28960,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -29244,7 +29075,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -29397,16 +29228,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147: - case 149: + case 148: case 150: + case 151: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -29433,13 +29264,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174: - return resolveCallExpression(node, candidatesOutArray); case 175: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 176: + return resolveNewExpression(node, candidatesOutArray); + case 177: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143: + case 144: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29468,17 +29299,17 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { return voidType; } - if (node.kind === 175) { + if (node.kind === 176) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 && - declaration.kind !== 152 && - declaration.kind !== 157 && + declaration.kind !== 149 && + declaration.kind !== 153 && + declaration.kind !== 158 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 69 ? + var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -29490,7 +29321,9 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, true) && + !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -29530,21 +29363,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } function assignBindingElementTypes(node) { @@ -29552,7 +29400,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69) { + if (element.name.kind === 70) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -29565,8 +29413,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 || - parameter.valueDeclaration.name.kind === 168)) { + (parameter.valueDeclaration.name.kind === 168 || + parameter.valueDeclaration.name.kind === 169)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -29605,7 +29453,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199) { + if (func.body.kind !== 200) { 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); @@ -29684,7 +29532,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -29713,7 +29561,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 || func.kind === 180)) { + func.kind === 180 || func.kind === 181)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -29730,7 +29578,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -29757,9 +29605,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179) { + if (!hasGrammarError && node.kind === 180) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -29793,14 +29641,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147) { + if (produceDiagnostics && node.kind !== 148) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -29810,7 +29658,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199) { + if (node.body.kind === 200) { checkSourceElement(node.body); } else { @@ -29845,10 +29693,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 172 || expr.kind === 173) && - expr.expression.kind === 97) { + (expr.kind === 173 || expr.kind === 174) && + expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148)) + if (!(func && func.kind === 149)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -29857,13 +29705,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 || expr.kind === 173) { + if (expr.kind === 173 || expr.kind === 174) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232; + return declaration && declaration.kind === 233; } } } @@ -29871,7 +29719,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 && node.kind !== 172 && node.kind !== 173) { + if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { error(expr, invalidReferenceMessage); return false; } @@ -29879,7 +29727,7 @@ var ts; var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); if (symbol) { if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 69 && !(symbol.flags & 3)) { + if (node.kind === 70 && !(symbol.flags & 3)) { error(expr, invalidReferenceMessage); return false; } @@ -29889,7 +29737,7 @@ var ts; } } } - else if (node.kind === 173) { + else if (node.kind === 174) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -29926,24 +29774,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 && node.operand.kind === 8) { + if (node.operator === 37 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 35: case 36: - case 50: + case 37: + case 51: if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49: + case 50: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 41: case 42: + case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); @@ -29969,8 +29817,8 @@ var ts; } if (type.flags & 1572864) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -29984,8 +29832,8 @@ var ts; } if (type.flags & 524288) { 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 (!isTypeOfKind(t, kind)) { return false; } @@ -29994,8 +29842,8 @@ var ts; } if (type.flags & 1048576) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -30033,24 +29881,24 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 || property.kind === 254) { - var name_20 = property.name; - if (name_20.kind === 140) { - checkComputedPropertyName(name_20); + var name_17 = property.name; + if (name_17.kind === 141) { + checkComputedPropertyName(name_17); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name_17)) { return undefined; } - var text = getTextOfPropertyName(name_20); + var text = getTextOfPropertyName(name_17); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -30065,7 +29913,7 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_17)); } } else { @@ -30083,8 +29931,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193) { - if (element.kind !== 191) { + if (element.kind !== 194) { + if (element.kind !== 192) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -30110,7 +29958,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -30137,14 +29985,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 && target.operatorToken.kind === 56) { + if (target.kind === 188 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170) { + if (target.kind === 171) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -30159,49 +30007,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69: + case 70: case 9: - case 10: - case 176: - case 189: case 11: + case 177: + case 190: + case 12: case 8: - case 99: - case 84: - case 93: - case 135: - case 179: - case 192: + case 100: + case 85: + case 94: + case 136: case 180: - case 170: + case 193: + case 181: case 171: - case 182: - case 196: + case 172: + case 183: + case 197: + case 243: case 242: - case 241: return true; - case 188: + case 189: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187: + case 188: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185: case 186: + case 187: switch (node.operator) { - case 49: - case 35: - case 36: case 50: + case 36: + case 37: + case 51: return true; } return false; - case 183: - case 177: - case 195: + case 184: + case 178: + case 196: default: return false; } @@ -30221,34 +30069,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 171 || left.kind === 170)) { + if (operator === 57 && (left.kind === 172 || left.kind === 171)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37: case 38: - case 59: - case 60: case 39: + case 60: case 61: case 40: case 62: - case 36: - case 58: - case 43: + case 41: case 63: + case 37: + case 59: case 44: case 64: case 45: case 65: - case 47: - case 67: - case 48: - case 68: case 46: case 66: + case 48: + case 68: + case 49: + case 69: + case 47: + case 67: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30272,8 +30120,8 @@ var ts; } } return numberType; - case 35: - case 57: + case 36: + case 58: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30302,24 +30150,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57) { + if (operator === 58) { checkAssignmentOperator(resultType); } return resultType; - case 25: - case 27: + case 26: case 28: case 29: + case 30: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30: case 31: case 32: case 33: + case 34: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -30330,22 +30178,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91: + case 92: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: + case 91: return checkInExpression(left, right, leftType, rightType); - case 51: + case 52: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52: + case 53: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56: + case 57: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24: + case 25: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -30363,21 +30211,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 48: + case 68: + return 53; + case 49: + case 69: + return 34; case 47: case 67: return 52; - case 48: - case 68: - return 33; - case 46: - case 66: - return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 && operator <= 68) { + if (produceDiagnostics && operator >= 57 && operator <= 69) { var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); @@ -30449,9 +30297,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 99: + case 100: return trueType; - case 84: + case 85: return falseType; } } @@ -30480,7 +30328,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 || node.kind === 195; + return node.kind === 178 || node.kind === 196; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -30506,14 +30354,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -30536,7 +30384,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139) { + if (node.kind === 140) { type = checkQualifiedName(node); } else { @@ -30544,9 +30392,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 172 && node.parent.expression === node) || - (node.parent.kind === 173 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 139) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 && node.parent.expression === node) || + (node.parent.kind === 174 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 140) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -30555,79 +30403,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69: + case 70: return checkIdentifier(node); - case 97: + case 98: return checkThisExpression(node); - case 95: + case 96: return checkSuperExpression(node); - case 93: + case 94: return nullWideningType; case 9: case 8: - case 99: - case 84: + case 100: + case 85: return checkLiteralExpression(node); - case 189: + case 190: return checkTemplateExpression(node); - case 11: + case 12: return stringType; - case 10: + case 11: return globalRegExpType; - case 170: - return checkArrayLiteral(node, contextualMapper); case 171: - return checkObjectLiteral(node, contextualMapper); + return checkArrayLiteral(node, contextualMapper); case 172: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, contextualMapper); case 173: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 174: + return checkIndexedAccess(node); case 175: - return checkCallExpression(node); case 176: + return checkCallExpression(node); + case 177: return checkTaggedTemplateExpression(node); - case 178: + case 179: return checkExpression(node.expression, contextualMapper); - case 192: + case 193: return checkClassExpression(node); - case 179: case 180: + case 181: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182: + case 183: return checkTypeOfExpression(node); - case 177: - case 195: - return checkAssertion(node); + case 178: case 196: + return checkAssertion(node); + case 197: return checkNonNullAssertion(node); - case 181: + case 182: return checkDeleteExpression(node); - case 183: - return checkVoidExpression(node); case 184: - return checkAwaitExpression(node); + return checkVoidExpression(node); case 185: - return checkPrefixUnaryExpression(node); + return checkAwaitExpression(node); case 186: - return checkPostfixUnaryExpression(node); + return checkPrefixUnaryExpression(node); case 187: - return checkBinaryExpression(node, contextualMapper); + return checkPostfixUnaryExpression(node); case 188: + return checkBinaryExpression(node, contextualMapper); + case 189: return checkConditionalExpression(node, contextualMapper); - case 191: + case 192: return checkSpreadElementExpression(node, contextualMapper); - case 193: + case 194: return undefinedWideningType; - case 190: + case 191: return checkYieldExpression(node); case 248: return checkJsxExpression(node); - case 241: - return checkJsxElement(node); case 242: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 243: + return checkJsxSelfClosingElement(node); + case 244: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -30648,7 +30496,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -30659,7 +30507,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 || func.kind === 152 || func.kind === 157) { + if (func.kind === 149 || func.kind === 153 || func.kind === 158) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -30671,15 +30519,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 || - node.kind === 220 || - node.kind === 179; + return node.kind === 148 || + node.kind === 221 || + node.kind === 180; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 && + if (param.name.kind === 70 && param.name.text === parameter.text) { return i; } @@ -30714,9 +30562,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name_18 = _a[_i].name; + if (ts.isBindingPattern(name_18) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_18, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -30729,13 +30577,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 181: + case 152: + case 221: case 180: - case 151: - case 220: - case 179: - case 156: + case 157: + case 148: case 147: - case 146: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -30748,27 +30596,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 69 && - name_22.text === predicateVariableName) { + var name_19 = element.name; + if (name_19.kind === 70 && + name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 168 || - name_22.kind === 167) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name_19.kind === 169 || + name_19.kind === 168) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 153) { + if (node.kind === 154) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 || node.kind === 220 || node.kind === 157 || - node.kind === 151 || node.kind === 148 || - node.kind === 152) { + else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || + node.kind === 152 || node.kind === 149 || + node.kind === 153) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -30780,10 +30628,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152: + case 153: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151: + case 152: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -30810,11 +30658,17 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Accessor; + (function (Accessor) { + Accessor[Accessor["Getter"] = 1] = "Getter"; + Accessor[Accessor["Setter"] = 2] = "Setter"; + Accessor[Accessor["Property"] = 3] = "Property"; + })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -30823,18 +30677,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149: + case 150: addName(names, member.name, memberName, 1); break; - case 150: + case 151: addName(names, member.name, memberName, 2); break; - case 145: + case 146: addName(names, member.name, memberName, 3); break; } @@ -30860,12 +30714,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144) { + if (member.kind == 145) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 69: + case 70: memberName = member.name.text; break; default: @@ -30882,7 +30736,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222) { + if (node.kind === 223) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -30897,7 +30751,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132: + case 133: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -30905,7 +30759,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130: + case 131: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -30961,15 +30815,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97) { + if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 && n.kind !== 220) { + else if (n.kind !== 180 && n.kind !== 221) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 && + return n.kind === 146 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30989,7 +30843,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31012,18 +30866,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149) { + if (node.kind === 150) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 149 ? 150 : 149; + var otherKind = node.kind === 150 ? 151 : 150; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -31037,11 +30891,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149) { + if (node.kind === 150) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171) { + if (node.parent.kind !== 172) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -31127,9 +30981,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 222 && - n.parent.kind !== 221 && - n.parent.kind !== 192 && + if (n.parent.kind !== 223 && + n.parent.kind !== 222 && + n.parent.kind !== 193 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31206,7 +31060,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 147 || node.kind === 146) && + var reportError = (node.kind === 148 || node.kind === 147) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -31239,11 +31093,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 || node.parent.kind === 159 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 220 || node.kind === 147 || node.kind === 146 || node.kind === 148) { + if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31354,16 +31208,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222: + case 223: return 2097152; - case 225: + case 226: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 221: - case 224: + case 222: + case 225: return 2097152 | 1048576; - case 229: + case 230: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31511,22 +31365,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221: + case 222: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147: - case 149: + case 148: case 150: + case 151: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -31535,9 +31389,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 155) { + if (node && node.kind === 156) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 ? 793064 : 1920; + var meaning = root.parent.kind === 156 ? 793064 : 1920; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -31571,20 +31425,20 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 221: + case 222: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147: - case 149: + case 148: case 150: + case 151: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145: - case 142: + case 146: + case 143: checkTypeAnnotationAsExpression(node); break; } @@ -31604,7 +31458,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 140) { + if (node.name && node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -31647,42 +31501,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256: - case 225: + case 226: checkUnusedModuleMembers(node); break; - case 221: - case 192: + case 222: + case 193: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222: + case 223: checkUnusedTypeParameters(node); break; - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: checkUnusedLocalsAndParameters(node); break; - case 148: - case 179: - case 220: - case 180: - case 147: case 149: + case 180: + case 221: + case 181: + case 148: case 150: + case 151: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146: - case 151: + case 147: case 152: case 153: - case 156: + case 154: case 157: + case 158: checkUnusedTypeParameters(node); break; } @@ -31691,11 +31545,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -31715,19 +31569,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; + return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 || member.kind === 145) { + if (member.kind === 148 || member.kind === 146) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148) { + else if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -31772,7 +31626,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 199) { + if (node.kind === 200) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -31794,19 +31648,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 || - node.kind === 144 || + if (node.kind === 146 || + node.kind === 145 || + node.kind === 148 || node.kind === 147 || - node.kind === 146 || - node.kind === 149 || - node.kind === 150) { + node.kind === 150 || + node.kind === 151) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -31820,7 +31674,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; + var isDeclaration_1 = node.kind !== 70; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -31841,7 +31695,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; + var isDeclaration_2 = node.kind !== 70; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -31851,13 +31705,13 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31869,7 +31723,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31881,7 +31735,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 218 && !node.initializer) { + if (node.kind === 219 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -31891,25 +31745,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219); - var container = varDeclList.parent.kind === 200 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); + var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 199 && ts.isFunctionLike(container.parent) || + (container.kind === 200 && ts.isFunctionLike(container.parent) || + container.kind === 227 || container.kind === 226 || - container.kind === 225 || container.kind === 256); 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); + var name_20 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_20, name_20); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142) { + if (ts.getRootDeclaration(node).kind !== 143) { return; } var func = ts.getContainingFunction(node); @@ -31918,10 +31772,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 172) { + if (n.kind === 173) { return visit(n.expression); } - else if (n.kind === 69) { + else if (n.kind === 70) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -31932,7 +31786,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142) { + if (symbol.valueDeclaration.kind === 143) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -31941,7 +31795,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 145 && + if (current.parent.kind === 146 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -31958,25 +31812,25 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169) { - if (node.propertyName && node.propertyName.kind === 140) { + if (node.kind === 170) { + if (node.propertyName && node.propertyName.kind === 141) { checkComputedPropertyName(node.propertyName); } var parent_13 = node.parent.parent; var parentType = getTypeForBindingElementParent(parent_13); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); + var name_21 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); if (parent_13.initializer && property && getParentOfSymbol(property)) { checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } @@ -31984,12 +31838,12 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 142 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31998,7 +31852,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32016,9 +31870,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 && node.kind !== 144) { + if (node.kind !== 146 && node.kind !== 145) { checkExportsOnMergedDeclarations(node); - if (node.kind === 218 || node.kind === 169) { + if (node.kind === 219 || node.kind === 170) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -32028,8 +31882,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 && right.kind === 218) || - (left.kind === 218 && right.kind === 142)) { + if ((left.kind === 143 && right.kind === 219) || + (left.kind === 219 && right.kind === 143)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32056,7 +31910,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 171) { + if (node.modifiers && node.parent.kind === 172) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -32075,7 +31929,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201) { + if (node.thenStatement.kind === 202) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32092,12 +31946,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219) { + if (node.initializer && node.initializer.kind === 220) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32115,13 +31969,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -32139,7 +31993,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { 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); @@ -32149,7 +32003,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { @@ -32322,7 +32176,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150))); + return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -32344,12 +32198,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 150) { + if (func.kind === 151) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148) { + else if (func.kind === 149) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -32367,7 +32221,7 @@ var ts; } } } - else if (func.kind !== 148 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -32424,7 +32278,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 && current.label.text === node.label.text) { + if (current.kind === 215 && 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; @@ -32450,7 +32304,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { + if (catchClause.variableDeclaration.name.kind !== 70) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -32518,7 +32372,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 140 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -32569,7 +32423,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 || declaration.kind === 222) { + if (declaration.kind === 222 || declaration.kind === 223) { if (!firstDecl) { firstDecl = declaration; } @@ -32706,7 +32560,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 192) { + if (derivedClassDecl.kind === 193) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -32750,7 +32604,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 || kind === 150; + return kind === 150 || kind === 151; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -32817,7 +32671,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -32912,18 +32766,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185: + case 186: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35: return value_1; - case 36: return -value_1; - case 50: return ~value_1; + case 36: return value_1; + case 37: return -value_1; + case 51: return ~value_1; } return undefined; - case 187: + case 188: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -32933,37 +32787,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 47: return left | right; - case 46: return left & right; - case 44: return left >> right; - case 45: return left >>> right; - case 43: return left << right; - case 48: return left ^ right; - case 37: return left * right; - case 39: return left / right; - case 35: return left + right; - case 36: return left - right; - case 40: return left % right; + case 48: return left | right; + case 47: return left & right; + case 45: return left >> right; + case 46: return left >>> right; + case 44: return left << right; + case 49: return left ^ right; + case 38: return left * right; + case 40: return left / right; + case 36: return left + right; + case 37: return left - right; + case 41: return left % right; } return undefined; case 8: return +e.text; - case 178: + case 179: return evalConstant(e.expression); - case 69: + case 70: + case 174: case 173: - case 172: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69) { + if (e.kind === 70) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 173) { + if (e.kind === 174) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32977,10 +32831,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 69) { + if (current.kind === 70) { break; } - else if (current.kind === 172) { + else if (current.kind === 173) { current = current.expression; } else { @@ -33040,7 +32894,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 224) { + if (declaration.kind !== 225) { return false; } var enumDeclaration = declaration; @@ -33063,8 +32917,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 === 221 || - (declaration.kind === 220 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 || + (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33123,7 +32977,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, 221); + var mergedClass = ts.getDeclarationOfKind(symbol, 222); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33166,36 +33020,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200: + case 201: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229: case 230: + case 231: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169: - case 218: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 170: + case 219: + var name_22 = node.name; + if (ts.isBindingPattern(name_22)) { + for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 221: - case 224: - case 220: case 222: case 225: + case 221: case 223: + case 226: + case 224: if (isGlobalAugmentation) { return; } @@ -33211,17 +33065,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69: + case 70: return node; - case 139: + case 140: do { node = node.left; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; - case 172: + case 173: do { node = node.expression; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; } } @@ -33231,9 +33085,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 ? + error(moduleName, node.kind === 237 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33254,7 +33108,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 ? + var message = node.kind === 239 ? 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)); @@ -33281,7 +33135,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { checkImportBinding(importClause.namedBindings); } else { @@ -33316,7 +33170,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.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); } } @@ -33332,7 +33186,7 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -33346,7 +33200,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33370,14 +33224,14 @@ var ts; return; } var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 225 && !ts.isAmbientModule(container)) { + if (container.kind === 226 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { markExportAsReferenced(node); } else { @@ -33385,7 +33239,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { @@ -33437,7 +33291,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 && declaration.kind !== 147) || + return (declaration.kind !== 221 && declaration.kind !== 148) || !!declaration.body; } } @@ -33448,118 +33302,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141: - return checkTypeParameter(node); case 142: + return checkTypeParameter(node); + case 143: return checkParameter(node); + case 146: case 145: - case 144: return checkPropertyDeclaration(node); - case 156: case 157: - case 151: + case 158: case 152: - return checkSignatureDeclaration(node); case 153: return checkSignatureDeclaration(node); + case 154: + return checkSignatureDeclaration(node); + case 148: case 147: - case 146: return checkMethodDeclaration(node); - case 148: - return checkConstructorDeclaration(node); case 149: + return checkConstructorDeclaration(node); case 150: + case 151: return checkAccessorDeclaration(node); - case 155: + case 156: return checkTypeReferenceNode(node); - case 154: + case 155: return checkTypePredicate(node); - case 158: - return checkTypeQuery(node); case 159: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 160: - return checkArrayType(node); + return checkTypeLiteral(node); case 161: - return checkTupleType(node); + return checkArrayType(node); case 162: + return checkTupleType(node); case 163: - return checkUnionOrIntersectionType(node); case 164: + return checkUnionOrIntersectionType(node); + case 165: return checkSourceElement(node.type); - case 220: + case 221: return checkFunctionDeclaration(node); - case 199: - case 226: - return checkBlock(node); case 200: + case 227: + return checkBlock(node); + case 201: return checkVariableStatement(node); - case 202: - return checkExpressionStatement(node); case 203: - return checkIfStatement(node); + return checkExpressionStatement(node); case 204: - return checkDoStatement(node); + return checkIfStatement(node); case 205: - return checkWhileStatement(node); + return checkDoStatement(node); case 206: - return checkForStatement(node); + return checkWhileStatement(node); case 207: - return checkForInStatement(node); + return checkForStatement(node); case 208: - return checkForOfStatement(node); + return checkForInStatement(node); case 209: + return checkForOfStatement(node); case 210: - return checkBreakOrContinueStatement(node); case 211: - return checkReturnStatement(node); + return checkBreakOrContinueStatement(node); case 212: - return checkWithStatement(node); + return checkReturnStatement(node); case 213: - return checkSwitchStatement(node); + return checkWithStatement(node); case 214: - return checkLabeledStatement(node); + return checkSwitchStatement(node); case 215: - return checkThrowStatement(node); + return checkLabeledStatement(node); case 216: + return checkThrowStatement(node); + case 217: return checkTryStatement(node); - case 218: + case 219: return checkVariableDeclaration(node); - case 169: + case 170: return checkBindingElement(node); - case 221: - return checkClassDeclaration(node); case 222: - return checkInterfaceDeclaration(node); + return checkClassDeclaration(node); case 223: - return checkTypeAliasDeclaration(node); + return checkInterfaceDeclaration(node); case 224: - return checkEnumDeclaration(node); + return checkTypeAliasDeclaration(node); case 225: + return checkEnumDeclaration(node); + case 226: return checkModuleDeclaration(node); - case 230: + case 231: return checkImportDeclaration(node); - case 229: + case 230: return checkImportEqualsDeclaration(node); - case 236: + case 237: return checkExportDeclaration(node); - case 235: + case 236: return checkExportAssignment(node); - case 201: + case 202: checkGrammarStatementInAmbientContext(node); return; - case 217: + case 218: checkGrammarStatementInAmbientContext(node); return; - case 239: + case 240: return checkMissingDeclaration(node); } } @@ -33572,17 +33426,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179: case 180: + case 181: + case 148: case 147: - case 146: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149: case 150: + case 151: checkAccessorDeferred(node); break; - case 192: + case 193: checkClassExpressionDeferred(node); break; } @@ -33654,7 +33508,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 && node.parent.statement === node) { + if (node.parent.kind === 213 && node.parent.statement === node) { return true; } node = node.parent; @@ -33680,24 +33534,24 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225: + case 226: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 224: + case 225: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 192: + case 193: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 221: case 222: + case 223: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 179: + case 180: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -33730,33 +33584,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 && + return name.kind === 70 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141: - case 221: + case 142: case 222: case 223: case 224: + case 225: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139) { + while (node.parent && node.parent.kind === 140) { node = node.parent; } - return node.parent && (node.parent.kind === 155 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172) { + while (node.parent && node.parent.kind === 173) { node = node.parent; } - return node.parent && node.parent.kind === 194; + return node.parent && node.parent.kind === 195; } function forEachEnclosingClass(node, callback) { var result; @@ -33773,13 +33627,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139) { + while (nodeOnRightSide.parent.kind === 140) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -33791,7 +33645,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -33803,20 +33657,20 @@ var ts; default: } } - if (entityName.parent.kind === 235 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 172 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 229); + if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 230); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 194) { + if (entityName.parent.kind === 195) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -33832,20 +33686,20 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 69) { + if (entityName.kind === 70) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 172) { + else if (entityName.kind === 173) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139) { + else if (entityName.kind === 140) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -33854,13 +33708,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } else if (entityName.parent.kind === 246) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { return resolveEntityName(entityName, 1); } return undefined; @@ -33878,12 +33732,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69) { + if (node.kind === 70) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 && - node.parent.parent.kind === 167 && + else if (node.parent.kind === 170 && + node.parent.parent.kind === 168 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -33893,11 +33747,11 @@ var ts; } } switch (node.kind) { - case 69: - case 172: - case 139: + case 70: + case 173: + case 140: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: + case 98: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -33905,21 +33759,21 @@ var ts; return sig.thisParameter; } } - case 95: + case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165: + case 166: return getTypeFromTypeNode(node).symbol; - case 121: + case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148) { + if (constructorDeclaration && constructorDeclaration.kind === 149) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 || node.parent.kind === 236) && + ((node.parent.kind === 231 || node.parent.kind === 237) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -33927,7 +33781,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 173 && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -33991,12 +33845,12 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 || expr.kind === 170); - if (expr.parent.kind === 208) { + ts.Debug.assert(expr.kind === 172 || expr.kind === 171); + if (expr.parent.kind === 209) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 187) { + if (expr.parent.kind === 188) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -34004,7 +33858,7 @@ var ts; var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 170); + ts.Debug.assert(expr.parent.kind === 171); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -34040,9 +33894,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_26 = symbol.name; + var name_23 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_23); if (symbol) { symbols_3.push(symbol); } @@ -34145,7 +33999,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 === 199 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34185,18 +34039,18 @@ var ts; return true; } switch (node.kind) { - case 229: - case 231: + case 230: case 232: - case 234: - case 238: + case 233: + case 235: + case 239: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236: + case 237: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235: + case 236: return node.expression - && node.expression.kind === 69 + && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -34428,7 +34282,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 172) || (node.kind === 69 && isInTypeQuery(node)) + var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -34575,6 +34429,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -34634,14 +34489,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -34658,28 +34513,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128) { - if (node.kind === 144 || node.kind === 146) { + if (modifier.kind !== 129) { + if (node.kind === 145 || node.kind === 147) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153) { + if (node.kind === 154) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74: - if (node.kind !== 224 && node.parent.kind === 221) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); + case 75: + if (node.kind !== 225 && node.parent.kind === 222) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; + case 113: case 112: case 111: - case 110: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111) { + if (modifier.kind === 112) { lastProtected = modifier; } - else if (modifier.kind === 110) { + else if (modifier.kind === 111) { lastPrivate = modifier; } if (flags & 28) { @@ -34694,11 +34549,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 110) { + if (modifier.kind === 111) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -34707,7 +34562,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113: + case 114: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -34717,10 +34572,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -34729,17 +34584,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 128: + case 129: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 && node.kind !== 144 && node.kind !== 153 && node.kind !== 142) { + else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 82: + case 83: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -34752,45 +34607,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 122: + case 123: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 115: + case 116: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221) { - if (node.kind !== 147 && - node.kind !== 145 && - node.kind !== 149 && - node.kind !== 150) { + if (node.kind !== 222) { + if (node.kind !== 148 && + node.kind !== 146 && + node.kind !== 150 && + node.kind !== 151) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -34802,14 +34657,14 @@ var ts; } flags |= 128; break; - case 118: + case 119: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -34817,7 +34672,7 @@ var ts; break; } } - if (node.kind === 148) { + if (node.kind === 149) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -34832,13 +34687,13 @@ var ts; } return; } - else if ((node.kind === 230 || node.kind === 229) && flags & 2) { + else if ((node.kind === 231 || node.kind === 230) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -34854,38 +34709,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149: case 150: - case 148: + case 151: + case 149: + case 146: case 145: - case 144: + case 148: case 147: - case 146: - case 153: - case 225: + case 154: + case 226: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 179: case 180: - case 142: + case 181: + case 143: return false; default: - if (node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 227 || node.parent.kind === 256) { return false; } switch (node.kind) { - case 220: - return nodeHasAnyModifiersExcept(node, 118); case 221: - return nodeHasAnyModifiersExcept(node, 115); + return nodeHasAnyModifiersExcept(node, 119); case 222: - case 200: + return nodeHasAnyModifiersExcept(node, 116); case 223: - return true; + case 201: case 224: - return nodeHasAnyModifiersExcept(node, 74); + return true; + case 225: + return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); return false; @@ -34897,10 +34752,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147: - case 220: - case 179: + case 148: + case 221: case 180: + case 181: if (!node.asteriskToken) { return false; } @@ -34916,7 +34771,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -34958,11 +34813,11 @@ var ts; } function checkGrammarFunctionLikeDeclaration(node) { var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180) { + if (node.kind === 181) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34997,7 +34852,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 132 && parameter.type.kind !== 130) { + if (parameter.type.kind !== 133 && parameter.type.kind !== 131) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -35024,7 +34879,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193) { + if (arg.kind === 194) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -35050,7 +34905,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -35063,7 +34918,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -35078,14 +34933,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -35094,19 +34949,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 140) { + if (node.kind !== 141) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 220 || - node.kind === 179 || - node.kind === 147); + ts.Debug.assert(node.kind === 221 || + node.kind === 180 || + node.kind === 148); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -35118,7 +34973,7 @@ var ts; } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -35131,9 +34986,9 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_27 = prop.name; - if (name_27.kind === 140) { - checkGrammarComputedPropertyName(name_27); + var name_24 = prop.name; + if (name_24.kind === 141) { + checkGrammarComputedPropertyName(name_24); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -35141,32 +34996,32 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 || prop.kind !== 147) { + if (mod.kind !== 119 || prop.kind !== 148) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8) { - checkGrammarNumericLiteral(name_27); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_24.kind === 8) { + checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147) { + else if (prop.kind === 148) { currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = GetAccessor; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_24); if (effectiveName === undefined) { continue; } @@ -35176,18 +35031,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_24, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_24)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -35200,12 +35055,12 @@ var ts; continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_25 = jsxAttr.name; + if (!seen[name_25.text]) { + seen[name_25.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_25, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 248 && !initializer.expression) { @@ -35217,7 +35072,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219) { + if (forInOrOfStatement.initializer.kind === 220) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35225,20 +35080,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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); @@ -35262,11 +35117,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 ? + return grammarErrorOnNode(accessor.name, kind === 150 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150) { + else if (kind === 151) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -35285,10 +35140,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -35303,8 +35158,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -35319,10 +35174,10 @@ 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 === 222) { + else if (node.parent.kind === 223) { 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 === 159) { + else if (node.parent.kind === 160) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -35333,9 +35188,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214: + case 215: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 209 + var isMisplacedContinueLabel = node.kind === 210 && !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); @@ -35343,8 +35198,8 @@ var ts; return false; } break; - case 213: - if (node.kind === 210 && !node.label) { + case 214: + if (node.kind === 211 && !node.label) { return false; } break; @@ -35357,13 +35212,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 + var message = node.kind === 211 ? 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 === 210 + var message = node.kind === 211 ? 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); @@ -35375,7 +35230,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 168 || node.name.kind === 167) { + if (node.name.kind === 169 || node.name.kind === 168) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35385,11 +35240,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 && node.parent.parent.kind !== 208) { + if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -35420,8 +35275,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.originalKeywordKind === 108) { + if (name.kind === 70) { + if (name.originalKeywordKind === 109) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -35446,15 +35301,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203: case 204: case 205: - case 212: case 206: + case 213: case 207: case 208: + case 209: return false; - case 214: + case 215: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -35509,7 +35364,7 @@ var ts; return true; } } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 223) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35517,7 +35372,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159) { + else if (node.parent.kind === 160) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35530,13 +35385,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 222 || - node.kind === 223 || + if (node.kind === 223 || + node.kind === 224 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || - node.kind === 228 || + node.kind === 229 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -35545,7 +35400,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 === 200) { + if (ts.isDeclaration(decl) || decl.kind === 201) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -35564,7 +35419,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 === 199 || node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { 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); @@ -35603,46 +35458,46 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139] = [ + _a[140] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143] = [ + _a[144] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177] = [ + _a[178] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195] = [ + _a[196] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196] = [ + _a[197] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224] = [ + _a[225] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225] = [ + _a[226] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226] = [ + _a[227] = [ { name: "statements", test: ts.isStatement } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240] = [ + _a[241] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255] = [ @@ -35658,41 +35513,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return initial; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return initial; } var result = initial; switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: case 287: break; - case 140: + case 141: result = reduceNode(node.expression, f, result); break; - case 142: + case 143: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 143: + case 144: result = reduceNode(node.expression, f, result); break; - case 145: + case 146: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147: + case 148: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35701,12 +35556,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148: + case 149: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 149: + case 150: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35714,51 +35569,51 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 150: + case 151: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 167: case 168: + case 169: result = ts.reduceLeft(node.elements, f, result); break; - case 169: + case 170: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 170: + case 171: result = ts.reduceLeft(node.elements, f, result); break; - case 171: + case 172: result = ts.reduceLeft(node.properties, f, result); break; - case 172: + case 173: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 173: + case 174: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 174: + case 175: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 175: + case 176: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176: + case 177: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179: + case 180: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -35766,117 +35621,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180: + case 181: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178: - case 181: + case 179: case 182: case 183: case 184: - case 190: + case 185: case 191: - case 196: + case 192: + case 197: result = reduceNode(node.expression, f, result); break; - case 185: case 186: + case 187: result = reduceNode(node.operand, f, result); break; - case 187: + case 188: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188: + case 189: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189: + case 190: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192: + case 193: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194: + case 195: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 197: + case 198: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 199: + case 200: result = ts.reduceLeft(node.statements, f, result); break; - case 200: + case 201: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202: + case 203: result = reduceNode(node.expression, f, result); break; - case 203: + case 204: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204: + case 205: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 205: - case 212: + case 206: + case 213: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 206: + case 207: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207: case 208: + case 209: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211: - case 215: + case 212: + case 216: result = reduceNode(node.expression, f, result); break; - case 213: + case 214: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214: + case 215: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216: + case 217: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218: + case 219: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219: + case 220: result = ts.reduceLeft(node.declarations, f, result); break; - case 220: + case 221: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35885,7 +35740,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 221: + case 222: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35893,49 +35748,49 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227: + case 228: result = ts.reduceLeft(node.clauses, f, result); break; - case 230: + case 231: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231: - result = reduceNode(node.name, f, result); - result = reduceNode(node.namedBindings, f, result); - break; case 232: result = reduceNode(node.name, f, result); + result = reduceNode(node.namedBindings, f, result); break; case 233: - case 237: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNode(node.name, f, result); break; case 234: case 238: + result = ts.reduceLeft(node.elements, f, result); + break; + case 235: + case 239: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235: + case 236: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236: + case 237: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 241: + case 242: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242: case 243: + case 244: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -36078,153 +35933,153 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return node; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return node; } switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: return node; - case 140: + case 141: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 142: + case 143: return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 145: + case 146: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: - return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 148: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 149: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 150: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 167: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 168: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 169: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 170: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 171: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 172: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); case 173: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 174: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 175: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 177: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 180: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); case 181: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); case 182: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 183: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 184: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 185: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187: + case 188: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 186: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 187: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 190: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 191: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 192: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 193: 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 194: + case 195: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 197: + case 198: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 199: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 200: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 201: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 202: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 203: - 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 204: - 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 205: - 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 206: - 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 207: - 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 208: - 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 209: - 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 210: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 211: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); case 212: - 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 213: - 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 214: - 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 215: - 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 216: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 217: 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 218: - 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 219: - 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 220: - 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 221: + 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 222: 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 227: + case 228: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230: - 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 231: - 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 232: - 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 233: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 234: - 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 235: - 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 236: - 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 237: - 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 238: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 239: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 242: - 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 243: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + case 244: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -36325,67 +36180,67 @@ var ts; return transformFlags | aggregateTransformFlagsForNode(child); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 && kind <= 166) { + if (kind >= 155 && kind <= 167) { return -3; } switch (kind) { - case 174: case 175: - case 170: - return 537133909; - case 225: - return 546335573; - case 142: - return 538968917; + case 176: + case 171: + return 537922901; + case 226: + return 574729557; + case 143: + return 545262933; + case 181: + return 592227669; case 180: - return 550710101; - case 179: - case 220: - return 550726485; - case 219: - return 538968917; case 221: - case 192: - return 537590613; - case 148: - return 550593365; - case 147: + return 592293205; + case 220: + return 545262933; + case 222: + case 193: + return 539749717; case 149: + return 591760725; + case 148: case 150: - return 550593365; - case 117: - case 130: - case 127: - case 132: - case 120: - case 133: - case 103: - case 141: - case 144: - case 146: case 151: + return 591760725; + case 118: + case 131: + case 128: + case 133: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: - case 222: + case 154: case 223: + case 224: return -3; - case 171: - return 537430869; + case 172: + return 539110741; default: - return 536871765; + return 536874325; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -36423,7 +36278,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -36443,9 +36298,9 @@ var ts; } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -36460,10 +36315,10 @@ var ts; } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -36495,9 +36350,9 @@ var ts; } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -36519,7 +36374,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -36540,7 +36395,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -36550,17 +36405,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171) { + if (target.kind === 172) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170) { + else if (target.kind === 171) { emitArrayLiteralAssignment(target, value, location); } else { - var name_29 = ts.getMutableClone(target); - ts.setSourceMapRange(name_29, target); - ts.setCommentRange(name_29, target); - emitAssignment(name_29, value, location, undefined); + var name_26 = ts.getMutableClone(target); + ts.setSourceMapRange(name_26, target); + ts.setCommentRange(name_26, target); + emitAssignment(name_26, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -36585,8 +36440,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193) { - if (e.kind !== 191) { + if (e.kind !== 194) { + if (e.kind !== 192) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -36615,7 +36470,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167) { + else if (name.kind === 168) { var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); } @@ -36635,7 +36490,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53), defaultValue, ts.createToken(54), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54), defaultValue, ts.createToken(55), value); } function createDestructuringPropertyAccess(expression, propertyName) { if (ts.isComputedPropertyName(propertyName)) { @@ -36673,6 +36528,12 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -36683,8 +36544,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(172); context.enableSubstitution(173); + context.enableSubstitution(174); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -36694,7 +36555,6 @@ var ts; var enabledSubstitutions; var classAliases; var applicableSubstitutions; - var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -36728,15 +36588,32 @@ var ts; } return node; } + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 236: + return visitExportAssignment(node); + case 237: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } function namespaceElementVisitor(node) { return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 236 || - node.kind === 230 || + if (node.kind === 237 || node.kind === 231 || - (node.kind === 229 && - node.moduleReference.kind === 240)) { + node.kind === 232 || + (node.kind === 230 && + node.moduleReference.kind === 241)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -36752,15 +36629,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 148: - return undefined; - case 145: - case 153: case 149: + return undefined; + case 146: + case 154: case 150: - case 147: + case 151: + case 148: return visitorWorker(node); - case 198: + case 199: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -36772,84 +36649,87 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82: - case 77: + case 83: + case 78: return currentNamespace ? undefined : node; - case 112: - case 110: + case 113: case 111: - case 115: - case 118: - case 74: - case 122: - case 128: - case 160: + case 112: + case 116: + case 75: + case 123: + case 129: case 161: - case 159: - case 154: - case 141: - case 117: - case 120: - case 132: - case 130: - case 127: - case 103: + case 162: + case 160: + case 155: + case 142: + case 118: + case 121: case 133: + case 131: + case 128: + case 104: + case 134: + case 158: case 157: + case 159: case 156: - case 158: - case 155: - case 162: case 163: case 164: case 165: case 166: - case 153: - case 143: + case 167: + case 154: + case 144: + case 224: + case 146: + case 149: + return visitConstructor(node); case 223: - case 145: - case 148: - return undefined; - case 222: return ts.createNotEmittedStatement(node); - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); case 251: return visitHeritageClause(node); - case 194: + case 195: return visitExpressionWithTypeArguments(node); - case 147: + case 148: return visitMethodDeclaration(node); - case 149: - return visitGetAccessor(node); case 150: + return visitGetAccessor(node); + case 151: return visitSetAccessor(node); - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: - return visitFunctionExpression(node); case 180: + return visitFunctionExpression(node); + case 181: return visitArrowFunction(node); - case 142: + case 143: return visitParameter(node); - case 178: + case 179: return visitParenthesizedExpression(node); - case 177: - case 195: - return visitAssertionExpression(node); + case 178: case 196: + return visitAssertionExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 197: return visitNonNullExpression(node); - case 224: + case 225: return visitEnumDeclaration(node); - case 184: - return visitAwaitExpression(node); - case 200: + case 201: return visitVariableStatement(node); - case 225: + case 219: + return visitVariableDeclaration(node); + case 226: return visitModuleDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -36859,14 +36739,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256: + case 228: case 227: - case 226: - case 199: + case 200: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 222: case 221: - case 220: if (ts.hasModifier(node, 2)) { break; } @@ -36891,14 +36771,14 @@ var ts; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; @@ -36938,7 +36818,7 @@ var ts; classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); } if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); @@ -36984,7 +36864,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); if (staticProperties.length > 0) { var expressions = []; @@ -36995,7 +36875,7 @@ var ts; } ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -37012,13 +36892,13 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072; + var hasParameterPropertyAssignments = node.transformFlags & 524288; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); } function transformConstructorParameters(constructor) { @@ -37026,7 +36906,7 @@ var ts; ? ts.visitNodes(constructor.parameters, visitor, ts.isParameter) : []; } - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; startLexicalEnvironment(); @@ -37039,7 +36919,7 @@ var ts; statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } @@ -37054,7 +36934,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -37088,24 +36968,24 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 145 + return member.kind === 146 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); } } - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -37113,7 +36993,7 @@ var ts; } return expressions; } - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); @@ -37161,12 +37041,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149: case 150: + case 151: return getAllDecoratorsOfAccessors(node, member); - case 147: + case 148: return getAllDecoratorsOfMethod(member); - case 145: + case 146: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -37244,7 +37124,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 145 + ? member.kind === 146 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -37332,43 +37212,43 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 - || kind === 149 + return kind === 148 || kind === 150 - || kind === 145; + || kind === 151 + || kind === 146; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 147; + return node.kind === 148; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 - || kind === 192 - || kind === 147 - || kind === 149 - || kind === 150; + return kind === 222 + || kind === 193 + || kind === 148 + || kind === 150 + || kind === 151; } function serializeTypeOfNode(node) { switch (node.kind) { - case 145: - case 142: - case 149: - return serializeTypeNode(node.type); + case 146: + case 143: case 150: + return serializeTypeNode(node.type); + case 151: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221: - case 192: - case 147: + case 222: + case 193: + case 148: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 160) { + if (node && node.kind === 161) { return node.elementType; } - else if (node && node.kind === 155) { + else if (node && node.kind === 156) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -37414,52 +37294,52 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103: + case 104: return ts.createVoidZero(); - case 164: + case 165: return serializeTypeNode(node.type); - case 156: case 157: + case 158: return ts.createIdentifier("Function"); - case 160: case 161: + case 162: return ts.createIdentifier("Array"); - case 154: - case 120: + case 155: + case 121: return ts.createIdentifier("Boolean"); - case 132: + case 133: return ts.createIdentifier("String"); - case 166: + case 167: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 99: - case 84: + case 100: + case 85: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130: + case 131: return ts.createIdentifier("Number"); - case 133: + case 134: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155: + case 156: return serializeTypeReferenceNode(node); + case 164: case 163: - case 162: { 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 !== 69) { + if (serializedIndividual.kind !== 70) { serializedUnion = undefined; break; } @@ -37476,10 +37356,10 @@ var ts; return serializedUnion; } } - case 158: case 159: - case 117: - case 165: + case 160: + case 118: + case 166: break; default: ts.Debug.failBadSyntaxKind(node); @@ -37520,22 +37400,22 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69: - var name_30 = ts.getMutableClone(node); - name_30.flags &= ~8; - name_30.original = undefined; - name_30.parent = currentScope; + case 70: + var name_27 = ts.getMutableClone(node); + name_27.flags &= ~8; + name_27.original = undefined; + name_27.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } - return name_30; - case 139: + return name_27; + case 140: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69) { + if (node.left.kind === 70) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -37548,7 +37428,7 @@ var ts; return ts.createPropertyAccess(left, node.right); } function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53), ts.createIdentifier("Symbol"), ts.createToken(54), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54), ts.createIdentifier("Symbol"), ts.createToken(55), ts.createIdentifier("Object")); } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; @@ -37580,9 +37460,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 83) { + if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83, types, node); + return ts.createHeritageClause(84, types, node); } return undefined; } @@ -37593,6 +37473,12 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; @@ -37643,36 +37529,33 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -37694,42 +37577,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, node.body, true); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); - } - } function visitParameter(node) { if (ts.parameterIsThisKeyword(node)) { return undefined; @@ -37756,14 +37603,14 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); } } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } function visitParenthesizedExpression(node) { var innerExpression = ts.skipOuterExpressions(node.expression, ~2); @@ -37781,6 +37628,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } function shouldEmitEnumDeclaration(node) { return !ts.isConst(node) || compilerOptions.preserveConstEnums @@ -37812,7 +37665,7 @@ var ts; var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); @@ -37855,7 +37708,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -37870,9 +37723,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_31 = node.symbol && node.symbol.name; - if (name_31) { - return currentScopeFirstDeclarationsOfName[name_31] === node; + var name_28 = node.symbol && node.symbol.name; + if (name_28) { + return currentScopeFirstDeclarationsOfName[name_28] === node; } } return false; @@ -37887,7 +37740,7 @@ var ts; ts.createVariableDeclaration(getDeclarationName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 224) { + if (node.kind === 225) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -37920,7 +37773,7 @@ var ts; var localName = getLocalName(node); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); @@ -37938,7 +37791,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226) { + if (body.kind === 227) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -37961,17 +37814,67 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 226) { + if (body.kind !== 227) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225) { + if (moduleDeclaration.body.kind === 226) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + function visitImportDeclaration(node) { + if (!node.importClause) { + return node; + } + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + return importClause + ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) + : undefined; + } + function visitImportClause(node) { + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + function visitNamedImportBindings(node) { + if (node.kind === 233) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + function visitImportSpecifier(node) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + function visitExportAssignment(node) { + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + function visitExportDeclaration(node) { + if (!node.exportClause) { + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + return undefined; + } + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + return exportClause + ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) + : undefined; + } + function visitNamedExports(node) { + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + function visitExportSpecifier(node) { + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } function shouldEmitImportEqualsDeclaration(node) { return resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) @@ -37979,7 +37882,9 @@ var ts; } function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -38063,7 +37968,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_32 = ts.getMutableClone(node.name); + var name_29 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -38072,9 +37977,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_32, emitFlags); + ts.setEmitFlags(name_29, emitFlags); } - return name_32; + return name_29; } else { return ts.getGeneratedNameForNode(node); @@ -38091,57 +37996,32 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(69); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4) === 0) { - enabledSubstitutions |= 4; - context.enableSubstitution(174); - context.enableSubstitution(172); - context.enableSubstitution(173); - context.enableEmitNotification(221); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(148); + context.enableSubstitution(70); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(69); + context.enableSubstitution(70); classAliases = ts.createMap(); } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); context.enableSubstitution(254); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 - || kind === 148 - || kind === 147 - || kind === 149 - || kind === 150; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 226; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224; + return ts.getOriginalNode(node).kind === 225; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - if (enabledSubstitutions & 4 && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -38150,7 +38030,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -38164,31 +38043,26 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_30 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_30); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, node); + return ts.createPropertyAssignment(name_30, initializer, node); } - return ts.createPropertyAssignment(name_33, exportedName, node); + return ts.createPropertyAssignment(name_30, exportedName, node); } } return node; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 172: - return substitutePropertyAccessExpression(node); case 173: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 174: - if (enabledSubstitutions & 4) { - return substituteCallExpression(node); - } - break; + return substituteElementAccessExpression(node); } return node; } @@ -38218,8 +38092,8 @@ var ts; if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 225) || - (applicableSubstitutions & 8 && container.kind === 224); + var substitute = (applicableSubstitutions & 2 && container.kind === 226) || + (applicableSubstitutions & 8 && container.kind === 225); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38227,37 +38101,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -38285,18 +38132,6 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); @@ -38329,9 +38164,9 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 241: - return visitJsxElement(node, false); case 242: + return visitJsxElement(node, false); + case 243: return visitJsxSelfClosingElement(node, false); case 248: return visitJsxExpression(node); @@ -38342,13 +38177,13 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 244: + case 10: return visitJsxText(node); case 248: return visitJsxExpression(node); - case 241: - return visitJsxElement(node, true); case 242: + return visitJsxElement(node, true); + case 243: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38465,16 +38300,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 241) { + if (node.kind === 242) { return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_31); } } } @@ -38752,13 +38587,30 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFileExternalHelpersModuleName; + var enabledSubstitutions; + var applicableSubstitutions; + var currentSuperContainer; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -38768,13 +38620,265 @@ var ts; else if (node.transformFlags & 32) { return ts.visitEachChild(node, visitor, context); } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119: + return undefined; + case 185: + return visitAwaitExpression(node); + case 148: + return visitMethodDeclaration(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + } + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression(undefined, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, node.body, true); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4); + } + } + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } + } + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(175); + context.enableSubstitution(173); + context.enableSubstitution(174); + context.enableEmitNotification(222); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(149); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173: + return substitutePropertyAccessExpression(node); + case 174: + return substituteElementAccessExpression(node); + case 175: + if (enabledSubstitutions & 1) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); + } + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); + } + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 + || kind === 149 + || kind === 148 + || kind === 150 + || kind === 151; + } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64) { + return visitorWorker(node); + } + else if (node.transformFlags & 128) { + return ts.visitEachChild(node, visitor, context); + } else { return node; } } function visitorWorker(node) { switch (node.kind) { - case 187: + case 188: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38784,7 +38888,7 @@ var ts; function visitBinaryExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60) { + if (node.operatorToken.kind === 61) { var target = void 0; var value = void 0; if (ts.isElementAccessExpression(left)) { @@ -38804,7 +38908,7 @@ var ts; } return ts.createAssignment(target, ts.createMathPow(value, right, node), node); } - else if (node.operatorToken.kind === 38) { + else if (node.operatorToken.kind === 39) { return ts.createMathPow(left, right, node); } else { @@ -38813,11 +38917,33 @@ var ts; } } } - ts.transformES7 = transformES7; + ts.transformES2016 = transformES2016; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6(context) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; @@ -38880,15 +39006,15 @@ var ts; return visited; } function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 214 || + return (node.transformFlags & 256) !== 0 || + node.kind === 215 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128) { + else if (node.transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -38907,18 +39033,18 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 211: + case 212: return visitReturnStatement(node); - case 200: + case 201: return visitVariableStatement(node); - case 213: + case 214: return visitSwitchStatement(node); + case 211: case 210: - case 209: return visitBreakOrContinueStatement(node); - case 97: + case 98: return visitThisKeyword(node); - case 69: + case 70: return visitIdentifier(node); default: return ts.visitEachChild(node, visitor, context); @@ -38926,74 +39052,74 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 82: + case 83: return node; - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); - case 142: + case 143: return visitParameter(node); - case 220: + case 221: return visitFunctionDeclaration(node); - case 180: + case 181: return visitArrowFunction(node); - case 179: + case 180: return visitFunctionExpression(node); - case 218: + case 219: return visitVariableDeclaration(node); - case 69: + case 70: return visitIdentifier(node); - case 219: + case 220: return visitVariableDeclarationList(node); - case 214: + case 215: return visitLabeledStatement(node); - case 204: - return visitDoStatement(node); case 205: - return visitWhileStatement(node); + return visitDoStatement(node); case 206: - return visitForStatement(node); + return visitWhileStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 202: + case 203: return visitExpressionStatement(node); - case 171: + case 172: return visitObjectLiteralExpression(node); case 254: return visitShorthandPropertyAssignment(node); - case 170: + case 171: return visitArrayLiteralExpression(node); - case 174: - return visitCallExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); - case 178: + case 179: return visitParenthesizedExpression(node, true); - case 187: + case 188: return visitBinaryExpression(node, true); - case 11: case 12: case 13: case 14: + case 15: return visitTemplateLiteral(node); - case 176: + case 177: return visitTaggedTemplateExpression(node); - case 189: - return visitTemplateExpression(node); case 190: + return visitTemplateExpression(node); + case 191: return visitYieldExpression(node); - case 95: - return visitSuperKeyword(node); - case 190: + case 96: + return visitSuperKeyword(); + case 191: return ts.visitEachChild(node, visitor, context); - case 147: + case 148: return visitMethodDeclaration(node); case 256: return visitSourceFileNode(node); - case 200: + case 201: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39008,7 +39134,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 180) { + if (currentNode.kind !== 181) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39016,14 +39142,14 @@ var ts; } } switch (currentNode.kind) { - case 200: + case 201: enclosingVariableStatement = currentNode; break; + case 220: case 219: - case 218: - case 169: - case 167: + case 170: case 168: + case 169: break; default: enclosingVariableStatement = undefined; @@ -39051,7 +39177,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180) { + if (enclosingFunction && enclosingFunction.kind === 181) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39071,13 +39197,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 210 ? 2 : 4; + var jump = node.kind === 211 ? 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 === 210) { + if (node.kind === 211) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39087,7 +39213,7 @@ var ts; } } else { - if (node.kind === 210) { + if (node.kind === 211) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39106,10 +39232,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 24, copyExpr); + expr = ts.createBinary(expr, 25, copyExpr); } } - returnExpression = ts.createBinary(expr, 24, returnExpression); + returnExpression = ts.createBinary(expr, 25, returnExpression); } return ts.createReturn(returnExpression); } @@ -39136,7 +39262,7 @@ var ts; return statement; } function isExportModifier(node) { - return node.kind === 82; + return node.kind === 83; } function visitClassExpression(node) { return transformClassLikeDeclarationToExpression(node); @@ -39146,7 +39272,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); if (ts.getEmitFlags(node) & 524288) { ts.setEmitFlags(classFunction, 524288); } @@ -39166,7 +39292,7 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); var localName = getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; @@ -39236,17 +39362,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 211) { + if (statement.kind === 212) { return true; } - else if (statement.kind === 203) { + else if (statement.kind === 204) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 199) { + else if (statement.kind === 200) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39275,7 +39401,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39311,7 +39437,7 @@ var ts; } } function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536) !== 0; + return (node.transformFlags & 262144) !== 0; } function addDefaultValueAssignmentsIfNeeded(statements, node) { if (!shouldAddDefaultValueAssignments(node)) { @@ -39319,22 +39445,22 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); } } } function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); } else if (initializer) { statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); @@ -39350,7 +39476,7 @@ var ts; statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -39375,7 +39501,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 && node.kind !== 180) { + if (node.transformFlags & 65536 && node.kind !== 181) { captureThisForNode(statements, node, ts.createThis()); } } @@ -39392,20 +39518,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 198: + case 199: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 147: + case 148: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 148: + case 149: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39445,6 +39571,7 @@ var ts; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384); var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -39452,6 +39579,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -39468,7 +39596,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 8192) { + if (node.transformFlags & 32768) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -39483,10 +39611,10 @@ var ts; } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180) { + if (node.kind !== 181) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } @@ -39516,7 +39644,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 180); + ts.Debug.assert(node.kind === 181); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -39543,16 +39671,16 @@ var ts; ts.setEmitFlags(block, 32); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16, closeBraceLocation); + ts.setTokenSourceMapRange(block, 17, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 178: + case 179: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 187: + case 188: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -39560,9 +39688,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 178: + case 179: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 187: + case 188: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -39581,16 +39709,16 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24, acc); }), node); + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { return undefined; @@ -39608,7 +39736,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 2097152 + if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -39627,8 +39755,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 && enclosingBlockScopeContainer.kind !== 208 + && enclosingBlockScopeContainer.kind !== 209 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -39651,7 +39779,7 @@ var ts; if (ts.isBindingPattern(node.name)) { var recordTempVariablesInLine = !enclosingVariableStatement || !ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenVariableDestructuring(context, node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + return ts.flattenVariableDestructuring(node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); } return ts.visitEachChild(node, visitor, context); } @@ -39694,7 +39822,7 @@ var ts; var initializer = node.initializer; var statements = []; var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 + var rhsReference = expression.kind === 70 ? ts.createUniqueName(expression.text) : ts.createTempVariable(undefined); if (ts.isVariableDeclarationList(initializer)) { @@ -39703,7 +39831,7 @@ var ts; } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); var declarationList = ts.createVariableDeclarationList(declarations, initializer); ts.setOriginalNode(declarationList, initializer); var firstDeclaration = declarations[0]; @@ -39759,8 +39887,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 4194304 - || property.name.kind === 140) { + if (property.transformFlags & 16777216 + || property.name.kind === 141) { numInitialProperties = i; break; } @@ -39786,7 +39914,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 69) { + if (node.kind === 70) { state.hoistedLocalVariables.push(node); } else { @@ -39815,11 +39943,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 206: case 207: case 208: + case 209: var initializer = node.initializer; - if (initializer && initializer.kind === 219) { + if (initializer && initializer.kind === 220) { loopInitializer = initializer; } break; @@ -39858,7 +39986,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 4194304) !== 0; + && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256; @@ -39867,7 +39995,7 @@ var ts; loopBodyFlags |= 2097152; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ])); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -39926,7 +40054,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 214 + statements.push(currentParent.kind === 215 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -39934,7 +40062,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56, source); + return ts.createBinary(target, 57, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -39949,7 +40077,7 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37), call) : call; + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); @@ -39968,10 +40096,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -40038,21 +40166,21 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; case 253: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; case 254: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 147: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); + case 148: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -40060,21 +40188,21 @@ var ts; } } } - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); if (startsOnNewLine) { expression.startsOnNewLine = true; @@ -40104,17 +40232,17 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { ts.setEmitFlags(thisArg, 128); } var resultingCall; - if (node.transformFlags & 262144) { + if (node.transformFlags & 1048576) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, 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); } - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 128); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -40125,18 +40253,18 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 262144) !== 0); + ts.Debug.assert((node.transformFlags & 1048576) !== 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, []); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -40147,7 +40275,7 @@ var ts; ? visitSpanOfSpreadElements : visitSpanOfNonSpreadElements; } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfSpreadElements(chunk) { return ts.map(chunk, visitExpressionOfSpreadElement); } function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { @@ -40188,7 +40316,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; + var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.createLiteral(text, node); @@ -40222,11 +40350,11 @@ var ts; } } } - function visitSuperKeyword(node) { + function visitSuperKeyword() { return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 174 + && currentParent.kind !== 175 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40253,20 +40381,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(97); - context.enableEmitNotification(148); - context.enableEmitNotification(147); + context.enableSubstitution(98); context.enableEmitNotification(149); + context.enableEmitNotification(148); context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(181); context.enableEmitNotification(180); - context.enableEmitNotification(179); - context.enableEmitNotification(220); + context.enableEmitNotification(221); } } function onSubstituteNode(emitContext, node) { @@ -40291,10 +40419,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 169: - case 221: - case 224: - case 218: + case 170: + case 222: + case 225: + case 219: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40302,9 +40430,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 97: + case 98: return substituteThisKeyword(node); } return node; @@ -40331,7 +40459,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_36 = ts.getMutableClone(node.name); + var name_33 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -40340,9 +40468,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_36, emitFlags); + ts.setEmitFlags(name_33, emitFlags); } - return name_36; + return name_33; } return ts.getGeneratedNameForNode(node); } @@ -40359,29 +40487,74 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { return false; } var expression = callArgument.expression; return ts.isIdentifier(expression) && expression === parameter.name; } } - ts.transformES6 = transformES6; + ts.transformES2015 = transformES2015; })(ts || (ts = {})); var ts; (function (ts) { + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -40427,7 +40600,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024) { + if (node.transformFlags & 4096) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -40442,10 +40615,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512) { + else if (transformFlags & 2048) { return visitGenerator(node); } - else if (transformFlags & 1024) { + else if (transformFlags & 4096) { return ts.visitEachChild(node, visitor, context); } else { @@ -40454,13 +40627,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 213: - return visitSwitchStatement(node); case 214: + return visitSwitchStatement(node); + case 215: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -40468,30 +40641,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); - case 149: case 150: + case 151: return visitAccessorDeclaration(node); - case 200: + case 201: return visitVariableStatement(node); - case 206: - return visitForStatement(node); case 207: + return visitForStatement(node); + case 208: return visitForInStatement(node); - case 210: + case 211: return visitBreakStatement(node); - case 209: + case 210: return visitContinueStatement(node); - case 211: + case 212: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 | 8388608)) { + else if (node.transformFlags & (4096 | 33554432)) { return ts.visitEachChild(node, visitor, context); } else { @@ -40501,21 +40674,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187: - return visitBinaryExpression(node); case 188: + return visitBinaryExpression(node); + case 189: return visitConditionalExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 170: - return visitArrayLiteralExpression(node); case 171: + return visitArrayLiteralExpression(node); + case 172: return visitObjectLiteralExpression(node); - case 173: - return visitElementAccessExpression(node); case 174: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40523,9 +40696,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40555,7 +40728,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -40628,7 +40801,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -40658,23 +40831,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 - && kind <= 68; + return kind >= 58 + && kind <= 69; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57: return 35; case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; - case 63: return 43; + case 63: return 41; case 64: return 44; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; + case 69: return 49; } } function visitRightAssociativeBinaryExpression(node) { @@ -40682,10 +40855,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172: + case 173: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173: + case 174: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -40694,7 +40867,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -40707,7 +40880,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24) { + else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } var clone_6 = ts.getMutableClone(node); @@ -40721,7 +40894,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -40737,7 +40910,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { visit(node.left); visit(node.right); } @@ -40780,7 +40953,7 @@ var ts; function visitArrayLiteralExpression(node) { return visitElements(node.elements, node.multiLine); } - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); var temp = declareLocal(); var hasAssignedTemp = false; @@ -40841,14 +41014,14 @@ var ts; function visitCallExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, false), node), node); + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node); } return ts.visitEachChild(node, visitor, context); } function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, false)), undefined, [], node), node); + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), undefined, [], node), node); } return ts.visitEachChild(node, visitor, context); } @@ -40877,35 +41050,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199: + case 200: return transformAndEmitBlock(node); - case 202: - return transformAndEmitExpressionStatement(node); case 203: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 204: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 205: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 206: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 207: + return transformAndEmitForStatement(node); + case 208: return transformAndEmitForInStatement(node); - case 209: - return transformAndEmitContinueStatement(node); case 210: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 211: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 212: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 213: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 214: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 215: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 216: + return transformAndEmitThrowStatement(node); + case 217: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41290,7 +41463,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304) !== 0; + return node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -41320,9 +41493,9 @@ 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_8 = ts.getMutableClone(name_37); + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -41431,7 +41604,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69); + context.enableSubstitution(70); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -41630,7 +41803,7 @@ var ts; } return expression; } - return ts.createNode(193); + return ts.createNode(194); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -41718,7 +41891,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -41985,6 +42158,51 @@ var ts; var _a; })(ts || (ts = {})); var ts; +(function (ts) { + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173); + context.enableSubstitution(253); + return transformSourceFile; + function transformSourceFile(node) { + return node; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, node); + } + return node; + } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.createLiteral(name, name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; (function (ts) { function transformModule(context) { var transformModuleDelegates = ts.createMap((_a = {}, @@ -42003,10 +42221,10 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableSubstitution(254); context.enableEmitNotification(256); var currentSourceFile; @@ -42023,7 +42241,7 @@ var ts; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; var updated = transformModule_1(node); ts.aggregateTransformFlags(updated); @@ -42068,7 +42286,7 @@ var ts; ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter("require"), ts.createParameter("exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) @@ -42089,7 +42307,7 @@ var ts; return body; } function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + if (exportEquals) { if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, exportEquals); ts.setEmitFlags(statement, 12288 | 49152); @@ -42104,21 +42322,21 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42194,14 +42412,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); - } + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); } return ts.singleOrMany(statements); } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { + else { return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) @@ -42210,14 +42426,12 @@ var ts; } } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } + if (node.isExportEquals) { + return undefined; } - return undefined; + var statements = []; + addExportDefault(statements, node.expression, node); + return statements; } function addExportDefault(statements, expression, location) { tryAddExportDefaultCompat(statements); @@ -42248,16 +42462,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_38 = names_1[_i]; - addExportMemberAssignments(statements, name_38); + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); } } } function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_39 = node.name; - if (ts.isIdentifier(name_39)) { - names.push(name_39); + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -42280,9 +42494,9 @@ var ts; } function visitVariableStatement(node) { var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 || - originalKind === 224 || - originalKind === 221) { + if (originalKind === 226 || + originalKind === 225 || + originalKind === 222) { if (!ts.hasModifier(node, 1)) { return node; } @@ -42328,7 +42542,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } else { return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); @@ -42338,7 +42552,8 @@ var ts; var statements = []; var name = node.name || ts.getGeneratedNameForNode(node); if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); + var isAsync = ts.hasModifier(node, 256); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); addExportMemberAssignment(statements, node); } else { @@ -42367,10 +42582,10 @@ var ts; function visitExpressionStatement(node) { var original = ts.getOriginalNode(node); var origKind = original.kind; - if (origKind === 224 || origKind === 225) { + if (origKind === 225 || origKind === 226) { return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); } - else if (origKind === 221) { + else if (origKind === 222) { var classDecl = original; if (classDecl.name) { var statements = [node]; @@ -42383,8 +42598,8 @@ var ts; function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { var statements = [node]; if (ts.hasModifier(original, 1) && - original.kind === 224 && - ts.isFirstDeclarationOfKind(original, 224)) { + original.kind === 225 && + ts.isFirstDeclarationOfKind(original, 225)) { addVarForExportedEnumOrNamespaceDeclaration(statements, original); } addExportMemberAssignments(statements, original.name); @@ -42432,12 +42647,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); + case 187: case 186: - case 185: return substituteUnaryExpression(node); } return node; @@ -42471,8 +42686,8 @@ var ts; if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { ts.setEmitFlags(node, 128); var transformedUnaryExpression = void 0; - if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); + if (node.kind === 187) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); ts.setEmitFlags(transformedUnaryExpression, 128); } var nestedExportAssignment = void 0; @@ -42504,21 +42719,11 @@ var ts; var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { - if (languageVersion >= 1) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), node); - } + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(declaration)) { - var name_40 = declaration.propertyName || declaration.name; - if (name_40.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_40.text), node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); - } + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), node); } } } @@ -42544,9 +42749,7 @@ var ts; return statement; } function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 && languageVersion === 0 - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -42593,15 +42796,14 @@ var ts; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableEmitNotification(256); var exportFunctionForFileMap = []; var currentSourceFile; @@ -42641,7 +42843,7 @@ var ts; } function transformSystemModuleWorker(node) { ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); exportFunctionForFile = ts.createUniqueName("exports"); contextObjectForFile = ts.createUniqueName("context"); exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; @@ -42650,7 +42852,7 @@ var ts; addSystemModuleBody(statements, node, dependencyGroups); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, [ + var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); @@ -42673,7 +42875,7 @@ var ts; var exportStarFunction = addExportStarIfNeeded(statements); statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) ]), true))); } function addExportStarIfNeeded(statements) { @@ -42684,7 +42886,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { var externalImport = externalImports_2[_i]; - if (externalImport.kind === 236 && externalImport.exportClause) { + if (externalImport.kind === 237 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -42702,7 +42904,7 @@ var ts; } for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { var externalImport = externalImports_3[_b]; - if (externalImport.kind !== 236) { + if (externalImport.kind !== 237) { continue; } var exportDecl = externalImport; @@ -42731,15 +42933,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 230: + case 231: if (!entry.importClause) { break; } - case 229: + case 230: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 236: + case 237: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -42755,19 +42957,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); } return ts.createArrayLiteral(setters, undefined, true); } function visitSourceElement(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); default: return visitNestedNode(node); @@ -42791,41 +42993,41 @@ var ts; } function visitNestedNodeWorker(node) { switch (node.kind) { - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 206: - return visitForStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 214: + case 215: return visitLabeledStatement(node); - case 212: - return visitWithStatement(node); case 213: + return visitWithStatement(node); + case 214: return visitSwitchStatement(node); - case 227: + case 228: return visitCaseBlock(node); case 249: return visitCaseClause(node); case 250: return visitDefaultClause(node); - case 216: + case 217: return visitTryStatement(node); case 252: return visitCatchClause(node); - case 199: + case 200: return visitBlock(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42852,20 +43054,14 @@ var ts; return undefined; } function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - return undefined; + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } + if (node.isExportEquals) { + return undefined; } - return undefined; + return createExportStatement(ts.createLiteral("default"), node.expression); } function visitVariableStatement(node) { var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || @@ -42897,16 +43093,17 @@ var ts; return ts.createAssignment(name, node.initializer); } else { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - var name_41 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); + var name_38 = node.name || ts.getGeneratedNameForNode(node); + var isAsync = ts.hasModifier(node, 256); + var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512)) { - recordExportName(name_41); + recordExportName(name_38); } ts.setOriginalNode(newNode, node); node = newNode; @@ -42916,14 +43113,14 @@ var ts; } function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_42 = getDeclarationName(originalNode); - if (originalNode.kind === 224) { - hoistVariableDeclaration(name_42); + if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { + var name_39 = getDeclarationName(originalNode); + if (originalNode.kind === 225) { + hoistVariableDeclaration(name_39); } return [ node, - createExportStatement(name_42, name_42) + createExportStatement(name_39, name_39) ]; } return node; @@ -42958,7 +43155,7 @@ var ts; ; return ts.createFor(expressions.length ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); + : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); } else { return ts.visitEachChild(node, visitNestedNode, context); @@ -42970,7 +43167,7 @@ var ts; var name = firstDeclaration.name; return ts.isIdentifier(name) ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } function visitForInStatement(node) { var initializer = node.initializer; @@ -43096,12 +43293,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); - case 185: case 186: + case 187: return substituteUnaryExpression(node); } return node; @@ -43126,14 +43323,14 @@ var ts; ts.setEmitFlags(node, 128); var left = node.left; switch (left.kind) { - case 69: + case 70: var exportDeclaration = resolver.getReferencedExportContainer(left); if (exportDeclaration) { return createExportExpression(left, node); } break; + case 172: case 171: - case 170: if (hasExportedReferenceInDestructuringPattern(left)) { return substituteDestructuring(node); } @@ -43147,9 +43344,9 @@ var ts; } function hasExportedReferenceInDestructuringPattern(node) { switch (node.kind) { - case 69: + case 70: return isExportedBinding(node); - case 171: + case 172: for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var property = _a[_i]; if (hasExportedReferenceInObjectDestructuringElement(property)) { @@ -43157,7 +43354,7 @@ var ts; } } break; - case 170: + case 171: for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { var element = _c[_b]; if (hasExportedReferenceInArrayDestructuringElement(element)) { @@ -43191,7 +43388,7 @@ var ts; function hasExportedReferenceInDestructuringElement(node) { if (ts.isBinaryExpression(node)) { var left = node.left; - return node.operatorToken.kind === 56 + return node.operatorToken.kind === 57 && isDestructuringPattern(left) && hasExportedReferenceInDestructuringPattern(left); } @@ -43211,9 +43408,9 @@ var ts; } function isDestructuringPattern(node) { var kind = node.kind; - return kind === 69 - || kind === 171 - || kind === 170; + return kind === 70 + || kind === 172 + || kind === 171; } function substituteDestructuring(node) { return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); @@ -43222,19 +43419,19 @@ var ts; var operand = node.operand; var operator = node.operator; var substitute = ts.isIdentifier(operand) && - (node.kind === 186 || - (node.kind === 185 && (operator === 41 || operator === 42))); + (node.kind === 187 || + (node.kind === 186 && (operator === 42 || operator === 43))); if (substitute) { var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); ts.setEmitFlags(expr, 128); var call = createExportExpression(operand, expr); - if (node.kind === 185) { + if (node.kind === 186) { return call; } else { - return operator === 41 + return operator === 42 ? ts.createSubtract(call, ts.createLiteral(1)) : ts.createAdd(call, ts.createLiteral(1)); } @@ -43293,12 +43490,7 @@ var ts; else { return undefined; } - if (name.originalKeywordKind && languageVersion === 0) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); } function collectDependencyGroups(externalImports) { var groupIndices = ts.createMap(); @@ -43369,17 +43561,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6Module(context) { + function transformES2015Module(context) { var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; return ts.visitEachChild(node, visitor, context); } return node; @@ -43387,115 +43576,33 @@ var ts; function visitor(node) { switch (node.kind) { case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 231: - return visitImportClause(node); - case 233: - case 232: - return visitNamedBindings(node); - case 234: - return visitImportSpecifier(node); - case 235: - return visitExportAssignment(node); + return undefined; case 236: - return visitExportDeclaration(node); - case 237: - return visitNamedExports(node); - case 238: - return visitExportSpecifier(node); + return visitExportAssignment(node); } return node; } function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? ts.createExportDeclaration(undefined, undefined, newExportClause, node.moduleSpecifier) - : undefined; - } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration(undefined, undefined, newImportClause, node.moduleSpecifier); - } - } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; - } - function visitNamedBindings(node) { - if (node.kind === 232) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; - } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + return node.isExportEquals ? undefined : node; } } - ts.transformES6Module = transformES6Module; + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -43506,11 +43613,19 @@ var ts; if (jsx === 2) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); + if (languageVersion < 4) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3) { + transformers.push(ts.transformES2016); + } if (languageVersion < 2) { - transformers.push(ts.transformES6); + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -43530,7 +43645,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -43670,7 +43785,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -43714,7 +43829,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230); + ts.Debug.assert(aliasEmitInfo.node.kind === 231); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -43745,7 +43860,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -43785,10 +43900,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218) { + if (declaration.kind === 219) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 || declaration.kind === 234 || declaration.kind === 231) { + else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -43799,7 +43914,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 230) { + if (moduleElementEmitInfo.node.kind === 231) { moduleElementEmitInfo.isVisible = true; } else { @@ -43807,12 +43922,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -43924,67 +44039,67 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 165: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: case 166: + case 167: return writeTextOfNode(currentText, type); - case 194: + case 195: return emitExpressionWithTypeArguments(type); - case 155: + case 156: return emitTypeReference(type); - case 158: + case 159: return emitTypeQuery(type); - case 160: - return emitArrayType(type); case 161: - return emitTupleType(type); + return emitArrayType(type); case 162: - return emitUnionType(type); + return emitTupleType(type); case 163: - return emitIntersectionType(type); + return emitUnionType(type); case 164: + return emitIntersectionType(type); + case 165: return emitParenType(type); - case 156: case 157: + case 158: return emitSignatureDeclarationWithJsDocComments(type); - case 159: + case 160: return emitTypeLiteral(type); - case 69: + case 70: return emitEntityName(type); - case 139: + case 140: return emitEntityName(type); - case 154: + case 155: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69) { + if (entityName.kind === 70) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 ? entityName.left : entityName.expression; - var right = entityName.kind === 139 ? entityName.right : entityName.name; + var left = entityName.kind === 140 ? entityName.left : entityName.expression; + var right = entityName.kind === 140 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 229 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 172); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44058,14 +44173,14 @@ var ts; var count = 0; while (true) { count++; - var name_43 = baseName + "_" + count; - if (!(name_43 in currentIdentifiers)) { - return name_43; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } function emitExportAssignment(node) { - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -44086,11 +44201,11 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -44104,7 +44219,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 || + else if (node.kind === 230 || (node.parent.kind === 256 && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { @@ -44116,7 +44231,7 @@ var ts; }); } else { - if (node.kind === 230) { + if (node.kind === 231) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44134,23 +44249,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220: + case 221: return writeFunctionDeclaration(node); - case 200: + case 201: return writeVariableStatement(node); - case 222: + case 223: return writeInterfaceDeclaration(node); - case 221: + case 222: return writeClassDeclaration(node); - case 223: - return writeTypeAliasDeclaration(node); case 224: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 225: + return writeEnumDeclaration(node); + case 226: return writeModuleDeclaration(node); - case 229: - return writeImportEqualsDeclaration(node); case 230: + return writeImportEqualsDeclaration(node); + case 231: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -44165,7 +44280,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 222 && !noDeclare) { + else if (node.kind !== 223 && !noDeclare) { write("declare "); } } @@ -44205,7 +44320,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -44215,7 +44330,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44238,7 +44353,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 232) { + if (node.importClause.namedBindings.kind === 233) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44255,13 +44370,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; var moduleSpecifier; - if (parent.kind === 229) { + if (parent.kind === 230) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225) { + else if (parent.kind === 226) { moduleSpecifier = parent.name; } else { @@ -44329,7 +44444,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226) { + while (node.body && node.body.kind !== 227) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -44363,7 +44478,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -44399,7 +44514,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -44409,49 +44524,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - (node.parent.parent && node.parent.parent.kind === 159)) { - ts.Debug.assert(node.parent.kind === 147 || - node.parent.kind === 146 || - node.parent.kind === 156 || + if (node.parent.kind === 157 || + node.parent.kind === 158 || + (node.parent.parent && node.parent.parent.kind === 160)) { + ts.Debug.assert(node.parent.kind === 148 || + node.parent.kind === 147 || node.parent.kind === 157 || - node.parent.kind === 151 || - node.parent.kind === 152); + node.parent.kind === 158 || + node.parent.kind === 152 || + node.parent.kind === 153); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 221: + case 222: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222: + case 223: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151: + case 152: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 148: case 147: - case 146: 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 === 221) { + else if (node.parent.parent.kind === 222) { 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 220: + case 221: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -44479,16 +44594,16 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93) { + else if (!isImplementsList && node.expression.kind === 94) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 222) { 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; @@ -44568,17 +44683,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 218 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 145 || node.kind === 144 || - (node.kind === 142 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 || node.kind === 145 || + (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 || node.kind === 144) && node.parent.kind === 159) { + if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -44591,14 +44706,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218) { + if (node.kind === 219) { 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 : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 145 || node.kind === 144) { + else if (node.kind === 146 || node.kind === 145) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44606,7 +44721,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 === 221) { + else if (node.parent.kind === 222) { 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 : @@ -44632,7 +44747,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193) { + if (element.kind !== 194) { elements.push(element); } } @@ -44698,7 +44813,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 149 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -44711,7 +44826,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 + return accessor.kind === 150 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -44720,7 +44835,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150) { + if (accessorWithTypeAnnotation.kind === 151) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -44766,17 +44881,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220) { + if (node.kind === 221) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 || node.kind === 148) { + else if (node.kind === 148 || node.kind === 149) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220) { + if (node.kind === 221) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148) { + else if (node.kind === 149) { write("constructor"); } else { @@ -44796,15 +44911,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153) { + if (node.kind === 154) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 152 || node.kind === 157) { + if (node.kind === 153 || node.kind === 158) { write("new "); } - else if (node.kind === 156) { + else if (node.kind === 157) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -44815,20 +44930,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153) { + if (node.kind === 154) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 156 || node.kind === 157; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159) { + var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -44842,23 +44957,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152: + case 153: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 151: + case 152: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153: + case 154: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; + case 148: case 147: - case 146: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44866,7 +44981,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 === 221) { + else if (node.parent.kind === 222) { 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 : @@ -44879,7 +44994,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220: + case 221: 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 : @@ -44911,9 +45026,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - node.parent.parent.kind === 159) { + if (node.parent.kind === 157 || + node.parent.kind === 158 || + node.parent.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -44929,22 +45044,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148: + case 149: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 152: + case 153: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 151: + case 152: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44952,7 +45067,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 === 221) { + else if (node.parent.parent.kind === 222) { 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 : @@ -44964,7 +45079,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 220: + case 221: 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 : @@ -44975,12 +45090,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 167) { + if (bindingPattern.kind === 168) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168) { + else if (bindingPattern.kind === 169) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -44991,10 +45106,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193) { + if (bindingElement.kind === 194) { write(" "); } - else if (bindingElement.kind === 169) { + else if (bindingElement.kind === 170) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45004,7 +45119,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69); + ts.Debug.assert(bindingElement.name.kind === 70); if (bindingElement.dotDotDotToken) { write("..."); } @@ -45016,37 +45131,37 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220: - case 225: - case 229: - case 222: case 221: + case 226: + case 230: case 223: + case 222: case 224: + case 225: return emitModuleElement(node, isModuleElementVisible(node)); - case 200: + case 201: return emitModuleElement(node, isVariableStatementVisible(node)); - case 230: + case 231: return emitModuleElement(node, !node.importClause); - case 236: + case 237: return emitExportDeclaration(node); + case 149: case 148: case 147: - case 146: return writeFunctionDeclaration(node); - case 152: - case 151: case 153: + case 152: + case 154: return emitSignatureDeclarationWithJsDocComments(node); - case 149: case 150: + case 151: return emitAccessorDeclaration(node); + case 146: case 145: - case 144: return emitPropertyDeclaration(node); case 255: return emitEnumMemberDeclaration(node); - case 235: + case 236: return emitExportAssignment(node); case 256: return emitSourceFile(node); @@ -45066,7 +45181,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { if (isBundledEmit && !addBundledFileReference) { return; } @@ -45131,7 +45246,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { if (disabled) { @@ -45334,7 +45449,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } function getSourceMappingURL() { @@ -45398,7 +45513,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -45436,7 +45551,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 219) { + if (node.kind === 220) { declarationListContainerEnd = end; } } @@ -45512,7 +45627,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -45530,7 +45645,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { if (!writer.isAtStartOfLine()) { writer.write(" "); } @@ -45553,7 +45668,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -45636,8 +45751,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); @@ -45815,191 +45936,205 @@ var ts; function pipelineEmitInIdentifierNameContext(node) { var kind = node.kind; switch (kind) { - case 69: + case 70: return emitIdentifier(node); } } function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { - case 12: case 13: case 14: + case 15: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 74: - case 77: - case 82: - case 103: - case 110: + case 75: + case 78: + case 83: + case 104: case 111: case 112: case 113: - case 115: + case 114: + case 116: case 117: case 118: + case 119: case 120: + case 121: case 122: - case 130: + case 123: + case 124: + case 125: + case 126: + case 127: case 128: + case 129: + case 130: + case 131: case 132: case 133: + case 134: + case 135: + case 136: case 137: + case 138: + case 139: writeTokenText(kind); return; - case 139: - return emitQualifiedName(node); case 140: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 141: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 142: - return emitParameter(node); + return emitTypeParameter(node); case 143: - return emitDecorator(node); + return emitParameter(node); case 144: - return emitPropertySignature(node); + return emitDecorator(node); case 145: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 146: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 147: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 148: - return emitConstructor(node); + return emitMethodDeclaration(node); case 149: + return emitConstructor(node); case 150: - return emitAccessorDeclaration(node); case 151: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 152: - return emitConstructSignature(node); + return emitCallSignature(node); case 153: - return emitIndexSignature(node); + return emitConstructSignature(node); case 154: - return emitTypePredicate(node); + return emitIndexSignature(node); case 155: - return emitTypeReference(node); + return emitTypePredicate(node); case 156: - return emitFunctionType(node); + return emitTypeReference(node); case 157: - return emitConstructorType(node); + return emitFunctionType(node); case 158: - return emitTypeQuery(node); + return emitConstructorType(node); case 159: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 160: - return emitArrayType(node); + return emitTypeLiteral(node); case 161: - return emitTupleType(node); + return emitArrayType(node); case 162: - return emitUnionType(node); + return emitTupleType(node); case 163: - return emitIntersectionType(node); + return emitUnionType(node); case 164: + return emitIntersectionType(node); + case 165: return emitParenthesizedType(node); - case 194: + case 195: return emitExpressionWithTypeArguments(node); - case 165: - return emitThisType(node); case 166: - return emitLiteralType(node); + return emitThisType(); case 167: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 168: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 169: + return emitArrayBindingPattern(node); + case 170: return emitBindingElement(node); - case 197: - return emitTemplateSpan(node); case 198: - return emitSemicolonClassElement(node); + return emitTemplateSpan(node); case 199: - return emitBlock(node); + return emitSemicolonClassElement(); case 200: - return emitVariableStatement(node); + return emitBlock(node); case 201: - return emitEmptyStatement(node); + return emitVariableStatement(node); case 202: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 203: - return emitIfStatement(node); + return emitExpressionStatement(node); case 204: - return emitDoStatement(node); + return emitIfStatement(node); case 205: - return emitWhileStatement(node); + return emitDoStatement(node); case 206: - return emitForStatement(node); + return emitWhileStatement(node); case 207: - return emitForInStatement(node); + return emitForStatement(node); case 208: - return emitForOfStatement(node); + return emitForInStatement(node); case 209: - return emitContinueStatement(node); + return emitForOfStatement(node); case 210: - return emitBreakStatement(node); + return emitContinueStatement(node); case 211: - return emitReturnStatement(node); + return emitBreakStatement(node); case 212: - return emitWithStatement(node); + return emitReturnStatement(node); case 213: - return emitSwitchStatement(node); + return emitWithStatement(node); case 214: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 215: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 216: - return emitTryStatement(node); + return emitThrowStatement(node); case 217: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 218: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 219: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 220: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 221: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 222: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 223: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 224: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 225: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 226: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 227: + return emitModuleBlock(node); + case 228: return emitCaseBlock(node); - case 229: - return emitImportEqualsDeclaration(node); case 230: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 231: - return emitImportClause(node); + return emitImportDeclaration(node); case 232: - return emitNamespaceImport(node); + return emitImportClause(node); case 233: - return emitNamedImports(node); + return emitNamespaceImport(node); case 234: - return emitImportSpecifier(node); + return emitNamedImports(node); case 235: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 236: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 237: - return emitNamedExports(node); + return emitExportDeclaration(node); case 238: - return emitExportSpecifier(node); + return emitNamedExports(node); case 239: - return; + return emitExportSpecifier(node); case 240: + return; + case 241: return emitExternalModuleReference(node); - case 244: + case 10: return emitJsxText(node); - case 243: + case 244: return emitJsxOpeningElement(node); case 245: return emitJsxClosingElement(node); @@ -46034,73 +46169,73 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 10: case 11: + case 12: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 84: - case 93: - case 95: - case 99: - case 97: + case 85: + case 94: + case 96: + case 100: + case 98: writeTokenText(kind); return; - case 170: - return emitArrayLiteralExpression(node); case 171: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 172: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 173: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 174: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 175: - return emitNewExpression(node); + return emitCallExpression(node); case 176: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 177: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 178: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 179: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 180: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 181: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 182: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 183: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 184: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 185: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 186: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 187: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 188: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 189: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 190: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 191: - return emitSpreadElementExpression(node); + return emitYieldExpression(node); case 192: - return emitClassExpression(node); + return emitSpreadElementExpression(node); case 193: + return emitClassExpression(node); + case 194: return; - case 195: - return emitAsExpression(node); case 196: + return emitAsExpression(node); + case 197: return emitNonNullExpression(node); - case 241: - return emitJsxElement(node); case 242: + return emitJsxElement(node); + case 243: return emitJsxSelfClosingElement(node); case 288: return emitPartiallyEmittedExpression(node); @@ -46136,7 +46271,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -46206,7 +46341,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 ? "get " : "set "); + write(node.kind === 150 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -46234,7 +46369,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } function emitTypePredicate(node) { @@ -46288,7 +46423,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -46356,7 +46491,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -46371,7 +46506,7 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21)) < 0; + return text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -46388,11 +46523,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488); } function emitTaggedTemplateExpression(node) { @@ -46452,16 +46589,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 185 - && ((node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) - || (node.operator === 36 && (operand.operator === 36 || operand.operator === 42))); + return operand.kind === 186 + && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) + || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24; + var isCommaOperator = node.operatorToken.kind !== 25; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -46522,16 +46659,16 @@ var ts; emitExpression(node.expression); emit(node.literal); } - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); write(" "); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } else { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); emitBlockStatements(node); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } } function emitBlockStatements(node) { @@ -46547,7 +46684,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -46555,16 +46692,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88, node.pos, node); + var openParenPos = writeToken(89, node.pos, node); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitExpression(node.expression); - writeToken(18, node.expression.end, node); + writeToken(19, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80, node.thenStatement.end, node); - if (node.elseStatement.kind === 203) { + writeToken(81, node.thenStatement.end, node); + if (node.elseStatement.kind === 204) { write(" "); emit(node.elseStatement); } @@ -46593,9 +46730,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -46605,28 +46742,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219) { + if (node.kind === 220) { emit(node); } else { @@ -46635,17 +46772,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75, node.pos); + writeToken(76, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70, node.pos); + writeToken(71, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94, node.pos, node); + writeToken(95, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -46656,11 +46793,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96, node.pos); + var openParenPos = writeToken(97, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); write(" "); emit(node.caseBlock); } @@ -46685,11 +46822,12 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); write(";"); } function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -46716,13 +46854,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -46745,7 +46883,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { if (ts.getEmitFlags(body) & 32) { return true; } @@ -46769,14 +46907,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16, body.statements.end, body); + writeToken(17, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -46854,7 +46992,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225) { + while (body.kind === 226) { write("."); emit(body.name); body = body.body; @@ -46877,9 +47015,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15, node.pos); + writeToken(16, node.pos); emitList(node, node.clauses, 65); - writeToken(16, node.clauses.end); + writeToken(17, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -46890,7 +47028,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47010,7 +47148,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47048,11 +47186,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72, node.pos); + var openParenPos = writeToken(73, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emit(node.variableDeclaration); - writeToken(18, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -47159,7 +47297,7 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192) { + if ((languageVersion < 4) && (!awaiterEmitted && node.flags & 8192)) { writeLines(awaiterHelper); if (languageVersion < 2) { writeLines(generatorHelper); @@ -47468,1409 +47606,2554 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 && ts.nodeIsSynthesized(node)) { node = node.expression; } - return node; + return node; + } + function getTextOfNode(node, includeTrivia) { + if (ts.isGeneratedIdentifier(node)) { + return getGeneratedIdentifier(node); + } + else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { + return ts.unescapeIdentifier(node.text); + } + else if (node.kind === 9 && node.textSourceNode) { + return getTextOfNode(node.textSourceNode, includeTrivia); + } + else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { + return node.text; + } + return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); + } + function getLiteralTextOfNode(node) { + if (node.kind === 9 && node.textSourceNode) { + var textSourceNode = node.textSourceNode; + if (ts.isIdentifier(textSourceNode)) { + return "\"" + ts.escapeNonAsciiCharacters(ts.escapeString(getTextOfNode(textSourceNode))) + "\""; + } + else { + return getLiteralTextOfNode(textSourceNode); + } + } + return ts.getLiteralText(node, currentSourceFile, languageVersion); + } + function isSingleLineEmptyBlock(block) { + return !block.multiLine + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 + && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + } + function isUniqueName(name) { + return !resolver.hasGlobalName(name) && + !ts.hasProperty(currentFileIdentifiers, name) && + !ts.hasProperty(generatedNameSet, name); + } + function isUniqueLocalName(name, container) { + for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { + if (node.locals && ts.hasProperty(node.locals, name)) { + if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { + return false; + } + } + } + return true; + } + function makeTempVariableName(flags) { + if (flags && !(tempFlags & flags)) { + var name_41 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_41)) { + tempFlags |= flags; + return name_41; + } + } + while (true) { + var count = tempFlags & 268435455; + tempFlags++; + if (count !== 8 && count !== 13) { + var name_42 = count < 26 + ? "_" + String.fromCharCode(97 + count) + : "_" + (count - 26); + if (isUniqueName(name_42)) { + return name_42; + } + } + } + } + function makeUniqueName(baseName) { + if (baseName.charCodeAt(baseName.length - 1) !== 95) { + baseName += "_"; + } + var i = 1; + while (true) { + var generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + function generateNameForModuleOrEnum(node) { + var name = getTextOfNode(node.name); + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + function generateNameForImportOrExportDeclaration(node) { + var expr = ts.getExternalModuleName(node); + var baseName = expr.kind === 9 ? + ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; + return makeUniqueName(baseName); + } + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + function generateNameForNode(node) { + switch (node.kind) { + case 70: + return makeUniqueName(getTextOfNode(node)); + case 226: + case 225: + return generateNameForModuleOrEnum(node); + case 231: + case 237: + return generateNameForImportOrExportDeclaration(node); + case 221: + case 222: + case 236: + return generateNameForExportDefault(); + case 193: + return generateNameForClassExpression(); + default: + return makeTempVariableName(0); + } + } + function generateName(name) { + switch (name.autoGenerateKind) { + case 1: + return makeTempVariableName(0); + case 2: + return makeTempVariableName(268435456); + case 3: + return makeUniqueName(name.text); + } + ts.Debug.fail("Unsupported GeneratedIdentifierKind."); + } + function getNodeForGeneratedName(name) { + var autoGenerateId = name.autoGenerateId; + var node = name; + var original = node.original; + while (original) { + node = original; + if (ts.isIdentifier(node) + && node.autoGenerateKind === 4 + && node.autoGenerateId !== autoGenerateId) { + break; + } + original = node.original; + } + return 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))); + } + else { + var autoGenerateId = name.autoGenerateId; + return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); + } + } + function createDelimiterMap() { + var delimiters = []; + delimiters[0] = ""; + delimiters[16] = ","; + delimiters[4] = " |"; + delimiters[8] = " &"; + return delimiters; + } + function getDelimiter(format) { + return delimiters[format & 28]; + } + function createBracketsMap() { + var brackets = []; + brackets[512] = ["{", "}"]; + brackets[1024] = ["(", ")"]; + brackets[2048] = ["<", ">"]; + brackets[4096] = ["[", "]"]; + return brackets; + } + function getOpeningBracket(format) { + return brackets[format & 7680][0]; + } + function getClosingBracket(format) { + return brackets[format & 7680][1]; + } + } + ts.emitFiles = emitFiles; + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.version = "2.1.0"; + var emptyArray = []; + function findConfigFile(searchPath, fileExists, configName) { + if (configName === void 0) { configName = "tsconfig.json"; } + while (true) { + var fileName = ts.combinePaths(searchPath, configName); + if (fileExists(fileName)) { + return fileName; + } + var parentPath = ts.getDirectoryPath(searchPath); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + } + ts.findConfigFile = findConfigFile; + function resolveTripleslashReference(moduleName, containingFile) { + var basePath = ts.getDirectoryPath(containingFile); + var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); + return ts.normalizePath(referencedFileName); + } + ts.resolveTripleslashReference = resolveTripleslashReference; + function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) { + var commonPathComponents; + var failed = ts.forEach(fileNames, function (sourceFile) { + var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory); + sourcePathComponents.pop(); + if (!commonPathComponents) { + commonPathComponents = sourcePathComponents; + return; + } + for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { + if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { + if (i === 0) { + return true; + } + commonPathComponents.length = i; + break; + } + } + if (sourcePathComponents.length < commonPathComponents.length) { + commonPathComponents.length = sourcePathComponents.length; + } + }); + if (failed) { + return ""; + } + if (!commonPathComponents) { + return currentDirectory; + } + return ts.getNormalizedPathFromPathComponents(commonPathComponents); + } + ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames; + function createCompilerHost(options, setParentNodes) { + var existingDirectories = ts.createMap(); + function getCanonicalFileName(fileName) { + return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + } + var unsupportedFileEncodingErrorCode = -2147024809; + function getSourceFile(fileName, languageVersion, onError) { + var text; + try { + ts.performance.mark("beforeIORead"); + text = ts.sys.readFile(fileName, options.charset); + ts.performance.mark("afterIORead"); + ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); + } + catch (e) { + if (onError) { + onError(e.number === unsupportedFileEncodingErrorCode + ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText + : e.message); + } + text = ""; + } + return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + } + function directoryExists(directoryPath) { + if (directoryPath in existingDirectories) { + return true; + } + if (ts.sys.directoryExists(directoryPath)) { + existingDirectories[directoryPath] = true; + return true; + } + return false; + } + function ensureDirectoriesExist(directoryPath) { + if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { + var parentDirectory = ts.getDirectoryPath(directoryPath); + ensureDirectoriesExist(parentDirectory); + ts.sys.createDirectory(directoryPath); + } + } + var outputFingerprints; + function writeFileIfUpdated(fileName, data, writeByteOrderMark) { + if (!outputFingerprints) { + outputFingerprints = ts.createMap(); + } + var hash = ts.sys.createHash(data); + var mtimeBefore = ts.sys.getModifiedTime(fileName); + if (mtimeBefore && fileName in outputFingerprints) { + var fingerprint = outputFingerprints[fileName]; + if (fingerprint.byteOrderMark === writeByteOrderMark && + fingerprint.hash === hash && + fingerprint.mtime.getTime() === mtimeBefore.getTime()) { + return; + } + } + ts.sys.writeFile(fileName, data, writeByteOrderMark); + var mtimeAfter = ts.sys.getModifiedTime(fileName); + outputFingerprints[fileName] = { + hash: hash, + byteOrderMark: writeByteOrderMark, + mtime: mtimeAfter + }; + } + function writeFile(fileName, data, writeByteOrderMark, onError) { + try { + ts.performance.mark("beforeIOWrite"); + ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); + if (ts.isWatchSet(options) && ts.sys.createHash && ts.sys.getModifiedTime) { + writeFileIfUpdated(fileName, data, writeByteOrderMark); + } + else { + ts.sys.writeFile(fileName, data, writeByteOrderMark); + } + ts.performance.mark("afterIOWrite"); + ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); + } + catch (e) { + if (onError) { + onError(e.message); + } + } + } + function getDefaultLibLocation() { + return ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())); + } + var newLine = ts.getNewLineCharacter(options); + var realpath = ts.sys.realpath && (function (path) { return ts.sys.realpath(path); }); + return { + getSourceFile: getSourceFile, + getDefaultLibLocation: getDefaultLibLocation, + getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); }, + writeFile: writeFile, + getCurrentDirectory: ts.memoize(function () { return ts.sys.getCurrentDirectory(); }), + useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, + getCanonicalFileName: getCanonicalFileName, + getNewLine: function () { return newLine; }, + fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, + readFile: function (fileName) { return ts.sys.readFile(fileName); }, + trace: function (s) { return ts.sys.write(s + newLine); }, + directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); }, + getEnvironmentVariable: function (name) { return ts.sys.getEnvironmentVariable ? ts.sys.getEnvironmentVariable(name) : ""; }, + getDirectories: function (path) { return ts.sys.getDirectories(path); }, + realpath: realpath + }; + } + ts.createCompilerHost = createCompilerHost; + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (program.getCompilerOptions().declaration) { + diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + } + return ts.sortAndDeduplicateDiagnostics(diagnostics); + } + ts.getPreEmitDiagnostics = getPreEmitDiagnostics; + function formatDiagnostics(diagnostics, host) { + var output = ""; + for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) { + var diagnostic = diagnostics_1[_i]; + if (diagnostic.file) { + var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; + var fileName = diagnostic.file.fileName; + var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); + output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): "; + } + var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); + output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + } + return output; + } + ts.formatDiagnostics = formatDiagnostics; + function flattenDiagnosticMessageText(messageText, newLine) { + if (typeof messageText === "string") { + return messageText; + } + else { + var diagnosticChain = messageText; + var result = ""; + var indent = 0; + while (diagnosticChain) { + if (indent) { + result += newLine; + for (var i = 0; i < indent; i++) { + result += " "; + } + } + result += diagnosticChain.messageText; + indent++; + diagnosticChain = diagnosticChain.next; + } + return result; + } + } + ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; + function loadWithLocalCache(names, containingFile, loader) { + if (names.length === 0) { + return []; + } + var resolutions = []; + var cache = ts.createMap(); + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name_43 = names_2[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); + resolutions.push(result); + } + return resolutions; + } + function createProgram(rootNames, options, host, oldProgram) { + var program; + var files = []; + var commonSourceDirectory; + var diagnosticsProducingTypeChecker; + var noDiagnosticsTypeChecker; + var classifiableNames; + var resolvedTypeReferenceDirectives = ts.createMap(); + var fileProcessingDiagnostics = ts.createDiagnosticCollection(); + var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; + var currentNodeModulesDepth = 0; + var modulesWithElidedImports = ts.createMap(); + var sourceFilesFoundSearchingNodeModules = ts.createMap(); + ts.performance.mark("beforeProgram"); + host = host || createCompilerHost(options); + var skipDefaultLib = options.noLib; + var programDiagnostics = ts.createDiagnosticCollection(); + var currentDirectory = host.getCurrentDirectory(); + var supportedExtensions = ts.getSupportedExtensions(options); + var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); + var resolveModuleNamesWorker; + if (host.resolveModuleNames) { + resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + } + else { + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; + } + var resolveTypeReferenceDirectiveNamesWorker; + if (host.resolveTypeReferenceDirectives) { + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; + } + else { + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader_2); }; + } + var filesByName = ts.createFileMap(); + var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; + if (!tryReuseStructureFromOldProgram()) { + ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); + var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + if (typeReferences.length) { + var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); + for (var i = 0; i < typeReferences.length; i++) { + processTypeReferenceDirective(typeReferences[i], resolutions[i]); + } + } + if (!skipDefaultLib) { + if (!options.lib) { + processRootFile(host.getDefaultLibFileName(options), true); + } + else { + var libDirectory_1 = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(host.getDefaultLibFileName(options)); + ts.forEach(options.lib, function (libFileName) { + processRootFile(ts.combinePaths(libDirectory_1, libFileName), true); + }); + } + } + } + oldProgram = undefined; + program = { + getRootFileNames: function () { return rootNames; }, + getSourceFile: getSourceFile, + getSourceFileByPath: getSourceFileByPath, + getSourceFiles: function () { return files; }, + getCompilerOptions: function () { return options; }, + getSyntacticDiagnostics: getSyntacticDiagnostics, + getOptionsDiagnostics: getOptionsDiagnostics, + getGlobalDiagnostics: getGlobalDiagnostics, + getSemanticDiagnostics: getSemanticDiagnostics, + getDeclarationDiagnostics: getDeclarationDiagnostics, + getTypeChecker: getTypeChecker, + getClassifiableNames: getClassifiableNames, + getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, + getCommonSourceDirectory: getCommonSourceDirectory, + emit: emit, + getCurrentDirectory: function () { return currentDirectory; }, + getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, + getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, + getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, + getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, + getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker + }; + verifyCompilerOptions(); + ts.performance.mark("afterProgram"); + ts.performance.measure("Program", "beforeProgram", "afterProgram"); + return program; + function getCommonSourceDirectory() { + if (typeof commonSourceDirectory === "undefined") { + if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { + commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); + } + else { + commonSourceDirectory = computeCommonSourceDirectory(files); + } + if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { + commonSourceDirectory += ts.directorySeparator; + } + } + return commonSourceDirectory; + } + function getClassifiableNames() { + if (!classifiableNames) { + getTypeChecker(); + classifiableNames = ts.createMap(); + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var sourceFile = files_2[_i]; + ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + } + } + return classifiableNames; } - function getTextOfNode(node, includeTrivia) { - if (ts.isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + function tryReuseStructureFromOldProgram() { + if (!oldProgram) { + return false; } - else if (ts.isIdentifier(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return ts.unescapeIdentifier(node.text); + var oldOptions = oldProgram.getCompilerOptions(); + if ((oldOptions.module !== options.module) || + (oldOptions.moduleResolution !== options.moduleResolution) || + (oldOptions.noResolve !== options.noResolve) || + (oldOptions.target !== options.target) || + (oldOptions.noLib !== options.noLib) || + (oldOptions.jsx !== options.jsx) || + (oldOptions.allowJs !== options.allowJs) || + (oldOptions.rootDir !== options.rootDir) || + (oldOptions.configFilePath !== options.configFilePath) || + (oldOptions.baseUrl !== options.baseUrl) || + (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || + !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || + !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || + !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || + !ts.equalOwnProperties(oldOptions.paths, options.paths)) { + return false; } - else if (node.kind === 9 && node.textSourceNode) { - return getTextOfNode(node.textSourceNode, includeTrivia); + ts.Debug.assert(!oldProgram.structureIsReused); + var oldRootNames = oldProgram.getRootFileNames(); + if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { + return false; } - else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) { - return node.text; + if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { + return false; } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia); - } - function getLiteralTextOfNode(node) { - if (node.kind === 9 && node.textSourceNode) { - var textSourceNode = node.textSourceNode; - if (ts.isIdentifier(textSourceNode)) { - return "\"" + ts.escapeNonAsciiCharacters(ts.escapeString(getTextOfNode(textSourceNode))) + "\""; + var newSourceFiles = []; + var filePaths = []; + var modifiedSourceFiles = []; + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var oldSourceFile = _a[_i]; + var newSourceFile = host.getSourceFileByPath + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) + : host.getSourceFile(oldSourceFile.fileName, options.target); + if (!newSourceFile) { + return false; + } + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); + if (oldSourceFile !== newSourceFile) { + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + return false; + } + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + return false; + } + if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + return false; + } + var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath); + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + if (resolveTypeReferenceDirectiveNamesWorker) { + var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; + modifiedSourceFiles.push(newSourceFile); } else { - return getLiteralTextOfNode(textSourceNode); + newSourceFile = oldSourceFile; } + newSourceFiles.push(newSourceFile); } - return ts.getLiteralText(node, currentSourceFile, languageVersion); + for (var i = 0, len = newSourceFiles.length; i < len; i++) { + filesByName.set(filePaths[i], newSourceFiles[i]); + } + files = newSourceFiles; + fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + } + resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); + oldProgram.structureIsReused = true; + return true; } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); + function getEmitHost(writeFileCallback) { + return { + getCanonicalFileName: getCanonicalFileName, + getCommonSourceDirectory: program.getCommonSourceDirectory, + getCompilerOptions: program.getCompilerOptions, + getCurrentDirectory: function () { return currentDirectory; }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: program.getSourceFile, + getSourceFileByPath: program.getSourceFileByPath, + getSourceFiles: program.getSourceFiles, + isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + isEmitBlocked: isEmitBlocked, + }; } - function isEmptyBlock(block) { - return block.statements.length === 0 - && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); + function getDiagnosticsProducingTypeChecker() { + return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } - function isUniqueName(name) { - return !resolver.hasGlobalName(name) && - !ts.hasProperty(currentFileIdentifiers, name) && - !ts.hasProperty(generatedNameSet, name); + function dropDiagnosticsProducingTypeChecker() { + diagnosticsProducingTypeChecker = undefined; } - function isUniqueLocalName(name, container) { - for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { - return false; - } - } - } - return true; + function getTypeChecker() { + return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function makeTempVariableName(flags) { - if (flags && !(tempFlags & flags)) { - var name_44 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_44)) { - tempFlags |= flags; - return name_44; - } - } - while (true) { - var count = tempFlags & 268435455; - tempFlags++; - if (count !== 8 && count !== 13) { - var name_45 = count < 26 - ? "_" + String.fromCharCode(97 + count) - : "_" + (count - 26); - if (isUniqueName(name_45)) { - return name_45; - } - } - } + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); } - function makeUniqueName(baseName) { - if (baseName.charCodeAt(baseName.length - 1) !== 95) { - baseName += "_"; + function isEmitBlocked(emitFileName) { + return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + var declarationDiagnostics = []; + if (options.noEmit) { + return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } - var i = 1; - while (true) { - var generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return generatedNameSet[generatedName] = generatedName; + if (options.noEmitOnError) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + if (diagnostics.length === 0 && program.getCompilerOptions().declaration) { + declarationDiagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken); + } + if (diagnostics.length > 0 || declarationDiagnostics.length > 0) { + return { + diagnostics: ts.concatenate(diagnostics, declarationDiagnostics), + sourceMaps: undefined, + emittedFiles: undefined, + emitSkipped: true + }; } - i++; } + var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); + ts.performance.mark("beforeEmit"); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); + ts.performance.mark("afterEmit"); + ts.performance.measure("Emit", "beforeEmit", "afterEmit"); + return emitResult; } - function generateNameForModuleOrEnum(node) { - var name = getTextOfNode(node.name); - return isUniqueLocalName(name, node) ? name : makeUniqueName(name); - } - function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); - var baseName = expr.kind === 9 ? - ts.escapeIdentifier(ts.makeIdentifierFromModuleName(expr.text)) : "module"; - return makeUniqueName(baseName); - } - function generateNameForExportDefault() { - return makeUniqueName("default"); + function getSourceFile(fileName) { + return getSourceFileByPath(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } - function generateNameForClassExpression() { - return makeUniqueName("class"); + function getSourceFileByPath(path) { + return filesByName.get(path); } - function generateNameForNode(node) { - switch (node.kind) { - case 69: - return makeUniqueName(getTextOfNode(node)); - case 225: - case 224: - return generateNameForModuleOrEnum(node); - case 230: - case 236: - return generateNameForImportOrExportDeclaration(node); - case 220: - case 221: - case 235: - return generateNameForExportDefault(); - case 192: - return generateNameForClassExpression(); - default: - return makeTempVariableName(0); + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { + if (sourceFile) { + return getDiagnostics(sourceFile, cancellationToken); } + var allDiagnostics = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); + }); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function generateName(name) { - switch (name.autoGenerateKind) { - case 1: - return makeTempVariableName(0); - case 2: - return makeTempVariableName(268435456); - case 3: - return makeUniqueName(name.text); - } - ts.Debug.fail("Unsupported GeneratedIdentifierKind."); + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getNodeForGeneratedName(name) { - var autoGenerateId = name.autoGenerateId; - var node = name; - var original = node.original; - while (original) { - node = original; - if (ts.isIdentifier(node) - && node.autoGenerateKind === 4 - && node.autoGenerateId !== autoGenerateId) { - break; - } - original = node.original; - } - return node; + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - 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))); + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + var options = program.getCompilerOptions(); + if (!sourceFile || options.out || options.outFile) { + return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } else { - var autoGenerateId = name.autoGenerateId; - return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = ts.unescapeIdentifier(generateName(name))); + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function createDelimiterMap() { - var delimiters = []; - delimiters[0] = ""; - delimiters[16] = ","; - delimiters[4] = " |"; - delimiters[8] = " &"; - return delimiters; - } - function getDelimiter(format) { - return delimiters[format & 28]; - } - function createBracketsMap() { - var brackets = []; - brackets[512] = ["{", "}"]; - brackets[1024] = ["(", ")"]; - brackets[2048] = ["<", ">"]; - brackets[4096] = ["[", "]"]; - return brackets; - } - function getOpeningBracket(format) { - return brackets[format & 7680][0]; - } - function getClosingBracket(format) { - return brackets[format & 7680][1]; + function getSyntacticDiagnosticsForFile(sourceFile) { + return sourceFile.parseDiagnostics; } - } - ts.emitFiles = emitFiles; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.version = "2.1.0"; - var emptyArray = []; - function findConfigFile(searchPath, fileExists, configName) { - if (configName === void 0) { configName = "tsconfig.json"; } - while (true) { - var fileName = ts.combinePaths(searchPath, configName); - if (fileExists(fileName)) { - return fileName; + function runWithCancellationToken(func) { + try { + return func(); } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; + catch (e) { + if (e instanceof ts.OperationCanceledException) { + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; } - searchPath = parentPath; } - return undefined; - } - ts.findConfigFile = findConfigFile; - function resolveTripleslashReference(moduleName, containingFile) { - var basePath = ts.getDirectoryPath(containingFile); - var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName); - return ts.normalizePath(referencedFileName); - } - ts.resolveTripleslashReference = resolveTripleslashReference; - function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) { - var commonPathComponents; - var failed = ts.forEach(fileNames, function (sourceFile) { - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory); - sourcePathComponents.pop(); - if (!commonPathComponents) { - commonPathComponents = sourcePathComponents; - return; - } - for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) { - if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) { - if (i === 0) { + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : + typeChecker.getDiagnostics(sourceFile, cancellationToken); + var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); + var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + }); + } + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { + return runWithCancellationToken(function () { + var diagnostics = []; + walk(sourceFile); + return diagnostics; + function walk(node) { + if (!node) { + return false; + } + switch (node.kind) { + case 230: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return true; + case 236: + if (node.isExportEquals) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 222: + var classDeclaration = node; + if (checkModifiers(classDeclaration.modifiers) || + checkTypeParameters(classDeclaration.typeParameters)) { + return true; + } + break; + case 251: + var heritageClause = node; + if (heritageClause.token === 107) { + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 223: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 226: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 224: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return true; + case 148: + case 147: + case 149: + case 150: + case 151: + case 180: + case 221: + case 181: + case 221: + var functionDeclaration = node; + if (checkModifiers(functionDeclaration.modifiers) || + checkTypeParameters(functionDeclaration.typeParameters) || + checkTypeAnnotation(functionDeclaration.type)) { + return true; + } + break; + case 201: + var variableStatement = node; + if (checkModifiers(variableStatement.modifiers)) { + return true; + } + break; + case 219: + var variableDeclaration = node; + if (checkTypeAnnotation(variableDeclaration.type)) { + return true; + } + break; + case 175: + case 176: + var expression = node; + if (expression.typeArguments && expression.typeArguments.length > 0) { + var start = expression.typeArguments.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 143: + var parameter = node; + if (parameter.modifiers) { + var start = parameter.modifiers.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return true; + } + if (parameter.questionToken) { + diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); + return true; + } + if (parameter.type) { + diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return true; + } + break; + case 146: + var propertyDeclaration = node; + if (propertyDeclaration.modifiers) { + for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { + var modifier = _a[_i]; + if (modifier.kind !== 114) { + diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + return true; + } + } + } + if (checkTypeAnnotation(node.type)) { + return true; + } + break; + case 225: + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return true; + case 178: + var typeAssertionExpression = node; + diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return true; + case 144: + if (!options.experimentalDecorators) { + diagnostics.push(ts.createDiagnosticForNode(node, 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)); + } + return true; + } + return ts.forEachChild(node, walk); + } + function checkTypeParameters(typeParameters) { + if (typeParameters) { + var start = typeParameters.pos; + diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return true; + } + return false; + } + function checkTypeAnnotation(type) { + if (type) { + diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return true; } - commonPathComponents.length = i; - break; + return false; + } + function checkModifiers(modifiers) { + if (modifiers) { + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; + switch (modifier.kind) { + case 113: + case 111: + case 112: + case 129: + case 123: + diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + return true; + case 114: + case 83: + case 75: + case 78: + case 116: + } + } + } + return false; } - } - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - }); - if (failed) { - return ""; + }); } - if (!commonPathComponents) { - return currentDirectory; + function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + var writeFile = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + }); } - return ts.getNormalizedPathFromPathComponents(commonPathComponents); - } - ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames; - function createCompilerHost(options, setParentNodes) { - var existingDirectories = ts.createMap(); - function getCanonicalFileName(fileName) { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return ts.isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(fileName, languageVersion, onError) { - var text; - try { - ts.performance.mark("beforeIORead"); - text = ts.sys.readFile(fileName, options.charset); - ts.performance.mark("afterIORead"); - ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); - } - text = ""; - } - return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined; + function getOptionsDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); + ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function directoryExists(directoryPath) { - if (directoryPath in existingDirectories) { - return true; + function getGlobalDiagnostics() { + var allDiagnostics = []; + ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); + return ts.sortAndDeduplicateDiagnostics(allDiagnostics); + } + function hasExtension(fileName) { + return ts.getBaseFileName(fileName).indexOf(".") >= 0; + } + function processRootFile(fileName, isDefaultLib) { + processSourceFile(ts.normalizePath(fileName), isDefaultLib); + } + function fileReferenceIsEqualTo(a, b) { + return a.fileName === b.fileName; + } + function moduleNameIsEqualTo(a, b) { + return a.text === b.text; + } + function getTextOfLiteral(literal) { + return literal.text; + } + function collectExternalModuleReferences(file) { + if (file.imports) { + return; } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; + var isJavaScriptFile = ts.isSourceFileJavaScript(file); + var isExternalModuleFile = ts.isExternalModule(file); + var imports; + var moduleAugmentations; + if (options.importHelpers + && (options.isolatedModules || isExternalModuleFile) + && !file.isDeclarationFile) { + var externalHelpersModuleReference = ts.createNode(9); + externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; + externalHelpersModuleReference.parent = file; + imports = [externalHelpersModuleReference]; } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); + for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { + var node = _a[_i]; + collectModuleReferences(node, false); + if (isJavaScriptFile) { + collectRequireCalls(node); + } } - } - var outputFingerprints; - function writeFileIfUpdated(fileName, data, writeByteOrderMark) { - if (!outputFingerprints) { - outputFingerprints = ts.createMap(); + file.imports = imports || emptyArray; + file.moduleAugmentations = moduleAugmentations || emptyArray; + return; + function collectModuleReferences(node, inAmbientModule) { + switch (node.kind) { + case 231: + case 230: + case 237: + var moduleNameExpr = ts.getExternalModuleName(node); + if (!moduleNameExpr || moduleNameExpr.kind !== 9) { + break; + } + if (!moduleNameExpr.text) { + break; + } + if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { + (imports || (imports = [])).push(moduleNameExpr); + } + break; + case 226: + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { + var moduleName = node.name; + if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { + (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); + } + else if (!inAmbientModule) { + var body = node.body; + if (body) { + for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + collectModuleReferences(statement, true); + } + } + } + } + } } - var hash = ts.sys.createHash(data); - var mtimeBefore = ts.sys.getModifiedTime(fileName); - if (mtimeBefore && fileName in outputFingerprints) { - var fingerprint = outputFingerprints[fileName]; - if (fingerprint.byteOrderMark === writeByteOrderMark && - fingerprint.hash === hash && - fingerprint.mtime.getTime() === mtimeBefore.getTime()) { - return; + function collectRequireCalls(node) { + if (ts.isRequireCall(node, true)) { + (imports || (imports = [])).push(node.arguments[0]); + } + else { + ts.forEachChild(node, collectRequireCalls); } } - ts.sys.writeFile(fileName, data, writeByteOrderMark); - var mtimeAfter = ts.sys.getModifiedTime(fileName); - outputFingerprints[fileName] = { - hash: hash, - byteOrderMark: writeByteOrderMark, - mtime: mtimeAfter - }; } - function writeFile(fileName, data, writeByteOrderMark, onError) { - try { - ts.performance.mark("beforeIOWrite"); - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - if (ts.isWatchSet(options) && ts.sys.createHash && ts.sys.getModifiedTime) { - writeFileIfUpdated(fileName, data, writeByteOrderMark); + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { + var diagnosticArgument; + var diagnostic; + if (hasExtension(fileName)) { + if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { + diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; + diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else { - ts.sys.writeFile(fileName, data, writeByteOrderMark); + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { + diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; + diagnosticArgument = [fileName]; } - ts.performance.mark("afterIOWrite"); - ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); } - catch (e) { - if (onError) { - onError(e.message); + else { + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); + if (!nonTsFile) { + if (options.allowNonTsExtensions) { + diagnostic = ts.Diagnostics.File_0_not_found; + diagnosticArgument = [fileName]; + } + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { + diagnostic = ts.Diagnostics.File_0_not_found; + fileName += ".ts"; + diagnosticArgument = [fileName]; + } } } - } - function getDefaultLibLocation() { - return ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())); - } - var newLine = ts.getNewLineCharacter(options); - var realpath = ts.sys.realpath && (function (path) { return ts.sys.realpath(path); }); - return { - getSourceFile: getSourceFile, - getDefaultLibLocation: getDefaultLibLocation, - getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); }, - writeFile: writeFile, - getCurrentDirectory: ts.memoize(function () { return ts.sys.getCurrentDirectory(); }), - useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return newLine; }, - fileExists: function (fileName) { return ts.sys.fileExists(fileName); }, - readFile: function (fileName) { return ts.sys.readFile(fileName); }, - trace: function (s) { return ts.sys.write(s + newLine); }, - directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); }, - getEnvironmentVariable: function (name) { return ts.sys.getEnvironmentVariable ? ts.sys.getEnvironmentVariable(name) : ""; }, - getDirectories: function (path) { return ts.sys.getDirectories(path); }, - realpath: realpath - }; - } - ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); - if (program.getCompilerOptions().declaration) { - diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); - } - return ts.sortAndDeduplicateDiagnostics(diagnostics); - } - ts.getPreEmitDiagnostics = getPreEmitDiagnostics; - function formatDiagnostics(diagnostics, host) { - var output = ""; - for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) { - var diagnostic = diagnostics_1[_i]; - if (diagnostic.file) { - var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; - var fileName = diagnostic.file.fileName; - var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - output += relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): "; + if (diagnostic) { + if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + } } - var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); } - return output; - } - ts.formatDiagnostics = formatDiagnostics; - function flattenDiagnosticMessageText(messageText, newLine) { - if (typeof messageText === "string") { - return messageText; + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } + else { + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); + } } - else { - var diagnosticChain = messageText; - var result = ""; - var indent = 0; - while (diagnosticChain) { - if (indent) { - result += newLine; - for (var i = 0; i < indent; i++) { - result += " "; + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { + if (filesByName.contains(path)) { + var file_1 = filesByName.get(path); + if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { + reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); + } + if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { + sourceFilesFoundSearchingNodeModules[file_1.path] = false; + if (!options.noResolve) { + processReferencedFiles(file_1, isDefaultLib); + processTypeReferenceDirectives(file_1); } + modulesWithElidedImports[file_1.path] = false; + processImportedModules(file_1); } - result += diagnosticChain.messageText; - indent++; - diagnosticChain = diagnosticChain.next; - } - return result; - } - } - ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText; - function loadWithLocalCache(names, containingFile, loader) { - if (names.length === 0) { - return []; - } - var resolutions = []; - var cache = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_46 = names_2[_i]; - var result = name_46 in cache - ? cache[name_46] - : cache[name_46] = loader(name_46, containingFile); - resolutions.push(result); - } - return resolutions; - } - function createProgram(rootNames, options, host, oldProgram) { - var program; - var files = []; - var commonSourceDirectory; - var diagnosticsProducingTypeChecker; - var noDiagnosticsTypeChecker; - var classifiableNames; - var resolvedTypeReferenceDirectives = ts.createMap(); - var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; - var currentNodeModulesDepth = 0; - var modulesWithElidedImports = ts.createMap(); - var sourceFilesFoundSearchingNodeModules = ts.createMap(); - ts.performance.mark("beforeProgram"); - host = host || createCompilerHost(options); - var skipDefaultLib = options.noLib; - var programDiagnostics = ts.createDiagnosticCollection(); - var currentDirectory = host.getCurrentDirectory(); - var supportedExtensions = ts.getSupportedExtensions(options); - var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); - var resolveModuleNamesWorker; - if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; - } - else { - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; - resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; - } - var resolveTypeReferenceDirectiveNamesWorker; - if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; - } - else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader_2); }; - } - var filesByName = ts.createFileMap(); - var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; - if (!tryReuseStructureFromOldProgram()) { - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); - if (typeReferences.length) { - var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); - for (var i = 0; i < typeReferences.length; i++) { - processTypeReferenceDirective(typeReferences[i], resolutions[i]); + else if (file_1 && modulesWithElidedImports[file_1.path]) { + if (currentNodeModulesDepth < maxNodeModulesJsDepth) { + modulesWithElidedImports[file_1.path] = false; + processImportedModules(file_1); + } } + return file_1; } - if (!skipDefaultLib) { - if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), true); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { + if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { + fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); } else { - var libDirectory_1 = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(host.getDefaultLibFileName(options)); - ts.forEach(options.lib, function (libFileName) { - processRootFile(ts.combinePaths(libDirectory_1, libFileName), true); - }); + fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); + } + }); + filesByName.set(path, file); + if (file) { + sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); + file.path = path; + if (host.useCaseSensitiveFileNames()) { + var existingFile = filesByNameIgnoreCase.get(path); + if (existingFile) { + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + } + else { + filesByNameIgnoreCase.set(path, file); + } + } + skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; + if (!options.noResolve) { + processReferencedFiles(file, isDefaultLib); + processTypeReferenceDirectives(file); + } + processImportedModules(file); + if (isDefaultLib) { + files.unshift(file); + } + else { + files.push(file); } } + return file; } - oldProgram = undefined; - program = { - getRootFileNames: function () { return rootNames; }, - getSourceFile: getSourceFile, - getSourceFileByPath: getSourceFileByPath, - getSourceFiles: function () { return files; }, - getCompilerOptions: function () { return options; }, - getSyntacticDiagnostics: getSyntacticDiagnostics, - getOptionsDiagnostics: getOptionsDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getSemanticDiagnostics: getSemanticDiagnostics, - getDeclarationDiagnostics: getDeclarationDiagnostics, - getTypeChecker: getTypeChecker, - getClassifiableNames: getClassifiableNames, - getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker, - getCommonSourceDirectory: getCommonSourceDirectory, - emit: emit, - getCurrentDirectory: function () { return currentDirectory; }, - getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, - getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, - getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, - getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, - getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, - dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker - }; - verifyCompilerOptions(); - ts.performance.mark("afterProgram"); - ts.performance.measure("Program", "beforeProgram", "afterProgram"); - return program; - function getCommonSourceDirectory() { - if (typeof commonSourceDirectory === "undefined") { - if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) { - commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); + function processReferencedFiles(file, isDefaultLib) { + ts.forEach(file.referencedFiles, function (ref) { + var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + }); + } + function processTypeReferenceDirectives(file) { + var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName); + for (var i = 0; i < typeDirectives.length; i++) { + var ref = file.typeReferenceDirectives[i]; + var resolvedTypeReferenceDirective = resolutions[i]; + var fileName = ref.fileName.toLocaleLowerCase(); + ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + } + } + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; + if (previousResolution && previousResolution.primary) { + return; + } + var saveResolution = true; + if (resolvedTypeReferenceDirective) { + if (resolvedTypeReferenceDirective.primary) { + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } else { - commonSourceDirectory = computeCommonSourceDirectory(files); + if (previousResolution) { + var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); + if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + } + saveResolution = false; + } + else { + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); + } } - if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { - commonSourceDirectory += ts.directorySeparator; + } + else { + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); + } + if (saveResolution) { + resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; + } + } + function createDiagnostic(refFile, refPos, refEnd, message) { + var args = []; + for (var _i = 4; _i < arguments.length; _i++) { + args[_i - 4] = arguments[_i]; + } + if (refFile === undefined || refPos === undefined || refEnd === undefined) { + return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + } + else { + return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + } + } + function getCanonicalFileName(fileName) { + return host.getCanonicalFileName(fileName); + } + function processImportedModules(file) { + collectExternalModuleReferences(file); + if (file.imports.length || file.moduleAugmentations.length) { + file.resolvedModules = ts.createMap(); + var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + for (var i = 0; i < moduleNames.length; i++) { + var resolution = resolutions[i]; + ts.setResolvedModule(file, moduleNames[i], resolution); + var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; + var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); + if (isFromNodeModulesSearch) { + currentNodeModulesDepth++; + } + var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth; + var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; + if (elideImport) { + modulesWithElidedImports[file.path] = true; + } + else if (shouldAddFile) { + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + } + if (isFromNodeModulesSearch) { + currentNodeModulesDepth--; + } } } - return commonSourceDirectory; + else { + file.resolvedModules = undefined; + } + return; } - function getClassifiableNames() { - if (!classifiableNames) { - getTypeChecker(); - classifiableNames = ts.createMap(); - for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { - var sourceFile = files_2[_i]; - ts.copyProperties(sourceFile.classifiableNames, classifiableNames); + function computeCommonSourceDirectory(sourceFiles) { + var fileNames = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var file = sourceFiles_6[_i]; + if (!file.isDeclarationFile) { + fileNames.push(file.fileName); } } - return classifiableNames; + return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName); } - function tryReuseStructureFromOldProgram() { - if (!oldProgram) { - return false; + function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { + var allFilesBelongToPath = true; + if (sourceFiles) { + var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; + if (!ts.isDeclarationFile(sourceFile)) { + var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); + if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); + allFilesBelongToPath = false; + } + } + } } - var oldOptions = oldProgram.getCompilerOptions(); - if ((oldOptions.module !== options.module) || - (oldOptions.moduleResolution !== options.moduleResolution) || - (oldOptions.noResolve !== options.noResolve) || - (oldOptions.target !== options.target) || - (oldOptions.noLib !== options.noLib) || - (oldOptions.jsx !== options.jsx) || - (oldOptions.allowJs !== options.allowJs) || - (oldOptions.rootDir !== options.rootDir) || - (oldOptions.configFilePath !== options.configFilePath) || - (oldOptions.baseUrl !== options.baseUrl) || - (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || - !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || - !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || - !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !ts.equalOwnProperties(oldOptions.paths, options.paths)) { - return false; + return allFilesBelongToPath; + } + function verifyCompilerOptions() { + if (options.isolatedModules) { + if (options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); + } + if (options.noEmitOnError) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); + } + if (options.out) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); + } + if (options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); + } } - ts.Debug.assert(!oldProgram.structureIsReused); - var oldRootNames = oldProgram.getRootFileNames(); - if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return false; + if (options.inlineSourceMap) { + if (options.sourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); + } + if (options.mapRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); + } } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return false; + if (options.paths && options.baseUrl === undefined) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option)); } - var newSourceFiles = []; - var filePaths = []; - var modifiedSourceFiles = []; - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var oldSourceFile = _a[_i]; - var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) - : host.getSourceFile(oldSourceFile.fileName, options.target); - if (!newSourceFile) { - return false; - } - newSourceFile.path = oldSourceFile.path; - filePaths.push(newSourceFile.path); - if (oldSourceFile !== newSourceFile) { - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { - return false; - } - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { - return false; - } - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - return false; - } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { - return false; + if (options.paths) { + for (var key in options.paths) { + if (!ts.hasProperty(options.paths, key)) { + continue; } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - return false; + if (!ts.hasZeroOrOneAsteriskCharacter(key)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); } - var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - return false; + if (ts.isArray(options.paths[key])) { + if (options.paths[key].length === 0) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key)); } - } - if (resolveTypeReferenceDirectiveNamesWorker) { - var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { - return false; + for (var _i = 0, _a = options.paths[key]; _i < _a.length; _i++) { + var subst = _a[_i]; + var typeOfSubst = typeof subst; + if (typeOfSubst === "string") { + if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); + } + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst)); + } } } - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; - modifiedSourceFiles.push(newSourceFile); + else { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key)); + } } - else { - newSourceFile = oldSourceFile; + } + if (!options.sourceMap && !options.inlineSourceMap) { + if (options.inlineSources) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources")); + } + if (options.sourceRoot) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot")); } - newSourceFiles.push(newSourceFile); } - for (var i = 0, len = newSourceFiles.length; i < len; i++) { - filesByName.set(filePaths[i], newSourceFiles[i]); + if (options.out && options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); } - files = newSourceFiles; - fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var modifiedFile = modifiedSourceFiles_1[_b]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + if (options.mapRoot && !options.sourceMap) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); } - resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - oldProgram.structureIsReused = true; - return true; - } - function getEmitHost(writeFileCallback) { - return { - getCanonicalFileName: getCanonicalFileName, - getCommonSourceDirectory: program.getCommonSourceDirectory, - getCompilerOptions: program.getCompilerOptions, - getCurrentDirectory: function () { return currentDirectory; }, - getNewLine: function () { return host.getNewLine(); }, - getSourceFile: program.getSourceFile, - getSourceFileByPath: program.getSourceFileByPath, - getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, - writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked - }; - } - function getDiagnosticsProducingTypeChecker() { - return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); - } - function dropDiagnosticsProducingTypeChecker() { - diagnosticsProducingTypeChecker = undefined; - } - function getTypeChecker() { - return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); - } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); - } - function isEmitBlocked(emitFileName) { - return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); - } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { - var declarationDiagnostics = []; - if (options.noEmit) { - return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; + if (options.declarationDir) { + if (!options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationDir", "declaration")); + } + if (options.out || options.outFile) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile")); + } } - if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); - if (diagnostics.length === 0 && program.getCompilerOptions().declaration) { - declarationDiagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken); + if (options.lib && options.noLib) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); + } + if (options.noImplicitUseStrict && options.alwaysStrict) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); + } + var languageVersion = options.target || 0; + var outFile = options.outFile || options.out; + var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); + if (options.isolatedModules) { + if (options.module === ts.ModuleKind.None && languageVersion < 2) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } - if (diagnostics.length > 0 || declarationDiagnostics.length > 0) { - return { - diagnostics: ts.concatenate(diagnostics, declarationDiagnostics), - sourceMaps: undefined, - emittedFiles: undefined, - emitSkipped: true - }; + var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); + if (firstNonExternalModuleSourceFile) { + var span_7 = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); + programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span_7.start, span_7.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + } + } + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) { + var span_8 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); + programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_8.start, span_8.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); + } + if (outFile) { + if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); + } + else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) { + var span_9 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); + programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_9.start, span_9.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); + } + } + if (options.outDir || + options.sourceRoot || + options.mapRoot) { + var dir = getCommonSourceDirectory(); + if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + } + } + if (!options.noEmit && options.allowJs && options.declaration) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); + } + if (options.emitDecoratorMetadata && + !options.experimentalDecorators) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); + } + if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); + } + if (!options.noEmit && !options.suppressOutputPathCheck) { + var emitHost = getEmitHost(); + var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { + verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); + verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); + }); + } + function verifyEmitFilePath(emitFileName, emitFilesSeen) { + if (emitFileName) { + var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); + if (filesByName.contains(emitFilePath)) { + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + } + if (emitFilesSeen.contains(emitFilePath)) { + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + } + else { + emitFilesSeen.set(emitFilePath, true); + } } } - var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); - ts.performance.mark("afterEmit"); - ts.performance.measure("Emit", "beforeEmit", "afterEmit"); - return emitResult; - } - function getSourceFile(fileName) { - return getSourceFileByPath(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); - } - function getSourceFileByPath(path) { - return filesByName.get(path); - } - function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { - if (sourceFile) { - return getDiagnostics(sourceFile, cancellationToken); + } + function createEmitBlockingDiagnostics(emitFileName, message) { + hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); + programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); + } + } + ts.createProgram = createProgram; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMap({ + "preserve": 1, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + }, + { + name: "reactNamespace", + type: "string", + description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + }, + { + name: "listFiles", + type: "boolean", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMap({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMap({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_in_the_given_directory, + paramType: ts.Diagnostics.DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMap({ + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2, + "es2016": 3, + "es2017": 4, + }), + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, + paramType: ts.Diagnostics.VERSION, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMap({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + } + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true } - var allDiagnostics = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (cancellationToken) { - cancellationToken.throwIfCancellationRequested(); - } - ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); - }); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getSyntacticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); - } - function getSemanticDiagnostics(sourceFile, cancellationToken) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMap({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.ts", + "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", + "es2016.array.include": "lib.es2016.array.include.d.ts", + "es2017.object": "lib.es2017.object.d.ts", + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } - function getDeclarationDiagnostics(sourceFile, cancellationToken) { - var options = program.getCompilerOptions(); - if (!sourceFile || options.out || options.outFile) { - return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); + ]; + ts.typingOptionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" } - else { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { - return sourceFile.parseDiagnostics; + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; } - function runWithCancellationToken(func) { - try { - return func(); - } - catch (e) { - if (e instanceof ts.OperationCanceledException) { - noDiagnosticsTypeChecker = undefined; - diagnosticsProducingTypeChecker = undefined; - } - throw e; + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + var key = trimString((value || "")).toLowerCase(); + var map = opt.type; + if (key in map) { + return map[key]; } - function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : - typeChecker.getDiagnostics(sourceFile, cancellationToken); - var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); - var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); - }); - } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - var diagnostics = []; - walk(sourceFile); - return diagnostics; - function walk(node) { - if (!node) { - return false; - } - switch (node.kind) { - case 229: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 235: - if (node.isExportEquals) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 221: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 251: - var heritageClause = node; - if (heritageClause.token === 106) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 222: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 225: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 223: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 147: - case 146: - case 148: - case 149: - case 150: - case 179: - case 220: - case 180: - case 220: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; - } - break; - case 200: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 218: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 174: - case 175: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 142: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 145: - var propertyDeclaration = node; - if (propertyDeclaration.modifiers) { - for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { - var modifier = _a[_i]; - if (modifier.kind !== 113) { - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - } - } - } - if (checkTypeAnnotation(node.type)) { - return true; - } - break; - case 224: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 177: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; - case 143: - if (!options.experimentalDecorators) { - diagnostics.push(ts.createDiagnosticForNode(node, 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)); - } - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { - var modifier = modifiers_1[_i]; - switch (modifier.kind) { - case 112: - case 110: - case 111: - case 128: - case 122: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - case 113: - case 82: - case 74: - case 77: - case 115: - } - } - } - return false; - } - }); - } - function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { - return runWithCancellationToken(function () { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); - }); - } - function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { - return ts.isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); - } - function getOptionsDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics()); - ts.addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function getGlobalDiagnostics() { - var allDiagnostics = []; - ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); - return ts.sortAndDeduplicateDiagnostics(allDiagnostics); - } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } - function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, true); - } - function fileReferenceIsEqualTo(a, b) { - return a.fileName === b.fileName; - } - function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function getTextOfLiteral(literal) { - return literal.text; + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); } - function collectExternalModuleReferences(file) { - if (file.imports) { - return; - } - var isJavaScriptFile = ts.isSourceFileJavaScript(file); - var isExternalModuleFile = ts.isExternalModule(file); - var imports; - var moduleAugmentations; - if (options.importHelpers - && (options.isolatedModules || isExternalModuleFile) - && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createNode(9); - externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - externalHelpersModuleReference.parent = file; - imports = [externalHelpersModuleReference]; - } - for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { - var node = _a[_i]; - collectModuleReferences(node, false); - if (isJavaScriptFile) { - collectRequireCalls(node); + } + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + } + } + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); } - } - file.imports = imports || emptyArray; - file.moduleAugmentations = moduleAugmentations || emptyArray; - return; - function collectModuleReferences(node, inAmbientModule) { - switch (node.kind) { - case 230: - case 229: - case 236: - var moduleNameExpr = ts.getExternalModuleName(node); - if (!moduleNameExpr || moduleNameExpr.kind !== 9) { - break; - } - if (!moduleNameExpr.text) { - break; - } - if (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text)) { - (imports || (imports = [])).push(moduleNameExpr); + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + if (s in shortOptionNames) { + s = shortOptionNames[s]; + } + if (s in optionNameMap) { + var opt = optionNameMap[s]; + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); } - break; - case 225: - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { - var moduleName = node.name; - if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { - (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); } - else if (!inAmbientModule) { - var body = node.body; - if (body) { - for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - collectModuleReferences(statement, true); + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; } - } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; } } - } - } - function collectRequireCalls(node) { - if (ts.isRequireCall(node, true)) { - (imports || (imports = [])).push(node.arguments[0]); - } - else { - ts.forEachChild(node, collectRequireCalls); - } - } - } - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { - var diagnosticArgument; - var diagnostic; - if (hasExtension(fileName)) { - if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { - diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; - diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; - } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; - } - else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { - diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; - diagnosticArgument = [fileName]; - } - } - else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); - if (!nonTsFile) { - if (options.allowNonTsExtensions) { - diagnostic = ts.Diagnostics.File_0_not_found; - diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { - diagnostic = ts.Diagnostics.File_0_not_found; - fileName += ".ts"; - diagnosticArgument = [fileName]; + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); } } - } - if (diagnostic) { - if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(diagnosticArgument))); - } else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(diagnosticArgument))); + fileNames.push(s); } } } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - } - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { - if (filesByName.contains(path)) { - var file_1 = filesByName.get(path); - if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { - reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); - } - if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { - sourceFilesFoundSearchingNodeModules[file_1.path] = false; - if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); - processTypeReferenceDirectives(file_1); - } - modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); - } - else if (file_1 && modulesWithElidedImports[file_1.path]) { - if (currentNodeModulesDepth < maxNodeModulesJsDepth) { - modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); - } - } - return file_1; + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }); - filesByName.set(path, file); - if (file) { - sourceFilesFoundSearchingNodeModules[path] = (currentNodeModulesDepth > 0); - file.path = path; - if (host.useCaseSensitiveFileNames()) { - var existingFile = filesByNameIgnoreCase.get(path); - if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; } else { - filesByNameIgnoreCase.set(path, file); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); } } - skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); - if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); - processTypeReferenceDirectives(file); - } - processImportedModules(file, basePath); - if (isDefaultLib) { - files.unshift(file); - } else { - files.push(file); + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); } } - return file; + parseStrings(args); } - function processReferencedFiles(file, basePath, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { - var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, true, file, ref.pos, ref.end); - }); + } + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); } - function processTypeReferenceDirectives(file) { - var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName); - for (var i = 0; i < typeDirectives.length; i++) { - var ref = file.typeReferenceDirectives[i]; - var resolvedTypeReferenceDirective = resolutions[i]; - var fileName = ref.fileName.toLocaleLowerCase(); - ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); - } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { - var previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective]; - if (previousResolution && previousResolution.primary) { - return; - } - var saveResolution = true; - if (resolvedTypeReferenceDirective) { - if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); - } - else { - if (previousResolution) { - var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); - if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); - } - saveResolution = false; - } - else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); - } - } - } - else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); - } - if (saveResolution) { - resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective; - } + return parseConfigFileTextToJson(fileName, text); + } + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; } - function createDiagnostic(refFile, refPos, refEnd, message) { - var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; - } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); - } - else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); - } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } - function getCanonicalFileName(fileName) { - return host.getCanonicalFileName(fileName); + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; } - function processImportedModules(file, basePath) { - collectExternalModuleReferences(file); - if (file.imports.length || file.moduleAugmentations.length) { - file.resolvedModules = ts.createMap(); - var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); - for (var i = 0; i < moduleNames.length; i++) { - var resolution = resolutions[i]; - ts.setResolvedModule(file, moduleNames[i], resolution); - var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); - if (isFromNodeModulesSearch) { - currentNodeModulesDepth++; - } - var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth; - var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; - if (elideImport) { - modulesWithElidedImports[file.path] = true; - } - else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); - } - if (isFromNodeModulesSearch) { - currentNodeModulesDepth--; - } - } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); } else { - file.resolvedModules = undefined; + return optionDefinition.type; } - return; } - function computeCommonSourceDirectory(sourceFiles) { - var fileNames = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var file = sourceFiles_6[_i]; - if (!file.isDeclarationFile) { - fileNames.push(file.fileName); + function getNameOfCompilerOptionValue(value, customTypeMap) { + for (var key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; } } - return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName); + return undefined; } - function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { - var allFilesBelongToPath = true; - if (sourceFiles) { - var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; - if (!ts.isDeclarationFile(sourceFile)) { - var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); - if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); - allFilesBelongToPath = false; - } + function serializeCompilerOptions(options) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { + switch (name_44) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name_44] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name_44] = convertedValue; + } + else { + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; } } } - return allFilesBelongToPath; + return result; } - function verifyCompilerOptions() { - if (options.isolatedModules) { - if (options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules")); - } - if (options.noEmitOnError) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules")); - } - if (options.out) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules")); - } - if (options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules")); - } + } + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; } - if (options.inlineSourceMap) { - if (options.sourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap")); - } - if (options.mapRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap")); - } + } + return output; + } + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + var errors = []; + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typingOptions: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; + } + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; } - if (options.paths && options.baseUrl === undefined) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option)); + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } - if (options.paths) { - for (var key in options.paths) { - if (!ts.hasProperty(options.paths, key)) { - continue; - } - if (!ts.hasZeroOrOneAsteriskCharacter(key)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); - } - if (ts.isArray(options.paths[key])) { - if (options.paths[key].length === 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key)); - } - for (var _i = 0, _a = options.paths[key]; _i < _a.length; _i++) { - var subst = _a[_i]; - var typeOfSubst = typeof subst; - if (typeOfSubst === "string") { - if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); - } - } - else { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst)); - } - } - } - else { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key)); - } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); + } + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typingOptions: typingOptions, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; } } - if (!options.sourceMap && !options.inlineSourceMap) { - if (options.inlineSources) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources")); + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); } - if (options.sourceRoot) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot")); + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; + } + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); } } - if (options.out && options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile")); - } - if (options.mapRoot && !options.sourceMap) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap")); - } - if (options.declarationDir) { - if (!options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationDir", "declaration")); + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; } - if (options.out || options.outFile) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile")); + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); } } - if (options.lib && options.noLib) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); - } - if (options.noImplicitUseStrict && options.alwaysStrict) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); - } - var languageVersion = options.target || 0; - var outFile = options.outFile || options.out; - var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); - if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; } - var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); - if (firstNonExternalModuleSourceFile) { - var span_7 = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); - programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span_7.start, span_7.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) { - var span_8 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_8.start, span_8.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); } - if (outFile) { - if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile")); + else { + excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); } - else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) { - var span_9 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); - programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_9.start, span_9.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile")); + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; + } + return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + } + var _b; + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; + } + function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { enableAutoDiscovery: true, include: [], exclude: [] } + : { enableAutoDiscovery: false, include: [], exclude: [] }; + convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); + return options; + } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (id in optionNameMap) { + var opt = optionNameMap[id]; + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + } + } + } + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); + } + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); + } + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } } } - if (options.outDir || - options.sourceRoot || - options.mapRoot) { - var dir = getCommonSourceDirectory(); - if (options.outDir && dir === "" && ts.forEach(files, function (file) { return ts.getRootLength(file.fileName) > 1; })) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + } + } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + if (key in opt.type) { + return opt.type[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + } + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + } + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); + } + if (exclude) { + exclude = validateSpecs(exclude, errors, true); + } + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap[keyMapper(file)] = file; + } + } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { + wildcardFileMap[key] = file; } } - if (!options.noEmit && options.allowJs && options.declaration) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); + } + var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); + var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); + wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; + } + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { + var spec = specs_2[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } - if (options.emitDecoratorMetadata && - !options.experimentalDecorators) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); } - if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); } - if (!options.noEmit && !options.suppressOutputPathCheck) { - var emitHost = getEmitHost(); - var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { - verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); - verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); - }); + else { + validSpecs.push(spec); } - function verifyEmitFilePath(emitFileName, emitFilesSeen) { - if (emitFileName) { - var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); - if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); - } - if (emitFilesSeen.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + } + return validSpecs; + } + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = ts.createMap(); + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var name_45 = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(name_45)) { + continue; + } + var match = wildcardDirectoryPattern.exec(name_45); + if (match) { + var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); + var flags = watchRecursivePattern.test(name_45) ? 1 : 0; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } } - else { - emitFilesSeen.set(emitFilePath, true); + } + } + for (var key in wildcardDirectories) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; } } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { - hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); + return wildcardDirectories; + } + function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + return true; + } } + return false; + } + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + delete wildcardFiles[lowerPriorityPath]; + } + } + function addFileToOutput(output, file) { + output.push(file); + return output; + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); } - ts.createProgram = createProgram; })(ts || (ts = {})); var ts; (function (ts) { @@ -48886,7 +50169,7 @@ var ts; StringScriptSnapshot.prototype.getLength = function () { return this.text.length; }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + StringScriptSnapshot.prototype.getChangeRange = function () { return undefined; }; return StringScriptSnapshot; @@ -48940,6 +50223,22 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(ts.OutputFileType || (ts.OutputFileType = {})); + var OutputFileType = ts.OutputFileType; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(ts.EndOfLineState || (ts.EndOfLineState = {})); + var EndOfLineState = ts.EndOfLineState; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -49027,40 +50326,75 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; })(ts || (ts = {})); var ts; (function (ts) { - ts.scanner = ts.createScanner(2, true); + ts.scanner = ts.createScanner(4, true); ts.emptyArray = []; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; + })(ts.SemanticMeaning || (ts.SemanticMeaning = {})); + var SemanticMeaning = ts.SemanticMeaning; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 142: - case 218: - case 169: + case 143: + case 219: + case 170: + case 146: case 145: - case 144: case 253: case 254: case 255: - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 252: return 1; - case 141: - case 222: + case 142: case 223: - case 159: - return 2; - case 221: case 224: - return 1 | 2; + case 160: + return 2; + case 222: case 225: + return 1 | 2; + case 226: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -49070,12 +50404,12 @@ var ts; else { return 4; } - case 233: case 234: - case 229: - case 230: case 235: + case 230: + case 231: case 236: + case 237: return 1 | 2 | 4; case 256: return 4 | 1; @@ -49084,7 +50418,7 @@ var ts; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 235) { + if (node.parent.kind === 236) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -49105,16 +50439,16 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69); - if (node.parent.kind === 139 && + ts.Debug.assert(node.kind === 70); + if (node.parent.kind === 140 && node.parent.right === node && - node.parent.parent.kind === 229) { + node.parent.parent.kind === 230) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 139) { + while (node.parent.kind === 140) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -49125,27 +50459,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 139) { - while (root.parent && root.parent.kind === 139) { + if (root.parent.kind === 140) { + while (root.parent && root.parent.kind === 140) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 155 && !isLastClause; + return root.parent.kind === 156 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 172) { - while (root.parent && root.parent.kind === 172) { + if (root.parent.kind === 173) { + while (root.parent && root.parent.kind === 173) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 && root.parent.parent.kind === 251) { + if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { var decl = root.parent.parent.parent; - return (decl.kind === 221 && root.parent.parent.token === 106) || - (decl.kind === 222 && root.parent.parent.token === 83); + return (decl.kind === 222 && root.parent.parent.token === 107) || + (decl.kind === 223 && root.parent.parent.token === 84); } return false; } @@ -49153,17 +50487,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 155 || - (node.parent.kind === 194 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 && !ts.isPartOfExpression(node)) || - node.kind === 165; + return node.parent.kind === 156 || + (node.parent.kind === 195 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 && !ts.isPartOfExpression(node)) || + node.kind === 166; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174); + return isCallOrNewExpressionTarget(node, 175); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175); + return isCallOrNewExpressionTarget(node, 176); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -49176,7 +50510,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 214 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -49185,14 +50519,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 69 && - (node.parent.kind === 210 || node.parent.kind === 209) && + return node.kind === 70 && + (node.parent.kind === 211 || node.parent.kind === 210) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 69 && - node.parent.kind === 214 && + return node.kind === 70 && + node.parent.kind === 215 && node.parent.label === node; } function isLabelName(node) { @@ -49200,38 +50534,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 && node.parent.right === node; + return node.parent.kind === 140 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 && node.parent.name === node; + return node && node.parent && node.parent.kind === 173 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 && node.parent.name === node; + return node.parent.kind === 226 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 69 && + return node.kind === 70 && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { + case 146: case 145: - case 144: case 253: case 255: + case 148: case 147: - case 146: - case 149: case 150: - case 225: + case 151: + case 226: return node.parent.name === node; - case 173: + case 174: return node.parent.argumentExpression === node; - case 140: + case 141: return true; } } @@ -49276,16 +50610,16 @@ var ts; } switch (node.kind) { case 256: + case 148: case 147: - case 146: - case 220: - case 179: - case 149: - case 150: case 221: + case 180: + case 150: + case 151: case 222: - case 224: + case 223: case 225: + case 226: return node; } } @@ -49295,42 +50629,42 @@ var ts; switch (node.kind) { case 256: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225: + case 226: return ts.ScriptElementKind.moduleElement; - case 221: - case 192: + case 222: + case 193: return ts.ScriptElementKind.classElement; - case 222: return ts.ScriptElementKind.interfaceElement; - case 223: return ts.ScriptElementKind.typeElement; - case 224: return ts.ScriptElementKind.enumElement; - case 218: + case 223: return ts.ScriptElementKind.interfaceElement; + case 224: return ts.ScriptElementKind.typeElement; + case 225: return ts.ScriptElementKind.enumElement; + case 219: return getKindOfVariableDeclaration(node); - case 169: + case 170: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 181: + case 221: case 180: - case 220: - case 179: return ts.ScriptElementKind.functionElement; - case 149: return ts.ScriptElementKind.memberGetAccessorElement; - case 150: return ts.ScriptElementKind.memberSetAccessorElement; + case 150: return ts.ScriptElementKind.memberGetAccessorElement; + case 151: return ts.ScriptElementKind.memberSetAccessorElement; + case 148: case 147: - case 146: return ts.ScriptElementKind.memberFunctionElement; + case 146: case 145: - case 144: return ts.ScriptElementKind.memberVariableElement; - case 153: return ts.ScriptElementKind.indexSignatureElement; - case 152: return ts.ScriptElementKind.constructSignatureElement; - case 151: return ts.ScriptElementKind.callSignatureElement; - case 148: return ts.ScriptElementKind.constructorImplementationElement; - case 141: return ts.ScriptElementKind.typeParameterElement; + case 154: return ts.ScriptElementKind.indexSignatureElement; + case 153: return ts.ScriptElementKind.constructSignatureElement; + case 152: return ts.ScriptElementKind.callSignatureElement; + case 149: return ts.ScriptElementKind.constructorImplementationElement; + case 142: return ts.ScriptElementKind.typeParameterElement; case 255: return ts.ScriptElementKind.enumMemberElement; - case 142: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229: - case 234: - case 231: - case 238: + case 143: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230: + case 235: case 232: + case 239: + case 233: return ts.ScriptElementKind.alias; case 279: return ts.ScriptElementKind.typeElement; @@ -49347,7 +50681,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 ? node.parent : node; + var searchNode = node.parent.kind === 167 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -49357,10 +50691,10 @@ var ts; ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 97: + case 98: return true; - case 69: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142; + case 70: + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143; default: return false; } @@ -49404,107 +50738,107 @@ var ts; return false; } switch (n.kind) { - case 221: case 222: - case 224: - case 171: - case 167: - case 159: - case 199: - case 226: + case 223: + case 225: + case 172: + case 168: + case 160: + case 200: case 227: - case 233: - case 237: - return nodeEndsWith(n, 16, sourceFile); + case 228: + case 234: + case 238: + return nodeEndsWith(n, 17, sourceFile); case 252: return isCompletedNode(n.block, sourceFile); - case 175: + case 176: if (!n.arguments) { return true; } - case 174: - case 178: - case 164: - return nodeEndsWith(n, 18, sourceFile); - case 156: + case 175: + case 179: + case 165: + return nodeEndsWith(n, 19, sourceFile); case 157: + case 158: return isCompletedNode(n.type, sourceFile); - case 148: case 149: case 150: - case 220: - case 179: - case 147: - case 146: - case 152: case 151: + case 221: case 180: + case 148: + case 147: + case 153: + case 152: + case 181: if (n.body) { return isCompletedNode(n.body, sourceFile); } if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 18, sourceFile); - case 225: + return hasChildOfKind(n, 19, sourceFile); + case 226: return n.body && isCompletedNode(n.body, sourceFile); - case 203: + case 204: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 202: + case 203: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23); - case 170: - case 168: - case 173: - case 140: - case 161: - return nodeEndsWith(n, 20, sourceFile); - case 153: + hasChildOfKind(n, 24); + case 171: + case 169: + case 174: + case 141: + case 162: + return nodeEndsWith(n, 21, sourceFile); + case 154: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 20, sourceFile); + return hasChildOfKind(n, 21, sourceFile); case 249: case 250: return false; - case 206: case 207: case 208: - case 205: + case 209: + case 206: return isCompletedNode(n.statement, sourceFile); - case 204: - var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); + case 205: + var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 18, sourceFile); + return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 158: + case 159: return isCompletedNode(n.exprName, sourceFile); - case 182: - case 181: case 183: - case 190: + case 182: + case 184: case 191: + case 192: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176: + case 177: return isCompletedNode(n.template, sourceFile); - case 189: + case 190: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 197: + case 198: return ts.nodeIsPresent(n.literal); - case 236: - case 230: + case 237: + case 231: return ts.nodeIsPresent(n.moduleSpecifier); - case 185: + case 186: return isCompletedNode(n.operand, sourceFile); - case 187: - return isCompletedNode(n.right, sourceFile); case 188: + return isCompletedNode(n.right, sourceFile); + case 189: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -49518,7 +50852,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 23 && children.length !== 1) { + else if (last.kind === 24 && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -49655,7 +50989,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 244) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -49663,16 +50997,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 244) { + if (isToken(n)) { return n; } var children = n.getChildren(); for (var i = 0, len = children.length; i < len; i++) { var child = children[i]; - if (position < child.end && (nodeHasTokens(child) || child.kind === 244)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 244 && start === child.end); + (child.kind === 10 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -49721,19 +51055,19 @@ var ts; if (!token) { return false; } - if (token.kind === 244) { + if (token.kind === 10) { return true; } - if (token.kind === 25 && token.parent.kind === 244) { + if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 25 && token.parent.kind === 248) { + if (token.kind === 26 && token.parent.kind === 248) { return true; } - if (token && token.kind === 16 && token.parent.kind === 248) { + if (token && token.kind === 17 && token.parent.kind === 248) { return true; } - if (token.kind === 25 && token.parent.kind === 245) { + if (token.kind === 26 && token.parent.kind === 245) { return true; } return false; @@ -49772,9 +51106,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -49824,21 +51158,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 || node.kind === 174) { + if (node.kind === 156 || node.kind === 175) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 221 || node.kind === 222) { + if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 138; + return n.kind >= 0 && n.kind <= 139; } ts.isToken = isToken; function isWord(kind) { - return kind === 69 || ts.isKeyword(kind); + return kind === 70 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -49850,7 +51184,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 - || kind === 10 + || kind === 11 || ts.isTemplateLiteralKind(kind)) { return true; } @@ -49858,7 +51192,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 <= kind && kind <= 68; + return 16 <= kind && kind <= 69; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -49868,9 +51202,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 112: - case 110: + case 113: case 111: + case 112: return true; } return false; @@ -49893,14 +51227,14 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 || - node.kind === 171) { - if (node.parent.kind === 187 && + if (node.kind === 171 || + node.kind === 172) { + if (node.parent.kind === 188 && node.parent.left === node && - node.parent.operatorToken.kind === 56) { + node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 208 && + if (node.parent.kind === 209 && node.parent.initializer === node) { return true; } @@ -49935,7 +51269,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -49988,7 +51322,7 @@ var ts; } } function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3) { @@ -50037,7 +51371,7 @@ var ts; } } ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { + function displayPart(text, kind) { return { text: text, kind: ts.SymbolDisplayPartKind[kind] @@ -50110,7 +51444,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140) { + location.parent.kind === 141) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -50120,7 +51454,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 234 || location.parent.kind === 238) && + (location.parent.kind === 235 || location.parent.kind === 239) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -50225,157 +51559,157 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 200: + case 201: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218: + case 219: + case 146: case 145: - case 144: return spanInVariableDeclaration(node); - case 142: + case 143: return spanInParameterDeclaration(node); - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: - case 148: - case 179: + case 151: + case 149: case 180: + case 181: return spanInFunctionDeclaration(node); - case 199: + case 200: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 226: + case 227: return spanInBlock(node); case 252: return spanInBlock(node.block); - case 202: + case 203: return textSpan(node.expression); - case 211: + case 212: return textSpan(node.getChildAt(0), node.expression); - case 205: + case 206: return textSpanEndingAtNextToken(node, node.expression); - case 204: + case 205: return spanInNode(node.statement); - case 217: + case 218: return textSpan(node.getChildAt(0)); - case 203: + case 204: return textSpanEndingAtNextToken(node, node.expression); - case 214: + case 215: return spanInNode(node.statement); + case 211: case 210: - case 209: return textSpan(node.getChildAt(0), node.label); - case 206: - return spanInForStatement(node); case 207: - return textSpanEndingAtNextToken(node, node.expression); + return spanInForStatement(node); case 208: + return textSpanEndingAtNextToken(node, node.expression); + case 209: return spanInInitializerOfForLike(node); - case 213: + case 214: return textSpanEndingAtNextToken(node, node.expression); case 249: case 250: return spanInNode(node.statements[0]); - case 216: + case 217: return spanInBlock(node.tryBlock); - case 215: + case 216: return textSpan(node, node.expression); - case 235: + case 236: return textSpan(node, node.expression); - case 229: - return textSpan(node, node.moduleReference); case 230: + return textSpan(node, node.moduleReference); + case 231: return textSpan(node, node.moduleSpecifier); - case 236: + case 237: return textSpan(node, node.moduleSpecifier); - case 225: + case 226: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 221: - case 224: + case 222: + case 225: case 255: - case 169: + case 170: return textSpan(node); - case 212: + case 213: return spanInNode(node.statement); - case 143: + case 144: return spanInNodeArray(node.parent.decorators); - case 167: case 168: + case 169: return spanInBindingPattern(node); - case 222: case 223: + case 224: return undefined; - case 23: + case 24: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24: + case 25: return spanInPreviousNode(node); - case 15: - return spanInOpenBraceToken(node); case 16: + return spanInOpenBraceToken(node); + case 17: return spanInCloseBraceToken(node); - case 20: + case 21: return spanInCloseBracketToken(node); - case 17: - return spanInOpenParenToken(node); case 18: + return spanInOpenParenToken(node); + case 19: return spanInCloseParenToken(node); - case 54: + case 55: return spanInColonToken(node); - case 27: - case 25: + case 28: + case 26: return spanInGreaterThanOrLessThanToken(node); - case 104: + case 105: return spanInWhileKeyword(node); - case 80: - case 72: - case 85: + case 81: + case 73: + case 86: return spanInNextNode(node); - case 138: + case 139: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } - if ((node.kind === 69 || - node.kind == 191 || + if ((node.kind === 70 || + node.kind == 192 || node.kind === 253 || node.kind === 254) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 187) { + if (node.kind === 188) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 56 && + if (binaryExpression.operatorToken.kind === 57 && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { return textSpan(node); } - if (binaryExpression.operatorToken.kind === 24) { + if (binaryExpression.operatorToken.kind === 25) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 204: + case 205: return spanInPreviousNode(node); - case 143: + case 144: return spanInNode(node.parent); - case 206: - case 208: + case 207: + case 209: return textSpan(node); - case 187: - if (node.parent.operatorToken.kind === 24) { + case 188: + if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 180: + case 181: if (node.parent.body === node) { return textSpan(node); } @@ -50387,14 +51721,14 @@ var ts; !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 177 && node.parent.type === node) { + if (node.parent.kind === 178 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 218 || - node.parent.kind === 142)) { + if ((node.parent.kind === 219 || + node.parent.kind === 143)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -50402,7 +51736,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 187) { + if (node.parent.kind === 188) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -50423,7 +51757,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 207) { + if (variableDeclaration.parent.parent.kind === 208) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -50431,7 +51765,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 208) { + variableDeclaration.parent.parent.kind === 209) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -50463,7 +51797,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 221 && functionDeclaration.kind !== 148); + (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -50483,22 +51817,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 225: + case 226: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 205: - case 203: - case 207: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 206: + case 204: case 208: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 207: + case 209: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 219) { + if (forLikeStatement.initializer.kind === 220) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -50520,62 +51854,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 169) { + if (bindingPattern.parent.kind === 170) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 && node.kind !== 167); - var elements = node.kind === 170 ? + ts.Debug.assert(node.kind !== 169 && node.kind !== 168); + var elements = node.kind === 171 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 187 ? node.parent : node); + return textSpan(node.parent.kind === 188 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 224: + case 225: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221: + case 222: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227: + case 228: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 226: + case 227: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 224: - case 221: + case 225: + case 222: return textSpan(node); - case 199: + case 200: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } case 252: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227: + case 228: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 167: + case 168: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -50588,7 +51922,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 168: + case 169: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -50600,33 +51934,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 204 || - node.parent.kind === 174 || - node.parent.kind === 175) { + if (node.parent.kind === 205 || + node.parent.kind === 175 || + node.parent.kind === 176) { return spanInPreviousNode(node); } - if (node.parent.kind === 178) { + if (node.parent.kind === 179) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 179: - case 220: case 180: + case 221: + case 181: + case 148: case 147: - case 146: - case 149: case 150: - case 148: - case 205: - case 204: + case 151: + case 149: case 206: - case 208: - case 174: + case 205: + case 207: + case 209: case 175: - case 178: + case 176: + case 179: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -50635,25 +51969,25 @@ var ts; function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || node.parent.kind === 253 || - node.parent.kind === 142) { + node.parent.kind === 143) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177) { + if (node.parent.kind === 178) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 204) { + if (node.parent.kind === 205) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 208) { + if (node.parent.kind === 209) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -50666,27 +52000,27 @@ var ts; var ts; (function (ts) { function createClassifier() { - var scanner = ts.createScanner(2, false); + var scanner = ts.createScanner(4, false); var noRegexTable = []; - noRegexTable[69] = true; + noRegexTable[70] = true; noRegexTable[9] = true; noRegexTable[8] = true; - noRegexTable[10] = true; - noRegexTable[97] = true; - noRegexTable[41] = true; + noRegexTable[11] = true; + noRegexTable[98] = true; noRegexTable[42] = true; - noRegexTable[18] = true; - noRegexTable[20] = true; - noRegexTable[16] = true; - noRegexTable[99] = true; - noRegexTable[84] = true; + noRegexTable[43] = true; + noRegexTable[19] = true; + noRegexTable[21] = true; + noRegexTable[17] = true; + noRegexTable[100] = true; + noRegexTable[85] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 123 || - keyword2 === 131 || - keyword2 === 121 || - keyword2 === 113) { + if (keyword2 === 124 || + keyword2 === 132 || + keyword2 === 122 || + keyword2 === 114) { return true; } return false; @@ -50769,7 +52103,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(12); + templateStack.push(13); break; } scanner.setText(text); @@ -50781,55 +52115,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10) { - token = 10; + if ((token === 40 || token === 62) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11) { + token = 11; } } - else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 69; + else if (lastNonTriviaToken === 22 && isKeyword(token)) { + token = 70; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 69; + token = 70; } - else if (lastNonTriviaToken === 69 && - token === 25) { + else if (lastNonTriviaToken === 70 && + token === 26) { angleBracketStack++; } - else if (token === 27 && angleBracketStack > 0) { + else if (token === 28 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 117 || - token === 132 || - token === 130 || - token === 120 || - token === 133) { + else if (token === 118 || + token === 133 || + token === 131 || + token === 121 || + token === 134) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 69; + token = 70; } } - else if (token === 12) { + else if (token === 13) { templateStack.push(token); } - else if (token === 15) { + else if (token === 16) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 16) { + else if (token === 17) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12) { + if (lastTemplateStackToken === 13) { token = scanner.reScanTemplateToken(); - if (token === 14) { + if (token === 15) { templateStack.pop(); } else { - ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 14, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 16, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -50867,10 +52201,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 14) { + if (token === 15) { result.endOfLineState = 5; } - else if (token === 11) { + else if (token === 12) { result.endOfLineState = 4; } else { @@ -50878,7 +52212,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13) { result.endOfLineState = 6; } } @@ -50902,43 +52236,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 37: - case 39: + case 38: case 40: - case 35: + case 41: case 36: - case 43: + case 37: case 44: case 45: - case 25: - case 27: + case 46: + case 26: case 28: case 29: - case 91: - case 90: - case 116: case 30: + case 92: + case 91: + case 117: case 31: case 32: case 33: - case 46: - case 48: + case 34: case 47: - case 51: + case 49: + case 48: case 52: - case 67: - case 66: + case 53: case 68: - case 63: + case 67: + case 69: case 64: case 65: - case 57: + case 66: case 58: case 59: - case 61: + case 60: case 62: - case 56: - case 24: + case 63: + case 57: + case 25: return true; default: return false; @@ -50946,19 +52280,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 41: case 42: + case 43: return true; default: return false; } } function isKeyword(token) { - return token >= 70 && token <= 138; + return token >= 71 && token <= 139; } function classFromKind(token) { if (isKeyword(token)) { @@ -50967,7 +52301,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 15 && token <= 68) { + else if (token >= 16 && token <= 69) { return 10; } switch (token) { @@ -50975,7 +52309,7 @@ var ts; return 4; case 9: return 6; - case 10: + case 11: return 7; case 7: case 3: @@ -50984,7 +52318,7 @@ var ts; case 5: case 4: return 8; - case 69: + case 70: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -51004,10 +52338,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } @@ -51051,7 +52385,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 && + return declaration.kind === 226 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -51060,7 +52394,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 && !ts.nodeIsMissing(node)) { + if (kind === 70 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -51123,8 +52457,8 @@ var ts; function getEncodedSyntacticClassifications(cancellationToken, sourceFile, span) { var spanStart = span.start; var spanLength = span.length; - var triviaScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 }; @@ -51266,10 +52600,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 10 && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 244 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 10 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -51282,7 +52616,7 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 243: + case 244: if (token.parent.tagName === token) { return 19; } @@ -51292,7 +52626,7 @@ var ts; return 20; } break; - case 242: + case 243: if (token.parent.tagName === token) { return 21; } @@ -51309,25 +52643,25 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 25 || tokenKind === 27) { + if (tokenKind === 26 || tokenKind === 28) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 56) { - if (token.parent.kind === 218 || - token.parent.kind === 145 || - token.parent.kind === 142 || + if (tokenKind === 57) { + if (token.parent.kind === 219 || + token.parent.kind === 146 || + token.parent.kind === 143 || token.parent.kind === 246) { return 5; } } - if (token.parent.kind === 187 || - token.parent.kind === 185 || + if (token.parent.kind === 188 || token.parent.kind === 186 || - token.parent.kind === 188) { + token.parent.kind === 187 || + token.parent.kind === 189) { return 5; } } @@ -51339,44 +52673,44 @@ var ts; else if (tokenKind === 9) { return token.parent.kind === 246 ? 24 : 6; } - else if (tokenKind === 10) { + else if (tokenKind === 11) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 244) { + else if (tokenKind === 10) { return 23; } - else if (tokenKind === 69) { + else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 221: + case 222: if (token.parent.name === token) { return 11; } return; - case 141: + case 142: if (token.parent.name === token) { return 15; } return; - case 222: + case 223: if (token.parent.name === token) { return 13; } return; - case 224: + case 225: if (token.parent.name === token) { return 12; } return; - case 225: + case 226: if (token.parent.name === token) { return 14; } return; - case 142: + case 143: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -51437,7 +52771,7 @@ var ts; name: tagName.text, kind: undefined, kindModifiers: undefined, - sortText: "0" + sortText: "0", }); } else { @@ -51453,13 +52787,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_47 in nameTable) { - if (nameTable[name_47] === position) { + for (var name_46 in nameTable) { + if (nameTable[name_46] === position) { continue; } - if (!uniqueNames[name_47]) { - uniqueNames[name_47] = name_47; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), 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, @@ -51482,7 +52816,7 @@ var ts; name: displayName, kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" + sortText: "0", }; } function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { @@ -51510,20 +52844,20 @@ var ts; return undefined; } if (node.parent.kind === 253 && - node.parent.parent.kind === 171 && + node.parent.parent.kind === 172 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 230 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 231 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } return getStringLiteralCompletionEntriesFromContextualType(node); } @@ -51538,7 +52872,7 @@ var ts; } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { var candidates = []; var entries = []; typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); @@ -51848,7 +53182,7 @@ var ts; if (typeRoots) { for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -51856,12 +53190,12 @@ var ts; for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { var packageJson = _d[_c]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { + function getCompletionEntriesFromDirectories(host, directory, span, result) { if (host.getDirectories && tryDirectoryExists(host, directory)) { var directories = tryGetDirectories(host, directory); if (directories) { @@ -52055,12 +53389,12 @@ var ts; return undefined; } var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21) { - if (parent_17.kind === 172) { + if (kind === 22) { + if (parent_17.kind === 173) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139) { + else if (parent_17.kind === 140) { node = contextToken.parent.left; isRightOfDot = true; } @@ -52069,11 +53403,11 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (kind === 25) { + if (kind === 26) { isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 && contextToken.parent.kind === 245) { + else if (kind === 40 && contextToken.parent.kind === 245) { isStartingCloseTag = true; location = contextToken; } @@ -52111,7 +53445,6 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; @@ -52119,7 +53452,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 || node.kind === 139 || node.kind === 172) { + if (node.kind === 70 || node.kind === 140 || node.kind === 173) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -52165,9 +53498,8 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 242) || (jsxContainer.kind === 243)) { + if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -52185,6 +53517,13 @@ var ts; previousToken.getStart() : position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 || + scopeNode.kind === 190 || + scopeNode.kind === 248 || + ts.isStatement(scopeNode); + } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); return true; @@ -52206,15 +53545,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 244) { + if (contextToken.kind === 10) { return true; } - if (contextToken.kind === 27 && contextToken.parent) { - if (contextToken.parent.kind === 243) { + if (contextToken.kind === 28 && contextToken.parent) { + if (contextToken.parent.kind === 244) { return true; } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 242) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241; + if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242; } } return false; @@ -52223,41 +53562,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 24: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 170 - || containingNodeKind === 187 - || containingNodeKind === 156; - case 17: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 178 - || containingNodeKind === 164; - case 19: - return containingNodeKind === 170 - || containingNodeKind === 153 - || containingNodeKind === 140; - case 125: + case 25: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 171 + || containingNodeKind === 188 + || containingNodeKind === 157; + case 18: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 179 + || containingNodeKind === 165; + case 20: + return containingNodeKind === 171 + || containingNodeKind === 154 + || containingNodeKind === 141; case 126: + case 127: return true; - case 21: - return containingNodeKind === 225; - case 15: - return containingNodeKind === 221; - case 56: - return containingNodeKind === 218 - || containingNodeKind === 187; - case 12: - return containingNodeKind === 189; + case 22: + return containingNodeKind === 226; + case 16: + return containingNodeKind === 222; + case 57: + return containingNodeKind === 219 + || containingNodeKind === 188; case 13: - return containingNodeKind === 197; - case 112: - case 110: + return containingNodeKind === 190; + case 14: + return containingNodeKind === 198; + case 113: case 111: - return containingNodeKind === 145; + case 112: + return containingNodeKind === 146; } switch (previousToken.getText()) { case "public": @@ -52270,7 +53609,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 - || contextToken.kind === 10 + || contextToken.kind === 11 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -52279,7 +53618,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 10; + || contextToken.kind === 11; } } return false; @@ -52288,22 +53627,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 171) { + if (objectLikeContainer.kind === 172) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 167) { + else if (objectLikeContainer.kind === 168) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142) { + if (!canGetType && rootDeclaration.kind === 143) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 147 || rootDeclaration.parent.kind === 150) { + else if (rootDeclaration.parent.kind === 148 || rootDeclaration.parent.kind === 151) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -52329,9 +53668,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 ? - 230 : - 236; + var declarationKind = namedImportsOrExports.kind === 234 ? + 231 : + 237; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -52350,10 +53689,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15: - case 24: + case 16: + case 25: var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 || parent_18.kind === 167)) { + if (parent_18 && (parent_18.kind === 172 || parent_18.kind === 168)) { return parent_18; } break; @@ -52364,11 +53703,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15: - case 24: + case 16: + case 25: switch (contextToken.parent.kind) { - case 233: - case 237: + case 234: + case 238: return contextToken.parent; } } @@ -52379,12 +53718,12 @@ var ts; if (contextToken) { var parent_19 = contextToken.parent; switch (contextToken.kind) { - case 26: - case 39: - case 69: + case 27: + case 40: + case 70: case 246: case 247: - if (parent_19 && (parent_19.kind === 242 || parent_19.kind === 243)) { + if (parent_19 && (parent_19.kind === 243 || parent_19.kind === 244)) { return parent_19; } else if (parent_19.kind === 246) { @@ -52396,7 +53735,7 @@ var ts; return parent_19.parent; } break; - case 16: + case 17: if (parent_19 && parent_19.kind === 248 && parent_19.parent && @@ -52413,16 +53752,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 179: case 180: - case 220: + case 181: + case 221: + case 148: case 147: - case 146: - case 149: case 150: case 151: case 152: case 153: + case 154: return true; } return false; @@ -52430,67 +53769,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 24: - return containingNodeKind === 218 || - containingNodeKind === 219 || - containingNodeKind === 200 || - containingNodeKind === 224 || + case 25: + return containingNodeKind === 219 || + containingNodeKind === 220 || + containingNodeKind === 201 || + containingNodeKind === 225 || isFunction(containingNodeKind) || - containingNodeKind === 221 || - containingNodeKind === 192 || containingNodeKind === 222 || - containingNodeKind === 168 || - containingNodeKind === 223; - case 21: - return containingNodeKind === 168; - case 54: + containingNodeKind === 193 || + containingNodeKind === 223 || + containingNodeKind === 169 || + containingNodeKind === 224; + case 22: + return containingNodeKind === 169; + case 55: + return containingNodeKind === 170; + case 20: return containingNodeKind === 169; - case 19: - return containingNodeKind === 168; - case 17: + case 18: return containingNodeKind === 252 || isFunction(containingNodeKind); - case 15: - return containingNodeKind === 224 || - containingNodeKind === 222 || - containingNodeKind === 159; - case 23: - return containingNodeKind === 144 && + case 16: + return containingNodeKind === 225 || + containingNodeKind === 223 || + containingNodeKind === 160; + case 24: + return containingNodeKind === 145 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 || - contextToken.parent.parent.kind === 159); - case 25: - return containingNodeKind === 221 || - containingNodeKind === 192 || - containingNodeKind === 222 || + (contextToken.parent.parent.kind === 223 || + contextToken.parent.parent.kind === 160); + case 26: + return containingNodeKind === 222 || + containingNodeKind === 193 || containingNodeKind === 223 || + containingNodeKind === 224 || isFunction(containingNodeKind); - case 113: - return containingNodeKind === 145; - case 22: - return containingNodeKind === 142 || + case 114: + return containingNodeKind === 146; + case 23: + return containingNodeKind === 143 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168); - case 112: - case 110: + contextToken.parent.parent.kind === 169); + case 113: case 111: - return containingNodeKind === 142; - case 116: - return containingNodeKind === 234 || - containingNodeKind === 238 || - containingNodeKind === 232; - case 73: - case 81: - case 107: - case 87: - case 102: - case 123: - case 131: - case 89: - case 108: + case 112: + return containingNodeKind === 143; + case 117: + return containingNodeKind === 235 || + containingNodeKind === 239 || + containingNodeKind === 233; case 74: - case 114: - case 134: + case 82: + case 108: + case 88: + case 103: + case 124: + case 132: + case 90: + case 109: + case 75: + case 115: + case 135: return true; } switch (contextToken.getText()) { @@ -52527,8 +53866,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_48 = element.propertyName || element.name; - existingImportsOrExports[name_48.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"; }); @@ -52544,16 +53883,16 @@ var ts; var m = existingMembers_1[_i]; if (m.kind !== 253 && m.kind !== 254 && - m.kind !== 169 && - m.kind !== 147) { + m.kind !== 170 && + m.kind !== 148) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 169 && m.propertyName) { - if (m.propertyName.kind === 69) { + if (m.kind === 170 && m.propertyName) { + if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } } @@ -52604,7 +53943,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 70; i <= 138; i++) { + for (var i = 71; i <= 139; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -52666,10 +54005,10 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 69 || - node.kind === 97 || - node.kind === 165 || - node.kind === 95 || + if (node.kind === 70 || + node.kind === 98 || + node.kind === 166 || + node.kind === 96 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, false, false, false); @@ -52718,77 +54057,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 88: - case 80: - if (hasKind(node.parent, 203)) { + case 89: + case 81: + if (hasKind(node.parent, 204)) { return getIfElseOccurrences(node.parent); } break; - case 94: - if (hasKind(node.parent, 211)) { + case 95: + if (hasKind(node.parent, 212)) { return getReturnOccurrences(node.parent); } break; - case 98: - if (hasKind(node.parent, 215)) { + case 99: + if (hasKind(node.parent, 216)) { return getThrowOccurrences(node.parent); } break; - case 72: - if (hasKind(parent(parent(node)), 216)) { + case 73: + if (hasKind(parent(parent(node)), 217)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 100: - case 85: - if (hasKind(parent(node), 216)) { + case 101: + case 86: + if (hasKind(parent(node), 217)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 96: - if (hasKind(node.parent, 213)) { + case 97: + if (hasKind(node.parent, 214)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 71: - case 77: - if (hasKind(parent(parent(parent(node))), 213)) { + case 72: + case 78: + if (hasKind(parent(parent(parent(node))), 214)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 70: - case 75: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { + case 71: + case 76: + if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 86: - if (hasKind(node.parent, 206) || - hasKind(node.parent, 207) || - hasKind(node.parent, 208)) { + case 87: + if (hasKind(node.parent, 207) || + hasKind(node.parent, 208) || + hasKind(node.parent, 209)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 104: - case 79: - if (hasKind(node.parent, 205) || hasKind(node.parent, 204)) { + case 105: + case 80: + if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 121: - if (hasKind(node.parent, 148)) { + case 122: + if (hasKind(node.parent, 149)) { return getConstructorOccurrences(node.parent); } break; - case 123: - case 131: - if (hasKind(node.parent, 149) || hasKind(node.parent, 150)) { + case 124: + case 132: + if (hasKind(node.parent, 150) || hasKind(node.parent, 151)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 201)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -52800,10 +54139,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215) { + if (node.kind === 216) { statementAccumulator.push(node); } - else if (node.kind === 216) { + else if (node.kind === 217) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -52827,7 +54166,7 @@ var ts; if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { return parent_20; } - if (parent_20.kind === 216) { + if (parent_20.kind === 217) { var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -52842,7 +54181,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 || node.kind === 209) { + if (node.kind === 211 || node.kind === 210) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -52857,15 +54196,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 213: - if (statement.kind === 209) { + case 214: + if (statement.kind === 210) { continue; } - case 206: case 207: case 208: + case 209: + case 206: case 205: - case 204: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -52882,24 +54221,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 221 || - container.kind === 192 || - (declaration.kind === 142 && hasKind(container, 148)))) { + if (!(container.kind === 222 || + container.kind === 193 || + (declaration.kind === 143 && hasKind(container, 149)))) { return undefined; } } - else if (modifier === 113) { - if (!(container.kind === 221 || container.kind === 192)) { + else if (modifier === 114) { + if (!(container.kind === 222 || container.kind === 193)) { return undefined; } } - else if (modifier === 82 || modifier === 122) { - if (!(container.kind === 226 || container.kind === 256)) { + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 227 || container.kind === 256)) { return undefined; } } - else if (modifier === 115) { - if (!(container.kind === 221 || declaration.kind === 221)) { + else if (modifier === 116) { + if (!(container.kind === 222 || declaration.kind === 222)) { return undefined; } } @@ -52910,7 +54249,7 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 226: + case 227: case 256: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); @@ -52919,15 +54258,15 @@ var ts; nodes = container.statements; } break; - case 148: + case 149: nodes = container.parameters.concat(container.parent.members); break; - case 221: - case 192: + case 222: + case 193: nodes = container.members; if (modifierFlag & 28) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 && member; + return member.kind === 149 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -52948,19 +54287,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 112: + case 113: return 4; - case 110: - return 8; case 111: + return 8; + case 112: return 16; - case 113: + case 114: return 32; - case 82: + case 83: return 1; - case 122: + case 123: return 2; - case 115: + case 116: return 128; default: ts.Debug.fail(); @@ -52980,13 +54319,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149); tryPushAccessorKeyword(accessorDeclaration.symbol, 150); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123, 131); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 132); }); } } } @@ -52995,18 +54334,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121); + return pushKeywordIf(keywords, token, 122); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { - if (loopNode.kind === 204) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 205) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104)) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { break; } } @@ -53015,7 +54354,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -53024,13 +54363,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 206: case 207: case 208: - case 204: + case 209: case 205: + case 206: return getLoopBreakContinueOccurrences(owner); - case 213: + case 214: return getSwitchCaseDefaultOccurrences(owner); } } @@ -53038,13 +54377,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70); + pushKeywordIf(keywords, statement.getFirstToken(), 71); } }); }); @@ -53052,13 +54391,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); } return ts.map(keywords, getHighlightSpanForNode); } @@ -53069,50 +54408,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 199))) { + if (!(func && hasKind(func.body, 200))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 203) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88); + pushKeywordIf(keywords, children[0], 89); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80)) { + if (pushKeywordIf(keywords, children[i], 81)) { break; } } - if (!hasKind(ifStatement.elseStatement, 203)) { + if (!hasKind(ifStatement.elseStatement, 204)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 80 && i < keywords.length - 1) { + if (keywords[i].kind === 81 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -53140,7 +54479,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 215; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -53265,9 +54604,9 @@ var ts; if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { break; } - case 69: - case 97: - case 121: + case 70: + case 98: + case 122: case 9: return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); } @@ -53288,7 +54627,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 95) { + if (node.kind === 96) { return getReferencesForSuperKeyword(node); } } @@ -53313,7 +54652,7 @@ var ts; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - var internedName = getInternedName(symbol, node, declarations); + var internedName = getInternedName(symbol, node); for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; cancellationToken.throwIfCancellationRequested(); @@ -53344,16 +54683,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 231); + var defaultImport = ts.getDeclarationOfKind(symbol, 232); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 || - declaration.kind === 238) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 || + declaration.kind === 239) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 234 ? + return importOrExportSpecifier.kind === 235 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -53368,20 +54707,20 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); + var bindingElement = ts.getDeclarationOfKind(symbol, 170); return bindingElement && - bindingElement.parent.kind === 167 && + bindingElement.parent.kind === 168 && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); + var bindingElement = ts.getDeclarationOfKind(symbol, 170); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } return undefined; } - function getInternedName(symbol, location, declarations) { + function getInternedName(symbol, location) { if (ts.isImportOrExportSpecifierName(location)) { return location.getText(); } @@ -53391,13 +54730,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 179 || valueDeclaration.kind === 192)) { + if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { return valueDeclaration; } 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, 221); + return ts.getAncestor(privateDeclaration, 222); } } if (symbol.flags & 8388608) { @@ -53443,8 +54782,8 @@ var ts; if (position > end) break; var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4))) { positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -53481,7 +54820,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 69: + case 70: return node.getWidth() === searchSymbolName.length; case 9: if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -53531,14 +54870,14 @@ var ts; if (referenceSymbol) { var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 121, parents, inheritsFromCache); + var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); if (relatedSymbol) { addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - else if (searchLocation.kind === 121) { + else if (searchLocation.kind === 122) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); } } @@ -53588,17 +54927,17 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); + ts.Debug.assert(decl.kind === 149); var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121); + ts.Debug.assert(ctrKeyword.kind === 122); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 147) { + if (decl && decl.kind === 148) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97, function (thisKeyword) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -53617,10 +54956,10 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); + ts.Debug.assert(decl.kind === 149); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 95, function (node) { + forEachDescendantOfKind(body, 96, function (node) { if (ts.isCallExpressionTarget(node)) { result.push(node); } @@ -53657,7 +54996,7 @@ var ts; if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { result.push(getReferenceEntryFromNode(refNode.parent)); } - else if (refNode.kind === 69) { + else if (refNode.kind === 70) { if (refNode.parent.kind === 254) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -53673,7 +55012,7 @@ var ts; maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); } else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199) { + if (parent_21.body.kind === 200) { ts.forEachReturnStatement(parent_21.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); @@ -53720,26 +55059,26 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 194 + if (node.kind === 195 && node.parent.kind === 251 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 69 || node.kind === 172) { + else if (node.kind === 70 || node.kind === 173) { return getContainingClassIfInHeritageClause(node.parent); } } return undefined; } function isImplementationExpression(node) { - if (node.kind === 178) { + if (node.kind === 179) { return isImplementationExpression(node.expression); } - return node.kind === 180 || - node.kind === 179 || - node.kind === 171 || - node.kind === 192 || - node.kind === 170; + return node.kind === 181 || + node.kind === 180 || + node.kind === 172 || + node.kind === 193 || + node.kind === 171; } function explicitlyInheritsFrom(child, parent, cachedResults) { var parentIsInterface = parent.getFlags() & 64; @@ -53768,7 +55107,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 222) { + else if (declaration.kind === 223) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -53795,13 +55134,13 @@ var ts; } var staticFlag = 32; switch (searchSpaceNode.kind) { - case 145: - case 144: - case 147: case 146: + case 145: case 148: + case 147: case 149: case 150: + case 151: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -53814,7 +55153,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { + if (!node || node.kind !== 96) { return; } var container = ts.getSuperContainer(node, false); @@ -53829,16 +55168,16 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 32; switch (searchSpaceNode.kind) { + case 148: case 147: - case 146: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 146: case 145: - case 144: - case 148: case 149: case 150: + case 151: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -53846,8 +55185,8 @@ var ts; if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 220: - case 179: + case 221: + case 180: break; default: return undefined; @@ -53888,20 +55227,20 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 179: - case 220: + case 180: + case 221: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 148: case 147: - case 146: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 192: - case 221: + case 193: + case 222: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } @@ -53975,7 +55314,7 @@ var ts; result.push(shorthandValueSymbol); } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 142 && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -54006,7 +55345,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 222) { + else if (declaration.kind === 223) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -54069,7 +55408,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -54138,7 +55477,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 218) { + else if (node.kind === 219) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -54148,18 +55487,18 @@ var ts; } else { switch (node.kind) { - case 221: - case 192: - case 224: + case 222: + case 193: case 225: + case 226: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200) { - ts.Debug.assert(node.parent.kind === 219); + if (node.parent && node.parent.parent && node.parent.parent.kind === 201) { + ts.Debug.assert(node.parent.kind === 220); return node.parent.parent; } } @@ -54192,17 +55531,17 @@ var ts; } FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; function isWriteAccess(node) { - if (node.kind === 69 && ts.isDeclarationName(node)) { + if (node.kind === 70 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 186 || parent.kind === 185) { + if (parent.kind === 187 || parent.kind === 186) { return true; } - else if (parent.kind === 187 && parent.left === node) { + else if (parent.kind === 188 && parent.left === node) { var operator = parent.operatorToken.kind; - return 56 <= operator && operator <= 68; + return 57 <= operator && operator <= 69; } } return false; @@ -54219,10 +55558,10 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 140) { + if (node.parent.kind === 141) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } - case 69: + case 70: return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -54231,9 +55570,9 @@ var ts; switch (node.kind) { case 253: case 254: - case 147: - case 149: + case 148: case 150: + case 151: return true; } return false; @@ -54290,9 +55629,9 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 69 && + if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 234 && declaration.parent && declaration.parent.kind === 233))) { + (declaration.kind === 235 && declaration.parent && declaration.parent.kind === 234))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -54350,7 +55689,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (ts.isNewExpressionTarget(location) || location.kind === 121) { + if (ts.isNewExpressionTarget(location) || location.kind === 122) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -54373,8 +55712,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 148) || - (!selectConstructors && (d.kind === 220 || d.kind === 147 || d.kind === 146))) { + if ((selectConstructors && d.kind === 149) || + (!selectConstructors && (d.kind === 221 || d.kind === 148 || d.kind === 147))) { declarations.push(d); if (d.body) definition = d; @@ -54455,7 +55794,7 @@ var ts; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; } - else if (node.kind === 95 || ts.isSuperProperty(node.parent)) { + else if (node.kind === 96 || ts.isSuperProperty(node.parent)) { var symbol = typeChecker.getSymbolAtLocation(node); return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; } @@ -54519,7 +55858,7 @@ var ts; "version" ]; var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + function getJsDocCommentsFromDeclarations(declarations) { var documentationComment = []; forEachUnique(declarations, function (declaration) { var comments = ts.getJSDocComments(declaration, true); @@ -54558,7 +55897,7 @@ var ts; name: tagName, kind: ts.ScriptElementKind.keyword, kindModifiers: "", - sortText: "0" + sortText: "0", }; })); } @@ -54575,16 +55914,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 220: - case 147: - case 148: case 221: - case 200: + case 148: + case 149: + case 222: + case 201: break findOwner; case 256: return undefined; - case 225: - if (commentOwner.parent.kind === 225) { + case 226: + if (commentOwner.parent.kind === 226) { return undefined; } break findOwner; @@ -54600,7 +55939,7 @@ var ts; var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 69 ? + var paramName = currentName.kind === 70 ? currentName.text : "param" + i; docParams += indentationStr + " * @param " + paramName + newLine; @@ -54618,7 +55957,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 200) { + if (commentOwner.kind === 201) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -54628,17 +55967,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178) { + while (rightHandSide.kind === 179) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 179: case 180: + case 181: return rightHandSide.parameters; - case 192: + case 193: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { return member.parameters; } } @@ -54649,13 +55988,153 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + 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(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath !== undefined) { + 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); + for (var name_48 in packageNameToTypingLocation) { + if (name_48 in inferredTypings && !inferredTypings[name_48]) { + inferredTypings[name_48] = packageNameToTypingLocation[name_48]; + } + } + for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { + var excludeTypingName = exclude_1[_a]; + 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) { + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + filesToWatch.push(jsonPath); + 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) { function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - var baseSensitivity = { sensitivity: "base" }; ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { @@ -54690,7 +56169,7 @@ var ts; }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 231 || decl.kind === 234 || decl.kind === 229) { + if (decl.kind === 232 || decl.kind === 235 || decl.kind === 230) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -54717,7 +56196,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || node.kind === 8) { return node.text; @@ -54731,7 +56210,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 140) { + else if (declaration.name.kind === 141) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -54748,7 +56227,7 @@ var ts; } return true; } - if (expression.kind === 172) { + if (expression.kind === 173) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -54759,7 +56238,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 140) { + if (declaration.name.kind === 141) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -54787,8 +56266,8 @@ var ts; } function compareNavigateToItems(i1, i2) { return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem) { var declaration = rawItem.declaration; @@ -54891,7 +56370,7 @@ var ts; return; } switch (node.kind) { - case 148: + case 149: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -54901,28 +56380,28 @@ var ts; } } break; - case 147: - case 149: + case 148: case 150: - case 146: + case 151: + case 147: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 146: case 145: - case 144: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 231: + case 232: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { addLeafNode(namedBindings); } else { @@ -54933,8 +56412,8 @@ var ts; } } break; - case 169: - case 218: + case 170: + case 219: var decl = node; var name_50 = decl.name; if (ts.isBindingPattern(name_50)) { @@ -54947,12 +56426,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 181: + case 221: case 180: - case 220: - case 179: addNodeWithRecursiveChild(node, node.body); break; - case 224: + case 225: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -54962,9 +56441,9 @@ var ts; } endNode(); break; - case 221: - case 192: case 222: + case 193: + case 223: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -54972,15 +56451,15 @@ var ts; } endNode(); break; - case 225: + case 226: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 238: - case 229: - case 153: - case 151: + case 239: + case 230: + case 154: case 152: - case 223: + case 153: + case 224: addLeafNode(node); break; default: @@ -55034,12 +56513,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 225 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 226 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 225) { + if (a.body.kind !== 226) { return true; } return areSameModule(a.body, b.body); @@ -55072,9 +56551,8 @@ var ts; return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { for (var i = 0; i < Math.min(a.length, b.length); i++) { var chA = a.charAt(i), chB = b.charAt(i); if (chA === "\"" && chB === "'") { @@ -55083,7 +56561,7 @@ var ts; if (chA === "'" && chB === "\"") { return -1; } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } @@ -55091,7 +56569,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return getModuleName(node); } var decl = node; @@ -55099,9 +56577,9 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 179: case 180: - case 192: + case 181: + case 193: return getFunctionOrClassName(node); case 279: return getJSDocTypedefTagName(node); @@ -55110,7 +56588,7 @@ var ts; } } function getItemName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return getModuleName(node); } var name = node.name; @@ -55126,22 +56604,22 @@ var ts; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 180: - case 220: - case 179: + case 181: case 221: - case 192: + case 180: + case 222: + case 193: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 148: + case 149: return "constructor"; - case 152: + case 153: return "new()"; - case 151: + case 152: return "()"; - case 153: + case 154: return "[]"; case 279: return getJSDocTypedefTagName(node); @@ -55155,10 +56633,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { return nameIdentifier.text; } } @@ -55183,24 +56661,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 221: - case 192: - case 224: case 222: + case 193: case 225: - case 256: case 223: + case 226: + case 256: + case 224: case 279: return true; - case 148: - case 147: case 149: + case 148: case 150: - case 218: + case 151: + case 219: return hasSomeImportantChild(item); + case 181: + case 221: case 180: - case 220: - case 179: return isTopLevelFunctionDeclaration(item); default: return false; @@ -55210,10 +56688,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 226: + case 227: case 256: - case 147: case 148: + case 149: return true; default: return hasSomeImportantChild(item); @@ -55222,7 +56700,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 218 && childKind !== 169; + return childKind !== 219 && childKind !== 170; }); } } @@ -55277,17 +56755,17 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 225) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 225 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 226 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 140; + return !member.name || member.name.kind === 141; } function getNodeSpan(node) { return node.kind === 256 @@ -55298,11 +56776,11 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 219) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 187 && - node.parent.operatorToken.kind === 56) { + else if (node.parent.kind === 188 && + node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left); } else if (node.parent.kind === 253 && node.parent.name) { @@ -55316,7 +56794,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 179 || node.kind === 180 || node.kind === 192; + return node.kind === 180 || node.kind === 181 || node.kind === 193; } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -55388,7 +56866,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180; + return ts.isFunctionBlock(node) && node.parent.kind !== 181; } var depth = 0; var maxDepth = 20; @@ -55400,30 +56878,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 199: + case 200: if (!ts.isFunctionBlock(n)) { var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_22.kind === 204 || - parent_22.kind === 207 || + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + if (parent_22.kind === 205 || parent_22.kind === 208 || + parent_22.kind === 209 || + parent_22.kind === 207 || + parent_22.kind === 204 || parent_22.kind === 206 || - parent_22.kind === 203 || - parent_22.kind === 205 || - parent_22.kind === 212 || + parent_22.kind === 213 || parent_22.kind === 252) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 216) { + if (parent_22.kind === 217) { var tryStatement = parent_22; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -55439,25 +56917,25 @@ var ts; }); break; } - case 226: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + case 227: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 221: case 222: - case 224: - case 171: - case 227: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + case 223: + case 225: + case 172: + case 228: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 170: - var openBracket = ts.findChildOfKind(n, 19, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20, sourceFile); + case 171: + var openBracket = ts.findChildOfKind(n, 20, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -55700,7 +57178,7 @@ var ts; if (ch >= 65 && ch <= 90) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { return false; } var str = String.fromCharCode(ch); @@ -55710,7 +57188,7 @@ var ts; if (ch >= 97 && ch <= 122) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { return false; } var str = String.fromCharCode(ch); @@ -55893,10 +57371,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 15) { + if (token === 16) { braceNesting++; } - else if (token === 16) { + else if (token === 17) { braceNesting--; } return token; @@ -55944,9 +57422,9 @@ var ts; } function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 122) { + if (token === 123) { token = nextToken(); - if (token === 125) { + if (token === 126) { token = nextToken(); if (token === 9) { recordAmbientExternalModule(); @@ -55958,42 +57436,42 @@ var ts; } function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 89) { + if (token === 90) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } else { - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } } - else if (token === 56) { + else if (token === 57) { if (tryConsumeRequireCall(true)) { return true; } } - else if (token === 24) { + else if (token === 25) { token = nextToken(); } else { return true; } } - if (token === 15) { + if (token === 16) { token = nextToken(); - while (token !== 16 && token !== 1) { + while (token !== 17 && token !== 1) { token = nextToken(); } - if (token === 16) { + if (token === 17) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56001,13 +57479,13 @@ var ts; } } } - else if (token === 37) { + else if (token === 38) { token = nextToken(); - if (token === 116) { + if (token === 117) { token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56023,17 +57501,17 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 82) { + if (token === 83) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 15) { + if (token === 16) { token = nextToken(); - while (token !== 16 && token !== 1) { + while (token !== 17 && token !== 1) { token = nextToken(); } - if (token === 16) { + if (token === 17) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56041,20 +57519,20 @@ var ts; } } } - else if (token === 37) { + else if (token === 38) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); } } } - else if (token === 89) { + else if (token === 90) { token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 56) { + if (token === 57) { if (tryConsumeRequireCall(true)) { return true; } @@ -56067,9 +57545,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129) { + if (token === 130) { token = nextToken(); - if (token === 17) { + if (token === 18) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56081,27 +57559,27 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 69 && ts.scanner.getTokenValue() === "define") { + if (token === 70 && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 17) { + if (token !== 18) { return true; } token = nextToken(); if (token === 9) { token = nextToken(); - if (token === 24) { + if (token === 25) { token = nextToken(); } else { return true; } } - if (token !== 19) { + if (token !== 20) { return true; } token = nextToken(); var i = 0; - while (token !== 20 && token !== 1) { + while (token !== 21 && token !== 1) { if (token === 9) { recordModuleName(); i++; @@ -56173,7 +57651,7 @@ var ts; var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, true); if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node)) { @@ -56261,6 +57739,12 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + })(SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + var ArgumentListKind = SignatureHelp.ArgumentListKind; function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -56286,14 +57770,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174) { + if (argumentInfo.invocation.kind !== 175) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 69 + var name = expression.kind === 70 ? expression - : expression.kind === 172 + : expression.kind === 173 ? expression.name : undefined; if (!name || !name.text) { @@ -56322,10 +57806,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 || node.parent.kind === 175) { + if (node.parent.kind === 175 || node.parent.kind === 176) { var callExpression = node.parent; - if (node.kind === 25 || - node.kind === 17) { + if (node.kind === 26 || + node.kind === 18) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -56354,24 +57838,24 @@ var ts; } return undefined; } - else if (node.kind === 11 && node.parent.kind === 176) { + else if (node.kind === 12 && node.parent.kind === 177) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 12 && node.parent.parent.kind === 176) { + else if (node.kind === 13 && node.parent.parent.kind === 177) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); + ts.Debug.assert(templateExpression.kind === 190); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 197 && node.parent.parent.parent.kind === 176) { + else if (node.parent.kind === 198 && node.parent.parent.parent.kind === 177) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); - if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 190); + if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -56388,7 +57872,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 24) { + if (child.kind !== 25) { argumentIndex++; } } @@ -56396,8 +57880,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25) { argumentCount++; } return argumentCount; @@ -56413,7 +57897,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { - var argumentCount = tagExpression.template.kind === 11 + var argumentCount = tagExpression.template.kind === 12 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -56434,7 +57918,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 189) { + if (template.kind === 190) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -56494,10 +57978,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25)); + prefixDisplayParts.push(ts.punctuationPart(26)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27)); + suffixDisplayParts.push(ts.punctuationPart(28)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -56508,10 +57992,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17)); + prefixDisplayParts.push(ts.punctuationPart(18)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18)); + suffixDisplayParts.push(ts.punctuationPart(19)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -56521,7 +58005,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -56572,7 +58056,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 192) ? + return ts.getDeclarationOfKind(symbol, 193) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -56603,7 +58087,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 97 && ts.isExpression(location)) { + if (location.kind === 98 && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } if (flags & 3) { @@ -56663,7 +58147,7 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 && ts.isExpression(location); + var isThisExpression = location.kind === 98 && ts.isExpression(location); var type; if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { @@ -56672,14 +58156,14 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 172) { + if (location.parent && location.parent.kind === 173) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression = void 0; - if (location.kind === 174 || location.kind === 175) { + if (location.kind === 175 || location.kind === 176) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -56691,7 +58175,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 175 || callExpression.expression.kind === 95; + var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -56706,7 +58190,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -56721,10 +58205,10 @@ var ts; case ts.ScriptElementKind.letElement: case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.punctuationPart(55)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } if (!(type.flags & 2097152) && type.symbol) { @@ -56739,21 +58223,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 121 && location.parent.kind === 148)) { + (location.kind === 122 && location.parent.kind === 149)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 149 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 148) { + if (functionDeclaration.kind === 149) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -56762,11 +58246,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192)) { + if (ts.getDeclarationOfKind(symbol, 193)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(73)); + displayParts.push(ts.keywordPart(74)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -56774,72 +58258,72 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107)); + displayParts.push(ts.keywordPart(108)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134)); + displayParts.push(ts.keywordPart(135)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74)); + displayParts.push(ts.keywordPart(75)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(81)); + displayParts.push(ts.keywordPart(82)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69; - displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); + var declaration = ts.getDeclarationOfKind(symbol, 226); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70; + displayParts.push(ts.keywordPart(isNamespace ? 127 : 126)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(19)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(91)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 141); + var declaration = ts.getDeclarationOfKind(symbol, 142); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152) { - displayParts.push(ts.keywordPart(92)); + if (declaration.kind === 153) { + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 151 && declaration.name) { + else if (declaration.kind !== 152 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - displayParts.push(ts.keywordPart(134)); + displayParts.push(ts.keywordPart(135)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -56854,7 +58338,7 @@ var ts; var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -56862,33 +58346,33 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228) { - displayParts.push(ts.keywordPart(82)); + if (symbol.declarations[0].kind === 229) { + displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126)); + displayParts.push(ts.keywordPart(127)); } else { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229) { + if (declaration.kind === 230) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129)); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(19)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -56902,7 +58386,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97)); + displayParts.push(ts.keywordPart(98)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -56911,7 +58395,7 @@ var ts; symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.punctuationPart(55)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -56944,7 +58428,7 @@ var ts; if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187) { + if (!declaration.parent || declaration.parent.kind !== 188) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -56987,9 +58471,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(19)); return; } } @@ -56997,12 +58481,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.operatorPart(35)); + displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.operatorPart(36)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.punctuationPart(19)); } documentation = signature.getDocumentationComment(); } @@ -57019,14 +58503,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 179) { + if (declaration.kind === 180) { return true; } - if (declaration.kind !== 218 && declaration.kind !== 220) { + if (declaration.kind !== 219 && declaration.kind !== 221) { return false; } for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { - if (parent_23.kind === 256 || parent_23.kind === 226) { + if (parent_23.kind === 256 || parent_23.kind === 227) { return false; } } @@ -57067,8 +58551,8 @@ var ts; var outputText; var sourceMapText; var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); sourceMapText = text; @@ -57084,9 +58568,9 @@ var ts; getCurrentDirectory: function () { return ""; }, getNewLine: function () { return newLine; }, fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } }; var program = ts.createProgram([inputFileName], options, compilerHost); if (transpileOptions.reportDiagnostics) { @@ -57135,11 +58619,20 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(2, false, 0); - var jsxScanner = ts.createScanner(2, false, 1); + var standardScanner = ts.createScanner(4, false, 0); + var jsxScanner = ts.createScanner(4, false, 1); var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -57164,7 +58657,7 @@ var ts; } }; function advance() { - ts.Debug.assert(scanner !== undefined); + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -57204,11 +58697,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 29: - case 64: + case 30: case 65: + case 66: + case 46: case 45: - case 44: return true; } } @@ -57218,26 +58711,26 @@ var ts; if (node.parent) { switch (node.parent.kind) { case 246: - case 243: + case 244: case 245: - case 242: - return node.kind === 69; + case 243: + return node.kind === 70; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 244; + return node && node.kind === 10; } function shouldRescanSlashToken(container) { - return container.kind === 10; + return container.kind === 11; } function shouldRescanTemplateToken(container) { - return container.kind === 13 || - container.kind === 14; + return container.kind === 14 || + container.kind === 15; } function startsWithSlashToken(t) { - return t === 39 || t === 61; + return t === 40 || t === 62; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -57268,7 +58761,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 27) { + if (expectedScanAction === 1 && currentToken === 28) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -57278,11 +58771,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 16) { + else if (expectedScanAction === 3 && currentToken === 17) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 69) { + else if (expectedScanAction === 4 && currentToken === 70) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -57416,8 +58909,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 16, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -57431,6 +58924,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (FormattingRequestKind) { + FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; + FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; + FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; + FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; + FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; + })(formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + var FormattingRequestKind = formatting.FormattingRequestKind; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57452,6 +58959,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(formatting.RuleAction || (formatting.RuleAction = {})); + var RuleAction = formatting.RuleAction; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57482,6 +59002,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(formatting.RuleFlags || (formatting.RuleFlags = {})); + var RuleFlags = formatting.RuleFlags; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57546,88 +59077,88 @@ var ts; function Rules() { this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.FromTokens([18, 20, 24, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + 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.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.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)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69, 3, 73, 82, 89]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18, 3, 79, 100, 85, 80]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70, 3, 74, 83, 90]); + 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.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)); this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102, 98, 92, 78, 94, 101, 119]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108, 74]), 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18, 79, 80, 71]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100, 85]), 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 131]), 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103, 99, 93, 79, 95, 102, 120]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + 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.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)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 132]), 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.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 129]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 73, 122, 77, 81, 82, 83, 123, 106, 89, 107, 125, 126, 110, 112, 111, 131, 113, 134, 136]), 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([83, 106, 136])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115, 69, 82, 77, 73, 113, 112, 110, 111, 123, 131, 19, 37])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37, formatting.Shared.TokenRange.FromTokens([69, 17])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + 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([126, 130]), 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, 126, 127, 111, 113, 112, 132, 114, 135, 137]), 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, 137])), 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)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.FromTokens([19, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.FromTokens([18, 20, 28, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 132, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 38]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119, 88), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70, formatting.Shared.TokenRange.FromTokens([12, 13])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); + 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.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -57682,41 +59213,41 @@ var ts; this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); + 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)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -57728,35 +59259,35 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 206; + return context.contextNode.kind === 207; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 187: case 188: - case 195: - case 238: - case 234: - case 154: - case 162: + case 189: + case 196: + case 239: + case 235: + case 155: case 163: + case 164: return true; - case 169: - case 223: - case 229: - case 218: - case 142: + case 170: + case 224: + case 230: + case 219: + case 143: case 255: + case 146: case 145: - case 144: - return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; - case 207: - return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; case 208: - return context.currentTokenSpan.kind === 138 || context.nextTokenSpan.kind === 138; + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 209: + return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; } return false; }; @@ -57764,7 +59295,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188; + return context.contextNode.kind === 189; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -57789,76 +59320,76 @@ var ts; return true; } switch (node.kind) { - case 199: + case 200: + case 228: + case 172: case 227: - case 171: - case 226: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: case 151: - case 179: - case 148: + case 152: case 180: - case 222: + case 149: + case 181: + case 223: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 || context.contextNode.kind === 179; + return context.contextNode.kind === 221 || context.contextNode.kind === 180; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 221: - case 192: case 222: - case 224: - case 159: + case 193: + case 223: case 225: - case 236: + case 160: + case 226: case 237: - case 230: - case 233: + case 238: + case 231: + case 234: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 221: + case 222: + case 226: case 225: - case 224: - case 199: + case 200: case 252: - case 226: - case 213: + case 227: + case 214: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 203: - case 213: - case 206: + case 204: + case 214: case 207: case 208: + case 209: + case 206: + case 217: case 205: - case 216: - case 204: - case 212: + case 213: case 252: return true; default: @@ -57866,31 +59397,31 @@ var ts; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171; + return context.contextNode.kind === 172; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174; + return context.contextNode.kind === 175; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175; + return context.contextNode.kind === 176; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24; + return context.currentTokenSpan.kind !== 25; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20; + return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241; + return context.contextNode.kind !== 242; }; Rules.IsJsxExpressionContext = function (context) { return context.contextNode.kind === 248; @@ -57902,7 +59433,7 @@ var ts; return context.contextNode.kind === 246; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242; + return context.contextNode.kind === 243; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -57917,41 +59448,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 143; + return node.kind === 144; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 && + return context.currentTokenParent.kind === 220 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 225; + return context.contextNode.kind === 226; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159; + return context.contextNode.kind === 160; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 && token.kind !== 27) { + if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 155: - case 177: - case 221: - case 192: + case 156: + case 178: case 222: - case 220: - case 179: + case 193: + case 223: + case 221: case 180: + case 181: + case 148: case 147: - case 146: - case 151: case 152: - case 174: + case 153: case 175: - case 194: + case 176: + case 195: return true; default: return false; @@ -57962,13 +59493,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177; + return context.contextNode.kind === 178; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 183; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -57990,7 +59521,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 + 1; + this.mapRowLength = 139 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -58003,6 +59534,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 && column <= 139, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -58166,12 +59698,12 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 138; token++) { + for (var token = 0; token <= 139; token++) { result.push(token); } return result; }; - TokenAllAccess.prototype.Contains = function (tokenValue) { + TokenAllAccess.prototype.Contains = function () { return true; }; TokenAllAccess.prototype.toString = function () { @@ -58210,17 +59742,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(70, 138); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 138, 116, 124]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41, 42, 50, 49]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 69, 17, 19, 15, 97, 92]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69, 17, 97, 92]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69, 18, 20, 92]); + TokenRange.Keywords = TokenRange.FromRange(71, 139); + TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 139, 117, 125]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([69, 130, 132, 120, 133, 103, 117]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 131, 133, 121, 134, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -58356,6 +59888,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -58376,11 +59912,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 24, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 17, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -58428,15 +59964,15 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 221: case 222: + case 223: return ts.rangeContainsRange(parent.members, node); - case 225: + case 226: var body = parent.body; - return body && body.kind === 226 && ts.rangeContainsRange(body.statements, node); + return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); case 256: - case 199: - case 226: + case 200: + case 227: return ts.rangeContainsRange(parent.statements, node); case 252: return ts.rangeContainsRange(parent.block.statements, node); @@ -58482,7 +60018,7 @@ var ts; index++; } }; - function rangeHasNoErrors(r) { + function rangeHasNoErrors() { return false; } } @@ -58594,18 +60130,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 221: return 73; - case 222: return 107; - case 220: return 87; - case 224: return 224; - case 149: return 123; - case 150: return 131; - case 147: + case 222: return 74; + case 223: return 108; + case 221: return 88; + case 225: return 225; + case 150: return 124; + case 151: return 132; + case 148: if (node.asteriskToken) { - return 37; + return 38; } - case 145: - case 142: + case 146: + case 143: return node.name.kind; } } @@ -58613,9 +60149,9 @@ var ts; return { getIndentationForComment: function (kind, tokenIndentation, container) { switch (kind) { - case 16: - case 20: - case 18: + case 17: + case 21: + case 19: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 ? tokenIndentation : indentation; @@ -58627,15 +60163,15 @@ var ts; } } switch (kind) { - case 15: case 16: - case 19: - case 20: case 17: + case 20: + case 21: case 18: - case 80: - case 104: - case 55: + case 19: + case 81: + case 105: + case 56: return indentation; default: return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; @@ -58715,17 +60251,17 @@ var ts; if (!formattingScanner.isOnToken()) { return inheritedIndentation; } - if (ts.isToken(child)) { + if (ts.isToken(child) && child.kind !== 10) { var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 143 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 144 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 170 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 171 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -59029,41 +60565,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 149: + case 221: + case 180: case 148: - case 220: - case 179: case 147: - case 146: - case 180: + case 181: if (node.typeParameters === list) { - return 25; + return 26; } else if (node.parameters === list) { - return 17; + return 18; } break; - case 174: case 175: + case 176: if (node.typeArguments === list) { - return 25; + return 26; } else if (node.arguments === list) { - return 17; + return 18; } break; - case 155: + case 156: if (node.typeArguments === list) { - return 25; + return 26; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 17: - return 18; - case 25: - return 27; + case 18: + return 19; + case 26: + return 28; } return 0; } @@ -59124,6 +60660,10 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -59152,7 +60692,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 187) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 188) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -59265,10 +60805,10 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 15) { + if (nextToken.kind === 16) { return true; } - else if (nextToken.kind === 16) { + else if (nextToken.kind === 17) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; return lineAtPosition === nextTokenStartLine; } @@ -59278,8 +60818,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); + if (parent.kind === 204 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -59290,23 +60830,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 155: + case 156: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 171: + case 172: return node.parent.properties; - case 170: + case 171: return node.parent.elements; - case 220: - case 179: + case 221: case 180: + case 181: + case 148: case 147: - case 146: - case 151: - case 152: { + case 152: + case 153: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -59317,8 +60857,8 @@ var ts; } break; } - case 175: - case 174: { + case 176: + case 175: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -59343,11 +60883,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 18) { + if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 174 || - node.parent.kind === 175) && + if (node.parent && (node.parent.kind === 175 || + node.parent.kind === 176) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -59365,10 +60905,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 174: case 175: - case 172: + case 176: case 173: + case 174: node = node.expression; break; default: @@ -59382,7 +60922,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24) { + if (list[i].kind === 25) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -59422,48 +60962,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202: - case 221: - case 192: + case 203: case 222: - case 224: + case 193: case 223: - case 170: - case 199: - case 226: + case 225: + case 224: case 171: - case 159: - case 161: + case 200: case 227: + case 172: + case 160: + case 162: + case 228: case 250: case 249: - case 178: - case 172: - case 174: + case 179: + case 173: case 175: - case 200: - case 218: - case 235: - case 211: - case 188: + case 176: + case 201: + case 219: + case 236: + case 212: + case 189: + case 169: case 168: - case 167: + case 244: case 243: - case 242: case 248: - case 146: - case 151: + case 147: case 152: - case 142: - case 156: + case 153: + case 143: case 157: - case 164: - case 176: - case 184: - case 237: - case 233: + case 158: + case 165: + case 177: + case 185: case 238: case 234: + case 239: + case 235: return true; } return false; @@ -59471,26 +61011,26 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 204: case 205: - case 207: - case 208: case 206: - case 203: - case 220: - case 179: - case 147: + case 208: + case 209: + case 207: + case 204: + case 221: case 180: case 148: + case 181: case 149: case 150: - return childKind !== 199; - case 236: - return childKind !== 237; - case 230: - return childKind !== 231 || - (child.namedBindings && child.namedBindings.kind !== 233); - case 241: + case 151: + return childKind !== 200; + case 237: + return childKind !== 238; + case 231: + return childKind !== 232 || + (child.namedBindings && child.namedBindings.kind !== 234); + case 242: return childKind !== 245; } return indentByDefault; @@ -59549,7 +61089,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 121) { + if (token.kind !== 122) { return undefined; } var newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -59564,7 +61104,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97) { + if (token.kind !== 98) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -59572,7 +61112,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 174) { + if (superCall.expression && superCall.expression.kind == 175) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -59596,7 +61136,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 202 && ts.isSuperCall(n.expression)) { + if (n.kind === 203 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -59612,8 +61152,8 @@ var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 139 ? new NodeObject(kind, pos, end) : - kind === 69 ? new IdentifierObject(69, pos, end) : + var node = kind >= 140 ? new NodeObject(kind, pos, end) : + kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -59690,7 +61230,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 139) { + if (this.kind >= 140) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; @@ -59748,7 +61288,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 139 ? child : child.getFirstToken(sourceFile); + return child.kind < 140 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -59756,7 +61296,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 139 ? child : child.getLastToken(sourceFile); + return child.kind < 140 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -59794,19 +61334,19 @@ var ts; TokenOrIdentifierObject.prototype.getText = function (sourceFile) { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildCount = function () { return 0; }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { + TokenOrIdentifierObject.prototype.getChildAt = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; return TokenOrIdentifierObject; @@ -59827,7 +61367,7 @@ var ts; }; SymbolObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4)); + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; }; @@ -59844,12 +61384,12 @@ var ts; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { + function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69; + IdentifierObject.prototype.kind = 70; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -59910,7 +61450,7 @@ var ts; }; SignatureObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], undefined, false) : []; + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; }; @@ -59958,9 +61498,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 140) { + if (declaration.name.kind === 141) { var expr = declaration.name.expression; - if (expr.kind === 172) { + if (expr.kind === 173) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -59970,7 +61510,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || node.kind === 8) { return node.text; @@ -59980,10 +61520,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 220: - case 179: + case 221: + case 180: + case 148: case 147: - case 146: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -60000,30 +61540,30 @@ var ts; ts.forEachChild(node, visit); } break; - case 221: - case 192: - case 222: - case 223: - case 224: - case 225: - case 229: - case 238: - case 234: - case 229: - case 231: + case 222: + case 193: + case 223: + case 224: + case 225: + case 226: + case 230: + case 239: + case 235: + case 230: case 232: - case 149: + case 233: case 150: - case 159: + case 151: + case 160: addDeclaration(node); ts.forEachChild(node, visit); break; - case 142: + case 143: if (!ts.hasModifier(node, 92)) { break; } - case 218: - case 169: { + case 219: + case 170: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -60033,23 +61573,23 @@ var ts; visit(decl.initializer); } case 255: + case 146: case 145: - case 144: addDeclaration(node); break; - case 236: + case 237: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 230: + case 231: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { addDeclaration(importClause.namedBindings); } else { @@ -60073,7 +61613,7 @@ var ts; getSourceFileConstructor: function () { return SourceFileObject; }, getSymbolConstructor: function () { return SymbolObject; }, getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } + getSignatureConstructor: function () { return SignatureObject; }, }; } function toEditorSettings(optionsAsMap) { @@ -60165,7 +61705,7 @@ var ts; }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { + this.fileNameToEntry.forEachValue(function (_path, value) { if (value) { fileNames.push(value.hostFileName); } @@ -60195,7 +61735,7 @@ var ts; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4, version, true, scriptKind); } else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); @@ -60348,7 +61888,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, + writeFile: function () { }, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { return hostCache.getOrCreateEntry(fileName) !== undefined; @@ -60490,12 +62030,12 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { - case 69: - case 172: - case 139: - case 97: - case 165: - case 95: + case 70: + case 173: + case 140: + case 98: + case 166: + case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -60616,23 +62156,23 @@ var ts; function getSourceFile(fileName) { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, startPos); if (node === sourceFile) { return; } switch (node.kind) { - case 172: - case 139: + case 173: + case 140: case 9: - case 84: - case 99: - case 93: - case 95: - case 97: - case 165: - case 69: + case 85: + case 100: + case 94: + case 96: + case 98: + case 166: + case 70: break; default: return; @@ -60643,7 +62183,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 225 && + if (nodeForStartPos.parent.parent.kind === 226 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -60723,14 +62263,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 15: return 16; - case 17: return 18; - case 19: return 20; - case 25: return 27; - case 16: return 15; - case 18: return 17; - case 20: return 19; - case 27: return 25; + case 16: return 17; + case 18: return 19; + case 20: return 21; + case 26: return 28; + case 17: return 16; + case 19: return 18; + case 21: return 20; + case 28: return 26; } return undefined; } @@ -60933,13 +62473,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 69: + case 70: nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 240 || + node.parent.kind === 241 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -60959,5352 +62499,5639 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 173 && + node.parent.kind === 174 && node.parent.argumentExpression === node; } - function getDefaultLibFilePath(options) { - if (typeof __dirname !== "undefined") { - return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); + function getDefaultLibFilePath(options) { + if (typeof __dirname !== "undefined") { + return __dirname + ts.directorySeparator + ts.getDefaultLibFileName(options); + } + throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); + } + ts.getDefaultLibFilePath = getDefaultLibFilePath; + function initializeServices() { + ts.objectAllocator = getServicesObjectAllocator(); + } + initializeServices(); +})(ts || (ts = {})); +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } + } + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + }()); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof result === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: result }) : result; + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (_dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + }()); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + return LanguageServiceShimObject; + }(ShimBase)); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; } - throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); - } - ts.getDefaultLibFilePath = getDefaultLibFilePath; - function initializeServices() { - ts.objectAllocator = getServicesObjectAllocator(); - } - initializeServices(); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var ScriptInfo = (function () { - function ScriptInfo(host, fileName, content, scriptKind, isOpen, hasMixedContent) { - if (isOpen === void 0) { isOpen = false; } - if (hasMixedContent === void 0) { hasMixedContent = false; } - this.host = host; - this.fileName = fileName; - this.scriptKind = scriptKind; - this.isOpen = isOpen; - this.hasMixedContent = hasMixedContent; - this.containingProjects = []; - this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); - this.svc = server.ScriptVersionCache.fromString(host, content); - this.scriptKind = scriptKind - ? scriptKind - : ts.getScriptKindFromFileName(fileName); + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; } - ScriptInfo.prototype.getFormatCodeSettings = function () { - return this.formatCodeSettings; - }; - ScriptInfo.prototype.attachToProject = function (project) { - var isNew = !this.isAttached(project); - if (isNew) { - this.containingProjects.push(project); - } - return isNew; - }; - ScriptInfo.prototype.isAttached = function (project) { - switch (this.containingProjects.length) { - case 0: return false; - case 1: return this.containingProjects[0] === project; - case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; - default: return ts.contains(this.containingProjects, project); - } - }; - ScriptInfo.prototype.detachFromProject = function (project) { - switch (this.containingProjects.length) { - case 0: - return; - case 1: - if (this.containingProjects[0] === project) { - this.containingProjects.pop(); - } - break; - case 2: - if (this.containingProjects[0] === project) { - this.containingProjects[0] = this.containingProjects.pop(); - } - else if (this.containingProjects[1] === project) { - this.containingProjects.pop(); - } - break; - default: - server.removeItemFromSet(this.containingProjects, project); - break; - } - }; - ScriptInfo.prototype.detachAllProjects = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.removeFile(this, false); - } - this.containingProjects.length = 0; - }; - ScriptInfo.prototype.getDefaultProject = function () { - if (this.containingProjects.length === 0) { - return server.Errors.ThrowNoProject(); - } - ts.Debug.assert(this.containingProjects.length !== 0); - return this.containingProjects[0]; - }; - ScriptInfo.prototype.setFormatOptions = function (formatSettings) { - if (formatSettings) { - if (!this.formatCodeSettings) { - this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); - } - server.mergeMaps(this.formatCodeSettings, formatSettings); - } - }; - ScriptInfo.prototype.setWatcher = function (watcher) { - this.stopWatcher(); - this.fileWatcher = watcher; - }; - ScriptInfo.prototype.stopWatcher = function () { - if (this.fileWatcher) { - this.fileWatcher.close(); - this.fileWatcher = undefined; - } - }; - ScriptInfo.prototype.getLatestVersion = function () { - return this.svc.latestVersion().toString(); - }; - ScriptInfo.prototype.reload = function (script) { - this.svc.reload(script); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.saveTo = function (fileName) { - var snap = this.snap(); - this.host.writeFile(fileName, snap.getText(0, snap.getLength())); - }; - ScriptInfo.prototype.reloadFromFile = function () { - if (this.hasMixedContent) { - this.reload(""); - } - else { - this.svc.reloadFromFile(this.fileName); - this.markContainingProjectsAsDirty(); - } - }; - ScriptInfo.prototype.snap = function () { - return this.svc.getSnapshot(); - }; - ScriptInfo.prototype.getLineInfo = function (line) { - var snap = this.snap(); - return snap.index.lineNumberToInfo(line); - }; - ScriptInfo.prototype.editContent = function (start, end, newText) { - this.svc.edit(start, end - start, newText); - this.markContainingProjectsAsDirty(); - }; - ScriptInfo.prototype.markContainingProjectsAsDirty = function () { - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - p.markAsDirty(); - } - }; - ScriptInfo.prototype.lineToTextSpan = function (line) { - var index = this.snap().index; - var lineInfo = index.lineNumberToInfo(line + 1); - var len; - if (lineInfo.leaf) { - len = lineInfo.leaf.text.length; - } - else { - var nextLineInfo = index.lineNumberToInfo(line + 2); - len = nextLineInfo.offset - lineInfo.offset; - } - return ts.createTextSpan(lineInfo.offset, len); - }; - ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { - var index = this.snap().index; - var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.offset + offset - 1); - }; - ScriptInfo.prototype.positionToLineOffset = function (position) { - var index = this.snap().index; - var lineOffset = index.charOffsetToLineNumberAndPos(position); - return { line: lineOffset.line, offset: lineOffset.offset + 1 }; - }; - return ScriptInfo; - }()); - server.ScriptInfo = ScriptInfo; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var LSHost = (function () { - function LSHost(host, project, cancellationToken) { - var _this = this; - this.host = host; - this.project = project; - this.cancellationToken = cancellationToken; - this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); - this.resolvedModuleNames = ts.createFileMap(); - this.resolvedTypeReferenceDirectives = ts.createFileMap(); - if (host.trace) { - this.trace = function (s) { return host.trace(s); }; - } - this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { - var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (primaryResult.resolvedModule) { - if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { - return primaryResult; - } - } - var secondaryLookupFailedLookupLocations = []; - var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; - if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { - var traceEnabled = ts.isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); - } - var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; - var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); - if (resolvedName) { - return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); - } - } - if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { - primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); - } - return primaryResult; + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; } - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { - var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var currentResolutionsInFile = cache.get(path); - var newResolutions = ts.createMap(); - var resolvedModules = []; - var compilerOptions = this.getCompilationSettings(); - var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; - for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { - var name_52 = names_3[_i]; - var resolution = newResolutions[name_52]; - if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; - if (moduleResolutionIsValid(existingResolution)) { - resolution = existingResolution; - } - else { - newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); - } - } - ts.Debug.assert(resolution !== undefined); - resolvedModules.push(getResult(resolution)); - } - cache.set(path, newResolutions); - return resolvedModules; - function moduleResolutionIsValid(resolution) { - if (!resolution) { - return false; - } - var result = getResult(resolution); - if (result) { - if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { - return false; - } - return true; - } - return resolution.failedLookupLocations.length === 0; - } - }; - LSHost.prototype.getProjectVersion = function () { - return this.project.getProjectVersion(); - }; - LSHost.prototype.getCompilationSettings = function () { - return this.compilationSettings; - }; - LSHost.prototype.useCaseSensitiveFileNames = function () { - return this.host.useCaseSensitiveFileNames; - }; - LSHost.prototype.getCancellationToken = function () { - return this.cancellationToken; - }; - LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); - }; - LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }); - }; - LSHost.prototype.getDefaultLibFileName = function () { - var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); - return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); - }; - LSHost.prototype.getScriptSnapshot = function (filename) { - var scriptInfo = this.project.getScriptInfoLSHost(filename); - if (scriptInfo) { - return scriptInfo.snap(); + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typingOptions: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; } - }; - LSHost.prototype.getScriptFileNames = function () { - return this.project.getRootFilesLSHost(); - }; - LSHost.prototype.getTypeRootsVersion = function () { - return this.project.typesVersion; - }; - LSHost.prototype.getScriptKind = function (fileName) { - var info = this.project.getScriptInfoLSHost(fileName); - return info && info.scriptKind; - }; - LSHost.prototype.getScriptVersion = function (filename) { - var info = this.project.getScriptInfoLSHost(filename); - return info && info.getLatestVersion(); - }; - LSHost.prototype.getCurrentDirectory = function () { - return this.host.getCurrentDirectory(); - }; - LSHost.prototype.resolvePath = function (path) { - return this.host.resolvePath(path); - }; - LSHost.prototype.fileExists = function (path) { - return this.host.fileExists(path); - }; - LSHost.prototype.readFile = function (fileName) { - return this.host.readFile(fileName); - }; - LSHost.prototype.directoryExists = function (path) { - return this.host.directoryExists(path); - }; - LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { - return this.host.readDirectory(path, extensions, exclude, include); - }; - LSHost.prototype.getDirectories = function (path) { - return this.host.getDirectories(path); - }; - LSHost.prototype.notifyFileRemoved = function (info) { - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - }; - LSHost.prototype.setCompilationSettings = function (opt) { - this.compilationSettings = opt; - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); - }; - return LSHost; - }()); - server.LSHost = LSHost; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.nullTypingsInstaller = { - enqueueInstallTypingsRequest: function () { }, - attach: function (projectService) { }, - onProjectClosed: function (p) { }, - globalTypingsCacheLocation: undefined + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typingOptions: configFile.typingOptions, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); }; - var TypingsCacheEntry = (function () { - function TypingsCacheEntry() { + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); + }); + }; + return CoreServicesShimObject; + }(ShimBase)); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); } - return TypingsCacheEntry; - }()); - function setIsEqualTo(arr1, arr2) { - if (arr1 === arr2) { - return true; + catch (err) { + logInternalError(host, err); + throw err; } - if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { - return true; + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); } - var set = ts.createMap(); - var unique = 0; - for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { - var v = arr1_1[_i]; - if (set[v] !== true) { - set[v] = true; - unique++; - } + catch (err) { + logInternalError(logger, err); + throw err; } - for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { - var v = arr2_1[_a]; - if (!ts.hasProperty(set, v)) { - return false; - } - if (set[v] === true) { - set[v] = false; - unique--; - } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); } - return unique === 0; - } - function typingOptionsChanged(opt1, opt2) { - return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery || - !setIsEqualTo(opt1.include, opt2.include) || - !setIsEqualTo(opt1.exclude, opt2.exclude); - } - function compilerOptionsChanged(opt1, opt2) { - return opt1.allowJs != opt2.allowJs; - } - function toTypingsArray(arr) { - arr.sort(); - return arr; - } - var TypingsCache = (function () { - function TypingsCache(installer) { - this.installer = installer; - this.perProjectCache = ts.createMap(); + catch (err) { + logInternalError(host, err); + throw err; } - TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { - var typingOptions = project.getTypingOptions(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - return server.emptyArray; - } - var entry = this.perProjectCache[project.getProjectName()]; - var result = entry ? entry.typings : server.emptyArray; - if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { - this.perProjectCache[project.getProjectName()] = { - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - typings: result, - poisoned: true - }; - this.installer.enqueueInstallTypingsRequest(project, typingOptions); - } - return result; - }; - TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { - var typingOptions = project.getTypingOptions(); - if (!typingOptions.enableAutoDiscovery) { + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0, n = this._shims.length; i < n; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; return; } - this.installer.enqueueInstallTypingsRequest(project, typingOptions); - }; - TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { - this.perProjectCache[projectName] = { - compilerOptions: compilerOptions, - typingOptions: typingOptions, - typings: toTypingsArray(newTypings), - poisoned: false - }; - }; - TypingsCache.prototype.onProjectClosed = function (project) { - delete this.perProjectCache[project.getProjectName()]; - this.installer.onProjectClosed(project); - }; - return TypingsCache; - }()); - server.TypingsCache = TypingsCache; - })(server = ts.server || (ts.server = {})); + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + }()); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } })(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "2.1"; var ts; (function (ts) { var server; (function (server) { - var crypto = require("crypto"); - function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; - } - server.shouldEmitFile = shouldEmitFile; - var BuilderFileInfo = (function () { - function BuilderFileInfo(scriptInfo, project) { - this.scriptInfo = scriptInfo; - this.project = project; + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(server.LogLevel || (server.LogLevel = {})); + var 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; } - 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 !== 225 || statement.name.kind !== 9) { - return false; - } - } - return true; - }; - BuilderFileInfo.prototype.computeHash = function (text) { - return crypto.createHash("md5") - .update(text) - .digest("base64"); - }; - 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; + } + function createInstallTypingsRequest(project, typingOptions, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" }; - return BuilderFileInfo; - }()); - server.BuilderFileInfo = BuilderFileInfo; - var AbstractBuilder = (function () { - function AbstractBuilder(project, ctor) { - this.project = project; - this.ctor = ctor; - this.fileInfos = ts.createFileMap(); + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); } - AbstractBuilder.prototype.getFileInfo = function (path) { - return this.fileInfos.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.fileInfos.getKeys(); - }; - AbstractBuilder.prototype.setFileInfo = function (path, info) { - this.fileInfos.set(path, info); - }; - AbstractBuilder.prototype.removeFileInfo = function (path) { - this.fileInfos.remove(path); - }; - AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.fileInfos.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; + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); } - 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.apply(this, arguments) || this; - _this.references = []; - _this.referencedBy = []; - return _this; + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); } - 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); + 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, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, }; - ModuleBuilderFileInfo.prototype.removeFileReferences = function () { - for (var _i = 0, _a = this.references; _i < _a.length; _i++) { - var reference = _a[_i]; - reference.removeReferencedBy(this); + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; } - 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.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(); + } + 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]; } }; - 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); + } + server.createNormalizedPathMap = createNormalizedPathMap; + function throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + 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]); } - fileInfo.references = newReferences; - fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); }; - 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; + 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; } - var result = []; - for (var fileName in fileNameSet) { - if (shouldEmitFile(fileNameSet[fileName])) { - result.push(fileName); - } + 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 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; + return GcTimer; + }()); + server.GcTimer = GcTimer; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; (function (ts) { var server; (function (server) { - (function (ProjectKind) { - ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; - ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; - ProjectKind[ProjectKind["External"] = 2] = "External"; - })(server.ProjectKind || (server.ProjectKind = {})); - var ProjectKind = server.ProjectKind; - function remove(items, item) { - var index = items.indexOf(item); - if (index >= 0) { - items.splice(index, 1); + var ScriptInfo = (function () { + function ScriptInfo(host, fileName, content, scriptKind, isOpen, hasMixedContent) { + if (isOpen === void 0) { isOpen = false; } + if (hasMixedContent === void 0) { hasMixedContent = false; } + this.host = host; + this.fileName = fileName; + this.scriptKind = scriptKind; + this.isOpen = isOpen; + this.hasMixedContent = hasMixedContent; + this.containingProjects = []; + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.svc = server.ScriptVersionCache.fromString(host, content); + this.scriptKind = scriptKind + ? scriptKind + : ts.getScriptKindFromFileName(fileName); } - } - function countEachFileTypes(infos) { - var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - switch (info.scriptKind) { + ScriptInfo.prototype.getFormatCodeSettings = function () { + return this.formatCodeSettings; + }; + ScriptInfo.prototype.attachToProject = function (project) { + var isNew = !this.isAttached(project); + if (isNew) { + this.containingProjects.push(project); + } + return isNew; + }; + ScriptInfo.prototype.isAttached = function (project) { + switch (this.containingProjects.length) { + case 0: return false; + case 1: return this.containingProjects[0] === project; + case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; + default: return ts.contains(this.containingProjects, project); + } + }; + ScriptInfo.prototype.detachFromProject = function (project) { + switch (this.containingProjects.length) { + case 0: + return; case 1: - result.js += 1; + if (this.containingProjects[0] === project) { + this.containingProjects.pop(); + } break; case 2: - result.jsx += 1; - break; - case 3: - ts.fileExtensionIs(info.fileName, ".d.ts") - ? result.dts += 1 - : result.ts += 1; + if (this.containingProjects[0] === project) { + this.containingProjects[0] = this.containingProjects.pop(); + } + else if (this.containingProjects[1] === project) { + this.containingProjects.pop(); + } break; - case 4: - result.tsx += 1; + default: + server.removeItemFromSet(this.containingProjects, project); break; } - } - return result; - } - function hasOneOrMoreJsAndNoTsFiles(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; - } - function allRootFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getRootScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; - function allFilesAreJsOrDts(project) { - var counts = countEachFileTypes(project.getScriptInfos()); - return counts.ts === 0 && counts.tsx === 0; - } - server.allFilesAreJsOrDts = allFilesAreJsOrDts; - var Project = (function () { - function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - this.projectKind = projectKind; - this.projectService = projectService; - this.documentRegistry = documentRegistry; - this.languageServiceEnabled = languageServiceEnabled; - this.compilerOptions = compilerOptions; - this.compileOnSaveEnabled = compileOnSaveEnabled; - this.rootFiles = []; - this.rootFilesMap = ts.createFileMap(); - this.lastReportedVersion = 0; - this.projectStructureVersion = 0; - this.projectStateVersion = 0; - this.typesVersion = 0; - if (!this.compilerOptions) { - this.compilerOptions = ts.getDefaultCompilerOptions(); - this.compilerOptions.allowNonTsExtensions = true; - this.compilerOptions.allowJs = true; + }; + ScriptInfo.prototype.detachAllProjects = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.removeFile(this, false); } - else if (hasExplicitListOfFiles) { - this.compilerOptions.allowNonTsExtensions = true; + this.containingProjects.length = 0; + }; + ScriptInfo.prototype.getDefaultProject = function () { + if (this.containingProjects.length === 0) { + return server.Errors.ThrowNoProject(); } - if (languageServiceEnabled) { - this.enableLanguageService(); + return this.containingProjects[0]; + }; + ScriptInfo.prototype.setFormatOptions = function (formatSettings) { + if (formatSettings) { + if (!this.formatCodeSettings) { + this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); + } + server.mergeMaps(this.formatCodeSettings, formatSettings); } - else { - this.disableLanguageService(); + }; + ScriptInfo.prototype.setWatcher = function (watcher) { + this.stopWatcher(); + this.fileWatcher = watcher; + }; + ScriptInfo.prototype.stopWatcher = function () { + if (this.fileWatcher) { + this.fileWatcher.close(); + this.fileWatcher = undefined; } - this.builder = server.createBuilder(this); - this.markAsDirty(); - } - Project.prototype.isNonTsProject = function () { - this.updateGraph(); - return allFilesAreJsOrDts(this); }; - Project.prototype.isJsOnlyProject = function () { - this.updateGraph(); - return hasOneOrMoreJsAndNoTsFiles(this); + ScriptInfo.prototype.getLatestVersion = function () { + return this.svc.latestVersion().toString(); }; - Project.prototype.getProjectErrors = function () { - return this.projectErrors; + ScriptInfo.prototype.reload = function (script) { + this.svc.reload(script); + this.markContainingProjectsAsDirty(); }; - Project.prototype.getLanguageService = function (ensureSynchronized) { - if (ensureSynchronized === void 0) { ensureSynchronized = true; } - if (ensureSynchronized) { - this.updateGraph(); - } - return this.languageService; + ScriptInfo.prototype.saveTo = function (fileName) { + var snap = this.snap(); + this.host.writeFile(fileName, snap.getText(0, snap.getLength())); }; - Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { - if (!this.languageServiceEnabled) { - return []; + ScriptInfo.prototype.reloadFromFile = function (tempFileName) { + if (this.hasMixedContent) { + this.reload(""); + } + else { + this.svc.reloadFromFile(tempFileName || this.fileName); + this.markContainingProjectsAsDirty(); } - this.updateGraph(); - return this.builder.getFilesAffectedBy(scriptInfo); }; - Project.prototype.getProjectVersion = function () { - return this.projectStateVersion.toString(); + ScriptInfo.prototype.snap = function () { + return this.svc.getSnapshot(); }; - Project.prototype.enableLanguageService = function () { - var lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); - lsHost.setCompilationSettings(this.compilerOptions); - this.languageService = ts.createLanguageService(lsHost, this.documentRegistry); - this.lsHost = lsHost; - this.languageServiceEnabled = true; + ScriptInfo.prototype.getLineInfo = function (line) { + var snap = this.snap(); + return snap.index.lineNumberToInfo(line); }; - Project.prototype.disableLanguageService = function () { - this.languageService = server.nullLanguageService; - this.lsHost = server.nullLanguageServiceHost; - this.languageServiceEnabled = false; + ScriptInfo.prototype.editContent = function (start, end, newText) { + this.svc.edit(start, end - start, newText); + this.markContainingProjectsAsDirty(); }; - Project.prototype.getSourceFile = function (path) { - if (!this.program) { - return undefined; + ScriptInfo.prototype.markContainingProjectsAsDirty = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.markAsDirty(); } - return this.program.getSourceFileByPath(path); - }; - Project.prototype.updateTypes = function () { - this.typesVersion++; - this.markAsDirty(); - this.updateGraph(); }; - Project.prototype.close = function () { - if (this.program) { - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - var info = this.projectService.getScriptInfo(f.fileName); - info.detachFromProject(this); - } + ScriptInfo.prototype.lineToTextSpan = function (line) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line + 1); + var len; + if (lineInfo.leaf) { + len = lineInfo.leaf.text.length; } else { - for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { - var root = _c[_b]; - root.detachFromProject(this); - } + var nextLineInfo = index.lineNumberToInfo(line + 2); + len = nextLineInfo.offset - lineInfo.offset; } - this.rootFiles = undefined; - this.rootFilesMap = undefined; - this.program = undefined; - this.languageService.dispose(); - }; - Project.prototype.getCompilerOptions = function () { - return this.compilerOptions; + return ts.createTextSpan(lineInfo.offset, len); }; - Project.prototype.hasRoots = function () { - return this.rootFiles && this.rootFiles.length > 0; + ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line); + return (lineInfo.offset + offset - 1); }; - Project.prototype.getRootFiles = function () { - return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); + ScriptInfo.prototype.positionToLineOffset = function (position) { + var index = this.snap().index; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; }; - Project.prototype.getRootFilesLSHost = function () { - var result = []; - if (this.rootFiles) { - for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { - var f = _a[_i]; - result.push(f.fileName); + return ScriptInfo; + }()); + server.ScriptInfo = ScriptInfo; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LSHost = (function () { + function LSHost(host, project, cancellationToken) { + var _this = this; + this.host = host; + this.project = project; + this.cancellationToken = cancellationToken; + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(); + this.resolvedTypeReferenceDirectives = ts.createFileMap(); + if (host.trace) { + this.trace = function (s) { return host.trace(s); }; + } + this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); + if (primaryResult.resolvedModule) { + if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { + return primaryResult; + } } - if (this.typingFiles) { - for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { - var f = _c[_b]; - result.push(f); + var secondaryLookupFailedLookupLocations = []; + var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; + if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { + var traceEnabled = ts.isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; + var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); + if (resolvedName) { + return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); } } - } - return result; - }; - Project.prototype.getRootScriptInfos = function () { - return this.rootFiles; - }; - Project.prototype.getScriptInfos = function () { - var _this = this; - return ts.map(this.program.getSourceFiles(), function (sourceFile) { - var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); - if (!scriptInfo) { - ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { + primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); } - return scriptInfo; - }); - }; - Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { - if (!this.languageServiceEnabled) { - return undefined; - } - return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); - }; - Project.prototype.getFileNames = function () { - if (!this.program) { - return []; + return primaryResult; + }; + } + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = cache.get(path); + var newResolutions = ts.createMap(); + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name_52 = names_3[_i]; + var resolution = newResolutions[name_52]; + if (!resolution) { + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(getResult(resolution)); } - if (!this.languageServiceEnabled) { - var rootFiles = this.getRootFiles(); - if (this.compilerOptions) { - var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); - if (defaultLibrary) { - (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + cache.set(path, newResolutions); + return resolvedModules; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + var result = getResult(resolution); + if (result) { + if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { + return false; } + return true; } - return rootFiles; + return resolution.failedLookupLocations.length === 0; } - var sourceFiles = this.program.getSourceFiles(); - return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); }; - Project.prototype.getAllEmittableFiles = function () { - if (!this.languageServiceEnabled) { - return []; - } - var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); - var infos = this.getScriptInfos(); - var result = []; - for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { - var info = infos_2[_i]; - if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { - result.push(info.fileName); - } + LSHost.prototype.getProjectVersion = function () { + return this.project.getProjectVersion(); + }; + LSHost.prototype.getCompilationSettings = function () { + return this.compilationSettings; + }; + LSHost.prototype.useCaseSensitiveFileNames = function () { + return this.host.useCaseSensitiveFileNames; + }; + LSHost.prototype.getCancellationToken = function () { + return this.cancellationToken; + }; + LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); + }; + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }); + }; + LSHost.prototype.getDefaultLibFileName = function () { + var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); + return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); + }; + LSHost.prototype.getScriptSnapshot = function (filename) { + var scriptInfo = this.project.getScriptInfoLSHost(filename); + if (scriptInfo) { + return scriptInfo.snap(); } - return result; }; - Project.prototype.containsScriptInfo = function (info) { - return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); + LSHost.prototype.getScriptFileNames = function () { + return this.project.getRootFilesLSHost(); + }; + LSHost.prototype.getTypeRootsVersion = function () { + return this.project.typesVersion; + }; + LSHost.prototype.getScriptKind = function (fileName) { + var info = this.project.getScriptInfoLSHost(fileName); + return info && info.scriptKind; + }; + LSHost.prototype.getScriptVersion = function (filename) { + var info = this.project.getScriptInfoLSHost(filename); + return info && info.getLatestVersion(); }; - Project.prototype.containsFile = function (filename, requireOpen) { - var info = this.projectService.getScriptInfoForNormalizedPath(filename); - if (info && (info.isOpen || !requireOpen)) { - return this.containsScriptInfo(info); - } + LSHost.prototype.getCurrentDirectory = function () { + return this.host.getCurrentDirectory(); }; - Project.prototype.isRoot = function (info) { - return this.rootFilesMap && this.rootFilesMap.contains(info.path); + LSHost.prototype.resolvePath = function (path) { + return this.host.resolvePath(path); }; - Project.prototype.addRoot = function (info) { - if (!this.isRoot(info)) { - this.rootFiles.push(info); - this.rootFilesMap.set(info.path, info); - info.attachToProject(this); - this.markAsDirty(); - } + LSHost.prototype.fileExists = function (path) { + return this.host.fileExists(path); }; - Project.prototype.removeFile = function (info, detachFromProject) { - if (detachFromProject === void 0) { detachFromProject = true; } - this.removeRootFileIfNecessary(info); - this.lsHost.notifyFileRemoved(info); - if (detachFromProject) { - info.detachFromProject(this); - } - this.markAsDirty(); + LSHost.prototype.readFile = function (fileName) { + return this.host.readFile(fileName); }; - Project.prototype.markAsDirty = function () { - this.projectStateVersion++; + LSHost.prototype.directoryExists = function (path) { + return this.host.directoryExists(path); }; - Project.prototype.updateGraph = function () { - if (!this.languageServiceEnabled) { - return true; + LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { + return this.host.readDirectory(path, extensions, exclude, include); + }; + LSHost.prototype.getDirectories = function (path) { + return this.host.getDirectories(path); + }; + LSHost.prototype.notifyFileRemoved = function (info) { + this.resolvedModuleNames.remove(info.path); + this.resolvedTypeReferenceDirectives.remove(info.path); + }; + LSHost.prototype.setCompilationSettings = function (opt) { + this.compilationSettings = opt; + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + }; + return LSHost; + }()); + server.LSHost = LSHost; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.nullTypingsInstaller = { + enqueueInstallTypingsRequest: function () { }, + attach: function () { }, + onProjectClosed: function () { }, + globalTypingsCacheLocation: undefined + }; + var TypingsCacheEntry = (function () { + function TypingsCacheEntry() { + } + return TypingsCacheEntry; + }()); + function setIsEqualTo(arr1, arr2) { + if (arr1 === arr2) { + return true; + } + if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { + return true; + } + var set = ts.createMap(); + var unique = 0; + for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { + var v = arr1_1[_i]; + if (set[v] !== true) { + set[v] = true; + unique++; } - var hasChanges = this.updateGraphWorker(); - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; + } + for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { + var v = arr2_1[_a]; + if (!ts.hasProperty(set, v)) { + return false; } - if (hasChanges) { - this.projectStructureVersion++; + if (set[v] === true) { + set[v] = false; + unique--; } - return !hasChanges; - }; - Project.prototype.setTypings = function (typings) { - if (ts.arrayIsEqualTo(this.typingFiles, typings)) { - return false; + } + return unique === 0; + } + function typingOptionsChanged(opt1, opt2) { + return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery || + !setIsEqualTo(opt1.include, opt2.include) || + !setIsEqualTo(opt1.exclude, opt2.exclude); + } + function compilerOptionsChanged(opt1, opt2) { + return opt1.allowJs != opt2.allowJs; + } + function toTypingsArray(arr) { + arr.sort(); + return arr; + } + var TypingsCache = (function () { + function TypingsCache(installer) { + this.installer = installer; + this.perProjectCache = ts.createMap(); + } + TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return server.emptyArray; } - this.typingFiles = typings; - this.markAsDirty(); - return true; - }; - Project.prototype.updateGraphWorker = function () { - var oldProgram = this.program; - this.program = this.languageService.getProgram(); - var hasChanges = false; - if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { - hasChanges = true; - if (oldProgram) { - for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { - var f = _a[_i]; - if (this.program.getSourceFileByPath(f.path)) { - continue; - } - var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); - if (scriptInfoToDetach) { - scriptInfoToDetach.detachFromProject(this); - } - } - } + var entry = this.perProjectCache[project.getProjectName()]; + var result = entry ? entry.typings : server.emptyArray; + if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { + this.perProjectCache[project.getProjectName()] = { + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + typings: result, + poisoned: true + }; + this.installer.enqueueInstallTypingsRequest(project, typingOptions); } - this.builder.onProjectUpdateGraph(); - return hasChanges; + return result; }; - Project.prototype.getScriptInfoLSHost = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); - if (scriptInfo) { - scriptInfo.attachToProject(this); + TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions.enableAutoDiscovery) { + return; } - return scriptInfo; + this.installer.enqueueInstallTypingsRequest(project, typingOptions); }; - Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { - var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); - if (scriptInfo && !scriptInfo.isAttached(this)) { - return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); - } - return scriptInfo; + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { + this.perProjectCache[projectName] = { + compilerOptions: compilerOptions, + typingOptions: typingOptions, + typings: toTypingsArray(newTypings), + poisoned: false + }; }; - Project.prototype.getScriptInfo = function (uncheckedFileName) { - return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + TypingsCache.prototype.onProjectClosed = function (project) { + delete this.perProjectCache[project.getProjectName()]; + this.installer.onProjectClosed(project); }; - Project.prototype.filesToString = function () { - if (!this.program) { - return ""; - } - var strBuilder = ""; - for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { - var file = _a[_i]; - strBuilder += file.fileName + "\n"; - } - return strBuilder; + return TypingsCache; + }()); + server.TypingsCache = TypingsCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var crypto = require("crypto"); + 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); }; - Project.prototype.setCompilerOptions = function (compilerOptions) { - if (compilerOptions) { - if (this.projectKind === ProjectKind.Inferred) { - compilerOptions.allowJs = true; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 226 || statement.name.kind !== 9) { + return false; } - compilerOptions.allowNonTsExtensions = true; - this.compilerOptions = compilerOptions; - this.lsHost.setCompilationSettings(compilerOptions); - this.markAsDirty(); } + return true; }; - Project.prototype.reloadScript = function (filename) { - var script = this.projectService.getScriptInfoForNormalizedPath(filename); - if (script) { - ts.Debug.assert(script.isAttached(this)); - script.reloadFromFile(); - return true; - } - return false; + BuilderFileInfo.prototype.computeHash = function (text) { + return crypto.createHash("md5") + .update(text) + .digest("base64"); }; - Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { - this.updateGraph(); - var info = { - projectName: this.getProjectName(), - version: this.projectStructureVersion, - isInferred: this.projectKind === ProjectKind.Inferred, - options: this.getCompilerOptions() - }; - if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { - if (this.projectStructureVersion == this.lastReportedVersion) { - return { info: info, projectErrors: this.projectErrors }; - } - var lastReportedFileNames = this.lastReportedFileNames; - var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); - var added = []; - var removed = []; - for (var id in currentFiles) { - if (!ts.hasProperty(lastReportedFileNames, id)) { - added.push(id); - } - } - for (var id in lastReportedFileNames) { - if (!ts.hasProperty(currentFiles, id)) { - removed.push(id); - } - } - this.lastReportedFileNames = currentFiles; - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, changes: { added: added, removed: removed }, projectErrors: this.projectErrors }; - } - else { - var projectFileNames = this.getFileNames(); - this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); - this.lastReportedVersion = this.projectStructureVersion; - return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; - } + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); }; - Project.prototype.getReferencedFiles = function (path) { - var _this = this; - if (!this.languageServiceEnabled) { - return []; - } - var sourceFile = this.getSourceFile(path); + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); if (!sourceFile) { - return []; - } - var referencedFiles = ts.createMap(); - if (sourceFile.imports && sourceFile.imports.length > 0) { - var checker = this.program.getTypeChecker(); - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importName = _a[_i]; - var symbol = checker.getSymbolAtLocation(importName); - if (symbol && symbol.declarations && symbol.declarations[0]) { - var declarationSourceFile = symbol.declarations[0].getSourceFile(); - if (declarationSourceFile) { - referencedFiles[declarationSourceFile.path] = true; - } - } - } + return true; } - var currentDirectory = ts.getDirectoryPath(path); - var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); - if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var referencedFile = _c[_b]; - var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); - referencedFiles[referencedPath] = true; - } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); } - if (sourceFile.resolvedTypeReferenceDirectiveNames) { - for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { - var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; - if (!resolvedTypeReferenceDirective) { - continue; - } - var fileName = resolvedTypeReferenceDirective.resolvedFileName; - var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - referencedFiles[typeFilePath] = true; + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); } } - var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); - return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); - }; - Project.prototype.removeRootFileIfNecessary = function (info) { - if (this.isRoot(info)) { - remove(this.rootFiles, info); - this.rootFilesMap.remove(info.path); - } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; }; - return Project; + return BuilderFileInfo; }()); - server.Project = Project; - var InferredProject = (function (_super) { - __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.directoriesWatchedForTsconfig = []; - _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); - InferredProject.NextId++; - return _this; + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + this.fileInfos = ts.createFileMap(); } - InferredProject.prototype.getProjectName = function () { - return this.inferredProjectName; - }; - InferredProject.prototype.getProjectRootPath = function () { - if (this.projectService.useSingleInferredProject) { - return undefined; - } - var rootFiles = this.getRootFiles(); - return ts.getDirectoryPath(rootFiles[0]); + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.fileInfos.get(path); }; - InferredProject.prototype.close = function () { - _super.prototype.close.call(this); - for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { - var directory = _a[_i]; - this.projectService.stopWatchingDirectory(directory); + 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; }; - InferredProject.prototype.getTypingOptions = function () { - return { - enableAutoDiscovery: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - }; - return InferredProject; - }(Project)); - InferredProject.NextId = 1; - server.InferredProject = InferredProject; - var ConfiguredProject = (function (_super) { - __extends(ConfiguredProject, _super); - function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { - var _this = _super.call(this, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.configFileName = configFileName; - _this.wildcardDirectories = wildcardDirectories; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.openRefCount = 0; - return _this; - } - ConfiguredProject.prototype.getProjectRootPath = function () { - return ts.getDirectoryPath(this.configFileName); - }; - ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; - }; - ConfiguredProject.prototype.setTypingOptions = function (newTypingOptions) { - this.typingOptions = newTypingOptions; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.fileInfos.getKeys(); }; - ConfiguredProject.prototype.getTypingOptions = function () { - return this.typingOptions; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.fileInfos.set(path, info); }; - ConfiguredProject.prototype.getProjectName = function () { - return this.configFileName; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.fileInfos.remove(path); }; - ConfiguredProject.prototype.watchConfigFile = function (callback) { - var _this = this; - this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, function (_) { return callback(_this); }); + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.fileInfos.forEachValue(function (_path, value) { return action(value); }); }; - ConfiguredProject.prototype.watchTypeRoots = function (callback) { - var _this = this; - var roots = this.getEffectiveTypeRoots(); - var watchers = []; - for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { - var root = roots_1[_i]; - this.projectService.logger.info("Add type root watcher for: " + root); - watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; } - this.typeRootsWatchers = watchers; - }; - ConfiguredProject.prototype.watchConfigDirectory = function (callback) { - var _this = this; - if (this.directoryWatcher) { - return; + 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); + } } - var directoryToWatch = ts.getDirectoryPath(this.configFileName); - this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); - this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); + return !emitSkipped; }; - ConfiguredProject.prototype.watchWildcards = function (callback) { - var _this = this; - if (!this.wildcardDirectories) { - return; - } - var configDirectoryPath = ts.getDirectoryPath(this.configFileName); - this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { - if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { - var recursive = (flag & 1) !== 0; - _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); + 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 watchers; - }, {}); + return this.project.getAllEmittableFiles(); + } + return singleFileResult; }; - ConfiguredProject.prototype.stopWatchingDirectory = function () { - if (this.directoryWatcher) { - this.directoryWatcher.close(); - this.directoryWatcher = undefined; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _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); } }; - ConfiguredProject.prototype.close = function () { - _super.prototype.close.call(this); - if (this.projectFileWatcher) { - this.projectFileWatcher.close(); + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; } - if (this.typeRootsWatchers) { - for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { - var watcher = _a[_i]; - watcher.close(); - } - this.typeRootsWatchers = undefined; + if (array[0] === fileInfo) { + array.splice(0, 1); + return; } - for (var id in this.directoriesWatchedForWildcards) { - this.directoriesWatchedForWildcards[id].close(); + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); } - this.directoriesWatchedForWildcards = undefined; - this.stopWatchingDirectory(); }; - ConfiguredProject.prototype.addOpenRef = function () { - this.openRefCount++; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); }; - ConfiguredProject.prototype.deleteOpenRef = function () { - this.openRefCount--; - return this.openRefCount; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); }; - ConfiguredProject.prototype.getEffectiveTypeRoots = function () { - return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; + 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 ConfiguredProject; - }(Project)); - server.ConfiguredProject = ConfiguredProject; - var ExternalProject = (function (_super) { - __extends(ExternalProject, _super); - function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { - var _this = _super.call(this, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.externalProjectName = externalProjectName; - _this.compileOnSaveEnabled = compileOnSaveEnabled; - _this.projectFilePath = projectFilePath; + 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; } - ExternalProject.prototype.getProjectRootPath = function () { - if (this.projectFilePath) { - return ts.getDirectoryPath(this.projectFilePath); + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; } - return ts.getDirectoryPath(ts.normalizeSlashes(this.externalProjectName)); - }; - ExternalProject.prototype.getTypingOptions = function () { - return this.typingOptions; + 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 []; }; - ExternalProject.prototype.setProjectErrors = function (projectErrors) { - this.projectErrors = projectErrors; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); }; - ExternalProject.prototype.setTypingOptions = function (newTypingOptions) { - if (!newTypingOptions) { - newTypingOptions = { - enableAutoDiscovery: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - } - else { - if (newTypingOptions.enableAutoDiscovery === undefined) { - newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this); - } - if (!newTypingOptions.include) { - newTypingOptions.include = []; - } - if (!newTypingOptions.exclude) { - newTypingOptions.exclude = []; + 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(); } - this.typingOptions = newTypingOptions; }; - ExternalProject.prototype.getProjectName = function () { - return this.externalProjectName; - }; - return ExternalProject; - }(Project)); - server.ExternalProject = ExternalProject; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; - function combineProjectOutput(projects, action, comparer, areEqual) { - var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); - return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; - } - server.combineProjectOutput = combineProjectOutput; - var fileNamePropertyReader = { - getFileName: function (x) { return x; }, - getScriptKind: function (_) { return undefined; }, - hasMixedContent: function (_) { return false; } - }; - var externalFilePropertyReader = { - getFileName: function (x) { return x.fileName; }, - getScriptKind: function (x) { return x.scriptKind; }, - hasMixedContent: function (x) { return x.hasMixedContent; } - }; - function findProjectByName(projectName, projects) { - for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { - var proj = projects_1[_i]; - if (proj.getProjectName() === projectName) { - return proj; - } - } - } - function createFileNotFoundDiagnostic(fileName) { - return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); - } - function isRootFileInInferredProject(info) { - if (info.containingProjects.length === 0) { - return false; - } - return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); - } - var DirectoryWatchers = (function () { - function DirectoryWatchers(projectService) { - this.projectService = projectService; - this.directoryWatchersForTsconfig = ts.createMap(); - this.directoryWatchersRefCount = ts.createMap(); - } - DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchersRefCount[directory]--; - if (this.directoryWatchersRefCount[directory] === 0) { - this.projectService.logger.info("Close directory watcher for: " + directory); - this.directoryWatchersForTsconfig[directory].close(); - delete this.directoryWatchersForTsconfig[directory]; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; } - }; - DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { - var currentPath = ts.getDirectoryPath(fileName); - var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { - if (!this.directoryWatchersForTsconfig[currentPath]) { - this.projectService.logger.info("Add watcher for: " + currentPath); - this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); - this.directoryWatchersRefCount[currentPath] = 1; + 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 { - this.directoryWatchersRefCount[currentPath] += 1; + oldIndex++; + newIndex++; } - project.directoriesWatchedForTsconfig.push(currentPath); - currentPath = parentPath; - parentPath = ts.getDirectoryPath(parentPath); - } - }; - return DirectoryWatchers; - }()); - var ProjectService = (function () { - function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { - if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } - this.host = host; - this.logger = logger; - this.cancellationToken = cancellationToken; - this.useSingleInferredProject = useSingleInferredProject; - this.typingsInstaller = typingsInstaller; - this.eventHandler = eventHandler; - this.filenameToScriptInfo = ts.createFileMap(); - this.externalProjectToConfiguredProjectMap = ts.createMap(); - this.externalProjects = []; - this.inferredProjects = []; - this.configuredProjects = []; - this.openFiles = []; - this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.directoryWatchers = new DirectoryWatchers(this); - this.throttledOperations = new server.ThrottledOperations(host); - this.typingsInstaller.attach(this); - this.typingsCache = new server.TypingsCache(this.typingsInstaller); - this.hostConfiguration = { - formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), - hostInfo: "Unknown host" - }; - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); - } - ProjectService.prototype.getChangedFiles_TestOnly = function () { - return this.changedFiles; - }; - ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { - this.ensureInferredProjectsUpToDate(); - }; - ProjectService.prototype.updateTypingsForProject = function (response) { - var project = this.findProject(response.projectName); - if (!project) { - return; } - switch (response.kind) { - case "set": - this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); - project.updateGraph(); - break; - case "invalidate": - this.typingsCache.invalidateCachedTypingsForProject(project); - break; + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); } - }; - ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = projectCompilerOptions; - this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; - for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - proj.setCompilerOptions(projectCompilerOptions); - proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); } - this.updateProjectGraphs(this.inferredProjects); - }; - ProjectService.prototype.stopWatchingDirectory = function (directory) { - this.directoryWatchers.stopWatchingDirectory(directory); + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); }; - ProjectService.prototype.findProject = function (projectName) { - if (projectName === undefined) { - return undefined; + 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 (server.isInferredProjectName(projectName)) { - this.ensureInferredProjectsUpToDate(); - return findProjectByName(projectName, this.inferredProjects); + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); } - return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); - }; - ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { - if (refreshInferredProjects) { - this.ensureInferredProjectsUpToDate(); + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; } - var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - return scriptInfo && scriptInfo.getDefaultProject(); - }; - ProjectService.prototype.ensureInferredProjectsUpToDate = function () { - if (this.changedFiles) { - var projectsToUpdate = void 0; - if (this.changedFiles.length === 1) { - projectsToUpdate = this.changedFiles[0].containingProjects; - } - else { - projectsToUpdate = []; - for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { - var f = _a[_i]; - projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + 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); + } } } - this.updateProjectGraphs(projectsToUpdate); - this.changedFiles = undefined; - } - }; - ProjectService.prototype.findContainingExternalProject = function (fileName) { - for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { - var proj = _a[_i]; - if (proj.containsFile(fileName)) { - return proj; - } + fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; } - return undefined; - }; - ProjectService.prototype.getFormatCodeOptions = function (file) { - var formatCodeSettings; - if (file) { - var info = this.getScriptInfoForNormalizedPath(file); - if (info) { - formatCodeSettings = info.getFormatCodeSettings(); + var result = []; + for (var fileName in fileNameSet) { + if (shouldEmitFile(fileNameSet[fileName])) { + result.push(fileName); } } - return formatCodeSettings || this.hostConfiguration.formatCodeOptions; + return result; }; - ProjectService.prototype.updateProjectGraphs = function (projects) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { - var p = projects_2[_i]; - if (!p.updateGraph()) { - shouldRefreshInferredProjects = true; - } + 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) { + (function (ProjectKind) { + ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; + ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; + ProjectKind[ProjectKind["External"] = 2] = "External"; + })(server.ProjectKind || (server.ProjectKind = {})); + var ProjectKind = server.ProjectKind; + function remove(items, item) { + var index = items.indexOf(item); + if (index >= 0) { + items.splice(index, 1); + } + } + function countEachFileTypes(infos) { + var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + switch (info.scriptKind) { + case 1: + result.js += 1; + break; + case 2: + result.jsx += 1; + break; + case 3: + ts.fileExtensionIs(info.fileName, ".d.ts") + ? result.dts += 1 + : result.ts += 1; + break; + case 4: + result.tsx += 1; + break; } - if (shouldRefreshInferredProjects) { - this.refreshInferredProjects(); + } + return result; + } + function hasOneOrMoreJsAndNoTsFiles(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; + } + function allRootFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getRootScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; + function allFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var Project = (function () { + function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + this.projectKind = projectKind; + this.projectService = projectService; + this.documentRegistry = documentRegistry; + this.languageServiceEnabled = languageServiceEnabled; + this.compilerOptions = compilerOptions; + this.compileOnSaveEnabled = compileOnSaveEnabled; + this.rootFiles = []; + this.rootFilesMap = ts.createFileMap(); + this.lastReportedVersion = 0; + this.projectStructureVersion = 0; + this.projectStateVersion = 0; + this.typesVersion = 0; + if (!this.compilerOptions) { + this.compilerOptions = ts.getDefaultCompilerOptions(); + this.compilerOptions.allowNonTsExtensions = true; + this.compilerOptions.allowJs = true; } - }; - ProjectService.prototype.onSourceFileChanged = function (fileName) { - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - this.logger.info("Error: got watch notification for unknown file: " + fileName); - return; + else if (hasExplicitListOfFiles) { + this.compilerOptions.allowNonTsExtensions = true; } - if (!this.host.fileExists(fileName)) { - this.handleDeletedFile(info); + if (languageServiceEnabled) { + this.enableLanguageService(); } else { - if (info && (!info.isOpen)) { - info.reloadFromFile(); - this.updateProjectGraphs(info.containingProjects); - } - } - }; - ProjectService.prototype.handleDeletedFile = function (info) { - this.logger.info(info.fileName + " deleted"); - info.stopWatcher(); - if (!info.isOpen) { - this.filenameToScriptInfo.remove(info.path); - this.lastDeletedFile = info; - var containingProjects = info.containingProjects.slice(); - info.detachAllProjects(); - this.updateProjectGraphs(containingProjects); - this.lastDeletedFile = undefined; - if (!this.eventHandler) { - return; - } - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var openFile = _a[_i]; - this.eventHandler({ eventName: "context", data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } }); - } + this.disableLanguageService(); } - this.printProjects(); + this.builder = server.createBuilder(this); + this.markAsDirty(); + } + Project.prototype.isNonTsProject = function () { + this.updateGraph(); + return allFilesAreJsOrDts(this); }; - ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { - var _this = this; - this.logger.info("Type root file " + fileName + " changed"); - this.throttledOperations.schedule(project.configFileName + " * type root", 250, function () { - project.updateTypes(); - _this.updateConfiguredProject(project); - _this.refreshInferredProjects(); - }); + Project.prototype.isJsOnlyProject = function () { + this.updateGraph(); + return hasOneOrMoreJsAndNoTsFiles(this); }; - ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { - var _this = this; - if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions())) { - return; - } - this.logger.info("Detected source file changes: " + fileName); - this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project); }); + Project.prototype.getProjectErrors = function () { + return this.projectErrors; }; - ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project) { - var _this = this; - var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors); - var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); - var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); - if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { - this.logger.info("Updating configured project"); - this.updateConfiguredProject(project); - this.refreshInferredProjects(); + Project.prototype.getLanguageService = function (ensureSynchronized) { + if (ensureSynchronized === void 0) { ensureSynchronized = true; } + if (ensureSynchronized) { + this.updateGraph(); } + return this.languageService; }; - ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { - this.logger.info("Config file changed: " + project.configFileName); - this.updateConfiguredProject(project); - this.refreshInferredProjects(); - }; - ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { - this.logger.info(fileName + " is not tsconfig.json"); - return; + Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { + if (!this.languageServiceEnabled) { + return []; } - var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; - this.reportConfigFileDiagnostics(fileName, configFileErrors); - this.logger.info("Detected newly added tsconfig file: " + fileName); - this.reloadProjects(); + this.updateGraph(); + return this.builder.getFilesAffectedBy(scriptInfo); }; - ProjectService.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); + Project.prototype.getProjectVersion = function () { + return this.projectStateVersion.toString(); }; - ProjectService.prototype.removeProject = function (project) { - this.logger.info("remove project: " + project.getRootFiles().toString()); - project.close(); - switch (project.projectKind) { - case server.ProjectKind.External: - server.removeItemFromSet(this.externalProjects, project); - break; - case server.ProjectKind.Configured: - server.removeItemFromSet(this.configuredProjects, project); - break; - case server.ProjectKind.Inferred: - server.removeItemFromSet(this.inferredProjects, project); - break; + Project.prototype.enableLanguageService = function () { + var lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); + lsHost.setCompilationSettings(this.compilerOptions); + this.languageService = ts.createLanguageService(lsHost, this.documentRegistry); + this.lsHost = lsHost; + this.languageServiceEnabled = true; + }; + Project.prototype.disableLanguageService = function () { + this.languageService = server.nullLanguageService; + this.lsHost = server.nullLanguageServiceHost; + this.languageServiceEnabled = false; + }; + Project.prototype.getSourceFile = function (path) { + if (!this.program) { + return undefined; } + return this.program.getSourceFileByPath(path); }; - ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { - var externalProject = this.findContainingExternalProject(info.fileName); - if (externalProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); + Project.prototype.updateTypes = function () { + this.typesVersion++; + this.markAsDirty(); + this.updateGraph(); + }; + Project.prototype.close = function () { + if (this.program) { + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + var info = this.projectService.getScriptInfo(f.fileName); + info.detachFromProject(this); } - return; } - var foundConfiguredProject = false; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - foundConfiguredProject = true; - if (addToListOfOpenFiles) { - (p).addOpenRef(); - } + else { + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; + root.detachFromProject(this); } } - if (foundConfiguredProject) { - if (addToListOfOpenFiles) { - this.openFiles.push(info); + this.rootFiles = undefined; + this.rootFilesMap = undefined; + this.program = undefined; + this.languageService.dispose(); + }; + Project.prototype.getCompilerOptions = function () { + return this.compilerOptions; + }; + Project.prototype.hasRoots = function () { + return this.rootFiles && this.rootFiles.length > 0; + }; + Project.prototype.getRootFiles = function () { + return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); + }; + Project.prototype.getRootFilesLSHost = function () { + var result = []; + if (this.rootFiles) { + for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { + var f = _a[_i]; + result.push(f.fileName); } - return; - } - if (info.containingProjects.length === 0) { - var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); - if (!this.useSingleInferredProject) { - for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { + if (this.typingFiles) { + for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { var f = _c[_b]; - if (f.containingProjects.length === 0) { - continue; - } - var defaultProject = f.getDefaultProject(); - if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - this.removeProject(defaultProject); - f.attachToProject(inferredProject); - } + result.push(f); } } } - if (addToListOfOpenFiles) { - this.openFiles.push(info); - } + return result; }; - ProjectService.prototype.closeOpenFile = function (info) { - info.reloadFromFile(); - server.removeItemFromSet(this.openFiles, info); - info.isOpen = false; - var projectsToRemove; - for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { - var p = _a[_i]; - if (p.projectKind === server.ProjectKind.Configured) { - if (p.deleteOpenRef() === 0) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } - } - else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { - (projectsToRemove || (projectsToRemove = [])).push(p); - } - } - if (projectsToRemove) { - for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { - var project = projectsToRemove_1[_b]; - this.removeProject(project); - } - var orphanFiles = void 0; - for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { - var f = _d[_c]; - if (f.containingProjects.length === 0) { - (orphanFiles || (orphanFiles = [])).push(f); - } - } - if (orphanFiles) { - for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { - var f = orphanFiles_1[_e]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); - } - } - } - if (info.containingProjects.length === 0) { - this.filenameToScriptInfo.remove(info.path); - } + Project.prototype.getRootScriptInfos = function () { + return this.rootFiles; }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { - var searchPath = ts.getDirectoryPath(fileName); - this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); - if (!configFileName) { - this.logger.info("No config files found."); - return {}; - } - this.logger.info("Config file name: " + configFileName); - var project = this.findConfiguredProjectByProjectName(configFileName); - if (!project) { - var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; - if (!success) { - return { configFileName: configFileName, configFileErrors: errors }; - } - this.logger.info("Opened configuration file " + configFileName); - if (errors && errors.length > 0) { - return { configFileName: configFileName, configFileErrors: errors }; + Project.prototype.getScriptInfos = function () { + var _this = this; + return ts.map(this.program.getSourceFiles(), function (sourceFile) { + var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); + if (!scriptInfo) { + ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); } - } - else { - this.updateConfiguredProject(project); - } - return { configFileName: configFileName }; + return scriptInfo; + }); }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { - var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); - if (this.host.fileExists(tsconfigFileName)) { - return tsconfigFileName; - } - var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); - if (this.host.fileExists(jsconfigFileName)) { - return jsconfigFileName; - } - var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; + Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { + if (!this.languageServiceEnabled) { + return undefined; } - return undefined; + return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); }; - ProjectService.prototype.printProjects = function () { - if (!this.logger.hasLevel(server.LogLevel.verbose)) { - return; - } - this.logger.startGroup(); - var counter = 0; - counter = printProjects(this.logger, this.externalProjects, counter); - counter = printProjects(this.logger, this.configuredProjects, counter); - counter = printProjects(this.logger, this.inferredProjects, counter); - this.logger.info("Open files: "); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var rootFile = _a[_i]; - this.logger.info(rootFile.fileName); + Project.prototype.getFileNames = function () { + if (!this.program) { + return []; } - this.logger.endGroup(); - function printProjects(logger, projects, counter) { - for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { - var project = projects_3[_i]; - project.updateGraph(); - logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); - logger.info(project.filesToString()); - logger.info("-----------------------------------------------"); - counter++; + if (!this.languageServiceEnabled) { + var rootFiles = this.getRootFiles(); + if (this.compilerOptions) { + var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); + if (defaultLibrary) { + (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + } } - return counter; - } - }; - ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { - return findProjectByName(configFileName, this.configuredProjects); - }; - ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { - return findProjectByName(projectFileName, this.externalProjects); - }; - ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { - configFilename = ts.normalizePath(configFilename); - var configFileContent = this.host.readFile(configFilename); - var errors; - var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); - var config = result.config; - if (result.error) { - var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; - config = sanitizedConfig; - errors = diagnostics.length ? diagnostics : [result.error]; - } - var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename); - if (parsedCommandLine.errors.length) { - errors = ts.concatenate(errors, parsedCommandLine.errors); - } - ts.Debug.assert(!!parsedCommandLine.fileNames); - if (parsedCommandLine.fileNames.length === 0) { - (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); - return { success: false, configFileErrors: errors }; + return rootFiles; } - var projectOptions = { - files: parsedCommandLine.fileNames, - compilerOptions: parsedCommandLine.options, - configHasFilesProperty: config["files"] !== undefined, - wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), - typingOptions: parsedCommandLine.typingOptions, - compileOnSave: parsedCommandLine.compileOnSave - }; - return { success: true, projectOptions: projectOptions, configFileErrors: errors }; + var sourceFiles = this.program.getSourceFiles(); + return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); }; - ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { - if (options && options.disableSizeLimit || !this.host.getFileSize) { - return false; + Project.prototype.getAllEmittableFiles = function () { + if (!this.languageServiceEnabled) { + return []; } - var totalNonTsFileSize = 0; - for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { - var f = fileNames_3[_i]; - var fileName = propertyReader.getFileName(f); - if (ts.hasTypeScriptFileExtension(fileName)) { - continue; - } - totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { - return true; + var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); + var infos = this.getScriptInfos(); + var result = []; + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { + result.push(info.fileName); } } - return false; + return result; }; - ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, options, !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); - this.externalProjects.push(project); - return project; + Project.prototype.containsScriptInfo = function (info) { + return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); }; - ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { - if (!this.eventHandler) { - return; + Project.prototype.containsFile = function (filename, requireOpen) { + var info = this.projectService.getScriptInfoForNormalizedPath(filename); + if (info && (info.isOpen || !requireOpen)) { + return this.containsScriptInfo(info); } - this.eventHandler({ - eventName: "configFileDiag", - data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } - }); }; - ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { - var _this = this; - var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); - var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors); - project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); - if (!sizeLimitExceeded) { - this.watchConfigDirectoryForProject(project, projectOptions); - } - project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); - project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); - this.configuredProjects.push(project); - return project; + Project.prototype.isRoot = function (info) { + return this.rootFilesMap && this.rootFilesMap.contains(info.path); }; - ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { - var _this = this; - if (!options.configHasFilesProperty) { - project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + Project.prototype.addRoot = function (info) { + if (!this.isRoot(info)) { + this.rootFiles.push(info); + this.rootFilesMap.set(info.path, info); + info.attachToProject(this); + this.markAsDirty(); } }; - ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typingOptions, configFileErrors) { - var errors; - for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { - var f = files_4[_i]; - var rootFilename = propertyReader.getFileName(f); - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f); - if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); - project.addRoot(info); - } - else { - (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); - } + Project.prototype.removeFile = function (info, detachFromProject) { + if (detachFromProject === void 0) { detachFromProject = true; } + this.removeRootFileIfNecessary(info); + this.lsHost.notifyFileRemoved(info); + if (detachFromProject) { + info.detachFromProject(this); } - project.setProjectErrors(ts.concatenate(configFileErrors, errors)); - project.setTypingOptions(typingOptions); - project.updateGraph(); + this.markAsDirty(); }; - ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { - var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); - var projectOptions = conversionResult.success - ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; - var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); - return { - success: conversionResult.success, - project: project, - errors: project.getProjectErrors() - }; + Project.prototype.markAsDirty = function () { + this.projectStateVersion++; }; - ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors) { - var oldRootScriptInfos = project.getRootScriptInfos(); - var newRootScriptInfos = []; - var newRootScriptInfoMap = server.createNormalizedPathMap(); - var projectErrors; - var rootFilesChanged = false; - for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { - var f = newUncheckedFiles_1[_i]; - var newRootFile = propertyReader.getFileName(f); - if (!this.host.fileExists(newRootFile)) { - (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); - continue; - } - var normalizedPath = server.toNormalizedPath(newRootFile); - var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); - if (!scriptInfo || !project.isRoot(scriptInfo)) { - rootFilesChanged = true; - if (!scriptInfo) { - var scriptKind = propertyReader.getScriptKind(f); - var hasMixedContent = propertyReader.hasMixedContent(f); - scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); - } - } - newRootScriptInfos.push(scriptInfo); - newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); + Project.prototype.updateGraph = function () { + if (!this.languageServiceEnabled) { + return true; } - if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { - var toAdd = void 0; - var toRemove = void 0; - for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { - var oldFile = oldRootScriptInfos_1[_a]; - if (!newRootScriptInfoMap.contains(oldFile.fileName)) { - (toRemove || (toRemove = [])).push(oldFile); - } - } - for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { - var newFile = newRootScriptInfos_1[_b]; - if (!project.isRoot(newFile)) { - (toAdd || (toAdd = [])).push(newFile); - } - } - if (toRemove) { - for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { - var f = toRemove_1[_c]; - project.removeFile(f); - } - } - if (toAdd) { - for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { - var f = toAdd_1[_d]; - if (f.isOpen && isRootFileInInferredProject(f)) { - var inferredProject = f.containingProjects[0]; - inferredProject.removeFile(f); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); - } - } - project.addRoot(f); - } - } + var hasChanges = this.updateGraphWorker(); + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; } - project.setCompilerOptions(newOptions); - project.setTypingOptions(newTypingOptions); - if (compileOnSave !== undefined) { - project.compileOnSaveEnabled = compileOnSave; + if (hasChanges) { + this.projectStructureVersion++; } - project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); - project.updateGraph(); + return !hasChanges; }; - ProjectService.prototype.updateConfiguredProject = function (project) { - if (!this.host.fileExists(project.configFileName)) { - this.logger.info("Config file deleted"); - this.removeProject(project); - return; - } - var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - if (!success) { - this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); - return configFileErrors; - } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { - project.setCompilerOptions(projectOptions.compilerOptions); - if (!project.languageServiceEnabled) { - return; - } - project.disableLanguageService(); - project.stopWatchingDirectory(); + Project.prototype.setTypings = function (typings) { + if (ts.arrayIsEqualTo(this.typingFiles, typings)) { + return false; } - else { - if (!project.languageServiceEnabled) { - project.enableLanguageService(); + this.typingFiles = typings; + this.markAsDirty(); + return true; + }; + Project.prototype.updateGraphWorker = function () { + var oldProgram = this.program; + this.program = this.languageService.getProgram(); + var hasChanges = false; + if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { + hasChanges = true; + if (oldProgram) { + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (this.program.getSourceFileByPath(f.path)) { + continue; + } + var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); + if (scriptInfoToDetach) { + scriptInfoToDetach.detachFromProject(this); + } + } } - this.watchConfigDirectoryForProject(project, projectOptions); - this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors); } + this.builder.onProjectUpdateGraph(); + return hasChanges; }; - ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { - var _this = this; - var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; - var project = useExistingProject - ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); - project.addRoot(root); - this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); - project.updateGraph(); - if (!useExistingProject) { - this.inferredProjects.push(project); + Project.prototype.getScriptInfoLSHost = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); + if (scriptInfo) { + scriptInfo.attachToProject(this); } - return project; + return scriptInfo; }; - ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { - return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); + Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); + if (scriptInfo && !scriptInfo.isAttached(this)) { + return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); + } + return scriptInfo; }; - ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { + Project.prototype.getScriptInfo = function (uncheckedFileName) { return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); }; - ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { - var _this = this; - var info = this.getScriptInfoForNormalizedPath(fileName); - if (!info) { - var content = void 0; - if (this.host.fileExists(fileName)) { - content = fileContent || (hasMixedContent ? "" : this.host.readFile(fileName)); - } - if (!content) { - if (openedByClient) { - content = ""; - } - } - if (content !== undefined) { - info = new server.ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent); - this.filenameToScriptInfo.set(info.path, info); - if (!info.isOpen && !hasMixedContent) { - info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); - } - } + Project.prototype.filesToString = function () { + if (!this.program) { + return ""; } - if (info) { - if (fileContent !== undefined) { - info.reload(fileContent); - } - if (openedByClient) { - info.isOpen = true; - } + var strBuilder = ""; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var file = _a[_i]; + strBuilder += file.fileName + "\n"; } - return info; + return strBuilder; }; - ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { - return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); + Project.prototype.setCompilerOptions = function (compilerOptions) { + if (compilerOptions) { + if (this.projectKind === ProjectKind.Inferred) { + compilerOptions.allowJs = true; + } + compilerOptions.allowNonTsExtensions = true; + this.compilerOptions = compilerOptions; + this.lsHost.setCompilationSettings(compilerOptions); + this.markAsDirty(); + } }; - ProjectService.prototype.getScriptInfoForPath = function (fileName) { - return this.filenameToScriptInfo.get(fileName); + Project.prototype.reloadScript = function (filename, tempFileName) { + var script = this.projectService.getScriptInfoForNormalizedPath(filename); + if (script) { + ts.Debug.assert(script.isAttached(this)); + script.reloadFromFile(tempFileName); + return true; + } + return false; }; - ProjectService.prototype.setHostConfiguration = function (args) { - if (args.file) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); - if (info) { - info.setFormatOptions(args.formatOptions); - this.logger.info("Host configuration update for file " + args.file); + Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { + this.updateGraph(); + var info = { + projectName: this.getProjectName(), + version: this.projectStructureVersion, + isInferred: this.projectKind === ProjectKind.Inferred, + options: this.getCompilerOptions() + }; + if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { + if (this.projectStructureVersion == this.lastReportedVersion) { + return { info: info, projectErrors: this.projectErrors }; } - } - else { - if (args.hostInfo !== undefined) { - this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); + var lastReportedFileNames = this.lastReportedFileNames; + var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added = []; + var removed = []; + for (var id in currentFiles) { + if (!ts.hasProperty(lastReportedFileNames, id)) { + added.push(id); + } } - if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions); - this.logger.info("Format host information updated"); + for (var id in lastReportedFileNames) { + if (!ts.hasProperty(currentFiles, id)) { + removed.push(id); + } } + this.lastReportedFileNames = currentFiles; + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, changes: { added: added, removed: removed }, projectErrors: this.projectErrors }; } - }; - ProjectService.prototype.closeLog = function () { - this.logger.close(); - }; - ProjectService.prototype.reloadProjects = function () { - this.logger.info("reload projects."); - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - this.openOrUpdateConfiguredProjectForFile(info.fileName); + else { + var projectFileNames = this.getFileNames(); + this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; } - this.refreshInferredProjects(); }; - ProjectService.prototype.refreshInferredProjects = function () { - this.logger.info("updating project structure from ..."); - this.printProjects(); - var orphantedFiles = []; - for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { - var info = _a[_i]; - if (info.containingProjects.length === 0) { - orphantedFiles.push(info); - } - else { - if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { - var inferredProject = info.containingProjects[0]; - ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); - inferredProject.removeFile(info); - if (!inferredProject.hasRoots()) { - this.removeProject(inferredProject); + Project.prototype.getReferencedFiles = function (path) { + var _this = this; + if (!this.languageServiceEnabled) { + return []; + } + var sourceFile = this.getSourceFile(path); + if (!sourceFile) { + return []; + } + var referencedFiles = ts.createMap(); + if (sourceFile.imports && sourceFile.imports.length > 0) { + var checker = this.program.getTypeChecker(); + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importName = _a[_i]; + var symbol = checker.getSymbolAtLocation(importName); + if (symbol && symbol.declarations && symbol.declarations[0]) { + var declarationSourceFile = symbol.declarations[0].getSourceFile(); + if (declarationSourceFile) { + referencedFiles[declarationSourceFile.path] = true; } } } } - for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { - var f = orphantedFiles_1[_b]; - this.assignScriptInfoToInferredProjectIfNecessary(f, false); + var currentDirectory = ts.getDirectoryPath(path); + var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); + if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { + for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { + var referencedFile = _c[_b]; + var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); + referencedFiles[referencedPath] = true; + } } - for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { - var p = _d[_c]; - p.updateGraph(); + if (sourceFile.resolvedTypeReferenceDirectiveNames) { + for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { + var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + if (!resolvedTypeReferenceDirective) { + continue; + } + var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + referencedFiles[typeFilePath] = true; + } } - this.printProjects(); + var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); + return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + Project.prototype.removeRootFileIfNecessary = function (info) { + if (this.isRoot(info)) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); + } }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { - var _a = this.findContainingExternalProject(fileName) - ? {} - : this.openOrUpdateConfiguredProjectForFile(fileName), _b = _a.configFileName, configFileName = _b === void 0 ? undefined : _b, _c = _a.configFileErrors, configFileErrors = _c === void 0 ? undefined : _c; - var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); - this.assignScriptInfoToInferredProjectIfNecessary(info, true); - this.printProjects(); - return { configFileName: configFileName, configFileErrors: configFileErrors }; + return Project; + }()); + server.Project = Project; + var InferredProject = (function (_super) { + __extends(InferredProject, _super); + function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.directoriesWatchedForTsconfig = []; + _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); + InferredProject.NextId++; + return _this; + } + InferredProject.prototype.getProjectName = function () { + return this.inferredProjectName; }; - ProjectService.prototype.closeClientFile = function (uncheckedFileName) { - var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); - if (info) { - this.closeOpenFile(info); - info.isOpen = false; + InferredProject.prototype.getProjectRootPath = function () { + if (this.projectService.useSingleInferredProject) { + return undefined; } - this.printProjects(); + var rootFiles = this.getRootFiles(); + return ts.getDirectoryPath(rootFiles[0]); }; - ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_3 = function (proj) { - var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); - result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); - }; - for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { - var proj = currentProjects_1[_i]; - _loop_3(proj); + InferredProject.prototype.close = function () { + _super.prototype.close.call(this); + for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + this.projectService.stopWatchingDirectory(directory); } }; - ProjectService.prototype.synchronizeProjectList = function (knownProjects) { - var files = []; - this.collectChanges(knownProjects, this.externalProjects, files); - this.collectChanges(knownProjects, this.configuredProjects, files); - this.collectChanges(knownProjects, this.inferredProjects, files); - return files; + InferredProject.prototype.getTypingOptions = function () { + return { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; }; - ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { - var recordChangedFiles = changedFiles && !openFiles && !closedFiles; - if (openFiles) { - for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { - var file = openFiles_1[_i]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); - var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); - } - } - if (changedFiles) { - for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { - var file = changedFiles_1[_a]; - var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!!scriptInfo); - for (var i = file.changes.length - 1; i >= 0; i--) { - var change = file.changes[i]; - scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); - } - if (recordChangedFiles) { - if (!this.changedFiles) { - this.changedFiles = [scriptInfo]; - } - else if (this.changedFiles.indexOf(scriptInfo) < 0) { - this.changedFiles.push(scriptInfo); - } - } - } - } - if (closedFiles) { - for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { - var file = closedFiles_1[_b]; - this.closeClientFile(file); - } - } - if (openFiles || closedFiles) { - this.refreshInferredProjects(); + return InferredProject; + }(Project)); + InferredProject.NextId = 1; + server.InferredProject = InferredProject; + var ConfiguredProject = (function (_super) { + __extends(ConfiguredProject, _super); + function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; + _this.wildcardDirectories = wildcardDirectories; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.openRefCount = 0; + return _this; + } + ConfiguredProject.prototype.getProjectRootPath = function () { + return ts.getDirectoryPath(this.configFileName); + }; + ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ConfiguredProject.prototype.setTypingOptions = function (newTypingOptions) { + this.typingOptions = newTypingOptions; + }; + ConfiguredProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ConfiguredProject.prototype.getProjectName = function () { + return this.configFileName; + }; + ConfiguredProject.prototype.watchConfigFile = function (callback) { + var _this = this; + this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, function (_) { return callback(_this); }); + }; + ConfiguredProject.prototype.watchTypeRoots = function (callback) { + var _this = this; + var roots = this.getEffectiveTypeRoots(); + var watchers = []; + for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { + var root = roots_1[_i]; + this.projectService.logger.info("Add type root watcher for: " + root); + watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); } + this.typeRootsWatchers = watchers; }; - ProjectService.prototype.closeConfiguredProject = function (configFile) { - var configuredProject = this.findConfiguredProjectByProjectName(configFile); - if (configuredProject && configuredProject.deleteOpenRef() === 0) { - this.removeProject(configuredProject); + ConfiguredProject.prototype.watchConfigDirectory = function (callback) { + var _this = this; + if (this.directoryWatcher) { + return; } + var directoryToWatch = ts.getDirectoryPath(this.configFileName); + this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); + this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); }; - ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { - if (suppressRefresh === void 0) { suppressRefresh = false; } - var fileName = server.toNormalizedPath(uncheckedFileName); - var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; - if (configFiles) { - var shouldRefreshInferredProjects = false; - for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { - var configFile = configFiles_1[_i]; - if (this.closeConfiguredProject(configFile)) { - shouldRefreshInferredProjects = true; - } - } - delete this.externalProjectToConfiguredProjectMap[fileName]; - if (shouldRefreshInferredProjects && !suppressRefresh) { - this.refreshInferredProjects(); - } + ConfiguredProject.prototype.watchWildcards = function (callback) { + var _this = this; + if (!this.wildcardDirectories) { + return; } - else { - var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); - if (externalProject) { - this.removeProject(externalProject); - if (!suppressRefresh) { - this.refreshInferredProjects(); - } + var configDirectoryPath = ts.getDirectoryPath(this.configFileName); + this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { + if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { + var recursive = (flag & 1) !== 0; + _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); + watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); } - } + return watchers; + }, {}); }; - ProjectService.prototype.openExternalProject = function (proj) { - var tsConfigFiles; - var rootFiles = []; - for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { - var file = _a[_i]; - var normalized = server.toNormalizedPath(file.fileName); - if (ts.getBaseFileName(normalized) === "tsconfig.json") { - (tsConfigFiles || (tsConfigFiles = [])).push(normalized); - } - else { - rootFiles.push(file); - } + ConfiguredProject.prototype.stopWatchingDirectory = function () { + if (this.directoryWatcher) { + this.directoryWatcher.close(); + this.directoryWatcher = undefined; } - if (tsConfigFiles) { - tsConfigFiles.sort(); + }; + ConfiguredProject.prototype.close = function () { + _super.prototype.close.call(this); + if (this.projectFileWatcher) { + this.projectFileWatcher.close(); } - var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); - var exisingConfigFiles; - if (externalProject) { - if (!tsConfigFiles) { - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, undefined); - return; + if (this.typeRootsWatchers) { + for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { + var watcher = _a[_i]; + watcher.close(); } - this.closeExternalProject(proj.projectFileName, true); + this.typeRootsWatchers = undefined; } - else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { - if (!tsConfigFiles) { - this.closeExternalProject(proj.projectFileName, true); - } - else { - var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - var iNew = 0; - var iOld = 0; - while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { - var newConfig = tsConfigFiles[iNew]; - var oldConfig = oldConfigFiles[iOld]; - if (oldConfig < newConfig) { - this.closeConfiguredProject(oldConfig); - iOld++; - } - else if (oldConfig > newConfig) { - iNew++; - } - else { - (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); - iOld++; - iNew++; - } - } - for (var i = iOld; i < oldConfigFiles.length; i++) { - this.closeConfiguredProject(oldConfigFiles[i]); - } - } + for (var id in this.directoriesWatchedForWildcards) { + this.directoriesWatchedForWildcards[id].close(); } - if (tsConfigFiles) { - this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; - for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { - var tsconfigFile = tsConfigFiles_1[_b]; - var project = this.findConfiguredProjectByProjectName(tsconfigFile); - if (!project) { - var result = this.openConfigFile(tsconfigFile); - project = result.success && result.project; - } - if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { - project.addOpenRef(); - } - } + this.directoriesWatchedForWildcards = undefined; + this.stopWatchingDirectory(); + }; + ConfiguredProject.prototype.addOpenRef = function () { + this.openRefCount++; + }; + ConfiguredProject.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; + ConfiguredProject.prototype.getEffectiveTypeRoots = function () { + return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; + }; + return ConfiguredProject; + }(Project)); + server.ConfiguredProject = ConfiguredProject; + var ExternalProject = (function (_super) { + __extends(ExternalProject, _super); + function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { + var _this = _super.call(this, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.externalProjectName = externalProjectName; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.projectFilePath = projectFilePath; + return _this; + } + ExternalProject.prototype.getProjectRootPath = function () { + if (this.projectFilePath) { + return ts.getDirectoryPath(this.projectFilePath); + } + return ts.getDirectoryPath(ts.normalizeSlashes(this.externalProjectName)); + }; + ExternalProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ExternalProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ExternalProject.prototype.setTypingOptions = function (newTypingOptions) { + if (!newTypingOptions) { + newTypingOptions = { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; } else { - delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions); + if (newTypingOptions.enableAutoDiscovery === undefined) { + newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this); + } + if (!newTypingOptions.include) { + newTypingOptions.include = []; + } + if (!newTypingOptions.exclude) { + newTypingOptions.exclude = []; + } } - this.refreshInferredProjects(); + this.typingOptions = newTypingOptions; }; - return ProjectService; - }()); - server.ProjectService = ProjectService; + ExternalProject.prototype.getProjectName = function () { + return this.externalProjectName; + }; + return ExternalProject; + }(Project)); + server.ExternalProject = ExternalProject; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; (function (ts) { var server; (function (server) { - function hrTimeToMilliseconds(time) { - var seconds = time[0]; - var nanoseconds = time[1]; - return ((1e9 * seconds) + nanoseconds) / 1000000.0; - } - function shouldSkipSematicCheck(project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; + server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { + var map = ts.createMap(); + for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { + var option = commandLineOptions_1[_i]; + if (typeof option.type === "object") { + var optionMap = option.type; + for (var id in optionMap) { + ts.Debug.assert(typeof optionMap[id] === "number"); + } + map[option.name] = optionMap; + } } - if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { - return true; + return map; + } + var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); + var indentStyle = ts.createMap({ + "none": ts.IndentStyle.None, + "block": ts.IndentStyle.Block, + "smart": ts.IndentStyle.Smart + }); + function convertFormatOptions(protocolOptions) { + if (typeof protocolOptions.indentStyle === "string") { + protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + ts.Debug.assert(protocolOptions.indentStyle !== undefined); + } + return protocolOptions; + } + server.convertFormatOptions = convertFormatOptions; + function convertCompilerOptions(protocolOptions) { + for (var id in compilerOptionConverters) { + var propertyValue = protocolOptions[id]; + if (typeof propertyValue === "string") { + var mappedValues = compilerOptionConverters[id]; + protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + } + } + return protocolOptions; + } + server.convertCompilerOptions = convertCompilerOptions; + function tryConvertScriptKindName(scriptKindName) { + return typeof scriptKindName === "string" + ? convertScriptKindName(scriptKindName) + : scriptKindName; + } + server.tryConvertScriptKindName = tryConvertScriptKindName; + function convertScriptKindName(scriptKindName) { + switch (scriptKindName) { + case "JS": + return 1; + case "JSX": + return 2; + case "TS": + return 3; + case "TSX": + return 4; + default: + return 0; } - return false; } - function compareNumber(a, b) { - return a - b; + server.convertScriptKindName = convertScriptKindName; + function combineProjectOutput(projects, action, comparer, areEqual) { + var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); + return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; } - function compareFileStart(a, b) { - if (a.file < b.file) { - return -1; - } - else if (a.file == b.file) { - var n = compareNumber(a.start.line, b.start.line); - if (n === 0) { - return compareNumber(a.start.offset, b.start.offset); + server.combineProjectOutput = combineProjectOutput; + var fileNamePropertyReader = { + getFileName: function (x) { return x; }, + getScriptKind: function (_) { return undefined; }, + hasMixedContent: function (_) { return false; } + }; + var externalFilePropertyReader = { + getFileName: function (x) { return x.fileName; }, + getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, + hasMixedContent: function (x) { return x.hasMixedContent; } + }; + function findProjectByName(projectName, projects) { + for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { + var proj = projects_1[_i]; + if (proj.getProjectName() === projectName) { + return proj; } - else - return n; - } - else { - return 1; } } - function formatDiag(fileName, project, diag) { - var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); - return { - start: scriptInfo.positionToLineOffset(diag.start), - end: scriptInfo.positionToLineOffset(diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), - code: diag.code - }; - } - function formatConfigFileDiag(diag) { - return { - start: undefined, - end: undefined, - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") - }; + function createFileNotFoundDiagnostic(fileName) { + return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); } - function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; - if (ts.textSpanEnd(edit.span) >= pos) { - return false; - } + function isRootFileInInferredProject(info) { + if (info.containingProjects.length === 0) { + return false; } - return true; + return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); } - var CommandNames; - (function (CommandNames) { - CommandNames.Brace = "brace"; - CommandNames.BraceFull = "brace-full"; - CommandNames.BraceCompletion = "braceCompletion"; - CommandNames.Change = "change"; - CommandNames.Close = "close"; - CommandNames.Completions = "completions"; - CommandNames.CompletionsFull = "completions-full"; - CommandNames.CompletionDetails = "completionEntryDetails"; - CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - CommandNames.Configure = "configure"; - CommandNames.Definition = "definition"; - CommandNames.DefinitionFull = "definition-full"; - CommandNames.Exit = "exit"; - CommandNames.Format = "format"; - CommandNames.Formatonkey = "formatonkey"; - CommandNames.FormatFull = "format-full"; - CommandNames.FormatonkeyFull = "formatonkey-full"; - CommandNames.FormatRangeFull = "formatRange-full"; - CommandNames.Geterr = "geterr"; - CommandNames.GeterrForProject = "geterrForProject"; - CommandNames.Implementation = "implementation"; - CommandNames.ImplementationFull = "implementation-full"; - CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - CommandNames.NavBar = "navbar"; - CommandNames.NavBarFull = "navbar-full"; - CommandNames.NavTree = "navtree"; - CommandNames.NavTreeFull = "navtree-full"; - CommandNames.Navto = "navto"; - CommandNames.NavtoFull = "navto-full"; - CommandNames.Occurrences = "occurrences"; - CommandNames.DocumentHighlights = "documentHighlights"; - CommandNames.DocumentHighlightsFull = "documentHighlights-full"; - CommandNames.Open = "open"; - CommandNames.Quickinfo = "quickinfo"; - CommandNames.QuickinfoFull = "quickinfo-full"; - CommandNames.References = "references"; - CommandNames.ReferencesFull = "references-full"; - CommandNames.Reload = "reload"; - CommandNames.Rename = "rename"; - CommandNames.RenameInfoFull = "rename-full"; - CommandNames.RenameLocationsFull = "renameLocations-full"; - CommandNames.Saveto = "saveto"; - CommandNames.SignatureHelp = "signatureHelp"; - CommandNames.SignatureHelpFull = "signatureHelp-full"; - CommandNames.TypeDefinition = "typeDefinition"; - CommandNames.ProjectInfo = "projectInfo"; - CommandNames.ReloadProjects = "reloadProjects"; - CommandNames.Unknown = "unknown"; - CommandNames.OpenExternalProject = "openExternalProject"; - CommandNames.OpenExternalProjects = "openExternalProjects"; - CommandNames.CloseExternalProject = "closeExternalProject"; - CommandNames.SynchronizeProjectList = "synchronizeProjectList"; - CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - CommandNames.Cleanup = "cleanup"; - CommandNames.OutliningSpans = "outliningSpans"; - CommandNames.TodoComments = "todoComments"; - CommandNames.Indentation = "indentation"; - CommandNames.DocCommentTemplate = "docCommentTemplate"; - CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; - CommandNames.BreakpointStatement = "breakpointStatement"; - CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - CommandNames.GetCodeFixes = "getCodeFixes"; - CommandNames.GetCodeFixesFull = "getCodeFixes-full"; - CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; - })(CommandNames = server.CommandNames || (server.CommandNames = {})); - function formatMessage(msg, logger, byteLength, newLine) { - var verboseLogging = logger.hasLevel(server.LogLevel.verbose); - var json = JSON.stringify(msg); - if (verboseLogging) { - logger.info(msg.type + ": " + json); + var DirectoryWatchers = (function () { + function DirectoryWatchers(projectService) { + this.projectService = projectService; + this.directoryWatchersForTsconfig = ts.createMap(); + this.directoryWatchersRefCount = ts.createMap(); } - var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; - } - server.formatMessage = formatMessage; - var Session = (function () { - function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { - var _this = this; + DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchersRefCount[directory]--; + if (this.directoryWatchersRefCount[directory] === 0) { + this.projectService.logger.info("Close directory watcher for: " + directory); + this.directoryWatchersForTsconfig[directory].close(); + delete this.directoryWatchersForTsconfig[directory]; + } + }; + DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { + var currentPath = ts.getDirectoryPath(fileName); + var parentPath = ts.getDirectoryPath(currentPath); + while (currentPath != parentPath) { + if (!this.directoryWatchersForTsconfig[currentPath]) { + this.projectService.logger.info("Add watcher for: " + currentPath); + this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); + this.directoryWatchersRefCount[currentPath] = 1; + } + else { + this.directoryWatchersRefCount[currentPath] += 1; + } + project.directoriesWatchedForTsconfig.push(currentPath); + currentPath = parentPath; + parentPath = ts.getDirectoryPath(parentPath); + } + }; + return DirectoryWatchers; + }()); + var ProjectService = (function () { + function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { + if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } this.host = host; - this.typingsInstaller = typingsInstaller; - this.byteLength = byteLength; - this.hrtime = hrtime; this.logger = logger; - this.canUseEvents = canUseEvents; - this.changeSeq = 0; - this.handlers = ts.createMap((_a = {}, - _a[CommandNames.OpenExternalProject] = function (request) { - _this.projectService.openExternalProject(request.arguments); - return _this.requiredResponse(true); - }, - _a[CommandNames.OpenExternalProjects] = function (request) { - for (var _i = 0, _a = request.arguments.projects; _i < _a.length; _i++) { - var proj = _a[_i]; - _this.projectService.openExternalProject(proj); - } - return _this.requiredResponse(true); - }, - _a[CommandNames.CloseExternalProject] = function (request) { - _this.projectService.closeExternalProject(request.arguments.projectFileName); - return _this.requiredResponse(true); - }, - _a[CommandNames.SynchronizeProjectList] = function (request) { - var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); - if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { - return _this.requiredResponse(result); - } - var converted = ts.map(result, function (p) { - if (!p.projectErrors || p.projectErrors.length === 0) { - return p; - } - return { - info: p.info, - changes: p.changes, - files: p.files, - projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) - }; - }); - return _this.requiredResponse(converted); - }, - _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { - _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); - _this.changeSeq++; - return _this.requiredResponse(true); - }, - _a[CommandNames.Exit] = function () { - _this.exit(); - return _this.notRequired(); - }, - _a[CommandNames.Definition] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, true)); - }, - _a[CommandNames.DefinitionFull] = function (request) { - return _this.requiredResponse(_this.getDefinition(request.arguments, false)); - }, - _a[CommandNames.TypeDefinition] = function (request) { - return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); - }, - _a[CommandNames.Implementation] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, true)); - }, - _a[CommandNames.ImplementationFull] = function (request) { - return _this.requiredResponse(_this.getImplementation(request.arguments, false)); - }, - _a[CommandNames.References] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, true)); - }, - _a[CommandNames.ReferencesFull] = function (request) { - return _this.requiredResponse(_this.getReferences(request.arguments, false)); - }, - _a[CommandNames.Rename] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); - }, - _a[CommandNames.RenameLocationsFull] = function (request) { - return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); - }, - _a[CommandNames.RenameInfoFull] = function (request) { - return _this.requiredResponse(_this.getRenameInfo(request.arguments)); - }, - _a[CommandNames.Open] = function (request) { - var openArgs = request.arguments; - var scriptKind; - switch (openArgs.scriptKindName) { - case "TS": - scriptKind = 3; - break; - case "JS": - scriptKind = 1; - break; - case "TSX": - scriptKind = 4; - break; - case "JSX": - scriptKind = 2; - break; - } - _this.openClientFile(server.toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind); - return _this.notRequired(); - }, - _a[CommandNames.Quickinfo] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); - }, - _a[CommandNames.QuickinfoFull] = function (request) { - return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); - }, - _a[CommandNames.OutliningSpans] = function (request) { - return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); - }, - _a[CommandNames.TodoComments] = function (request) { - return _this.requiredResponse(_this.getTodoComments(request.arguments)); - }, - _a[CommandNames.Indentation] = function (request) { - return _this.requiredResponse(_this.getIndentation(request.arguments)); - }, - _a[CommandNames.NameOrDottedNameSpan] = function (request) { - return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); - }, - _a[CommandNames.BreakpointStatement] = function (request) { - return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); - }, - _a[CommandNames.BraceCompletion] = function (request) { - return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); - }, - _a[CommandNames.DocCommentTemplate] = function (request) { - return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); - }, - _a[CommandNames.Format] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); - }, - _a[CommandNames.Formatonkey] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); - }, - _a[CommandNames.FormatFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); - }, - _a[CommandNames.FormatonkeyFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); - }, - _a[CommandNames.FormatRangeFull] = function (request) { - return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); - }, - _a[CommandNames.Completions] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, true)); - }, - _a[CommandNames.CompletionsFull] = function (request) { - return _this.requiredResponse(_this.getCompletions(request.arguments, false)); - }, - _a[CommandNames.CompletionDetails] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); - }, - _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { - return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); - }, - _a[CommandNames.CompileOnSaveEmitFile] = function (request) { - return _this.requiredResponse(_this.emitFile(request.arguments)); - }, - _a[CommandNames.SignatureHelp] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); - }, - _a[CommandNames.SignatureHelpFull] = function (request) { - return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { - return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); - }, - _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { - return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); - }, - _a[CommandNames.Cleanup] = function (request) { - _this.cleanup(); - return _this.requiredResponse(true); - }, - _a[CommandNames.SemanticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { - return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); - }, - _a[CommandNames.Geterr] = function (request) { - var geterrArgs = request.arguments; - return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; - }, - _a[CommandNames.GeterrForProject] = function (request) { - var _a = request.arguments, file = _a.file, delay = _a.delay; - return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; - }, - _a[CommandNames.Change] = function (request) { - _this.change(request.arguments); - return _this.notRequired(); - }, - _a[CommandNames.Configure] = function (request) { - _this.projectService.setHostConfiguration(request.arguments); - _this.output(undefined, CommandNames.Configure, request.seq); - return _this.notRequired(); - }, - _a[CommandNames.Reload] = function (request) { - _this.reload(request.arguments, request.seq); - return _this.requiredResponse({ reloadFinished: true }); - }, - _a[CommandNames.Saveto] = function (request) { - var savetoArgs = request.arguments; - _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return _this.notRequired(); - }, - _a[CommandNames.Close] = function (request) { - var closeArgs = request.arguments; - _this.closeClientFile(closeArgs.file); - return _this.notRequired(); - }, - _a[CommandNames.Navto] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); - }, - _a[CommandNames.NavtoFull] = function (request) { - return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); - }, - _a[CommandNames.Brace] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); - }, - _a[CommandNames.BraceFull] = function (request) { - return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); - }, - _a[CommandNames.NavBar] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); - }, - _a[CommandNames.NavBarFull] = function (request) { - return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); - }, - _a[CommandNames.NavTree] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); - }, - _a[CommandNames.NavTreeFull] = function (request) { - return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); - }, - _a[CommandNames.Occurrences] = function (request) { - return _this.requiredResponse(_this.getOccurrences(request.arguments)); - }, - _a[CommandNames.DocumentHighlights] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); - }, - _a[CommandNames.DocumentHighlightsFull] = function (request) { - return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); - }, - _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { - return _this.requiredResponse(_this.setCompilerOptionsForInferredProjects(request.arguments)); - }, - _a[CommandNames.ProjectInfo] = function (request) { - return _this.requiredResponse(_this.getProjectInfo(request.arguments)); - }, - _a[CommandNames.ReloadProjects] = function (request) { - _this.projectService.reloadProjects(); - return _this.notRequired(); - }, - _a[CommandNames.GetCodeFixes] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); - }, - _a[CommandNames.GetCodeFixesFull] = function (request) { - return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); - }, - _a[CommandNames.GetSupportedCodeFixes] = function (request) { - return _this.requiredResponse(_this.getSupportedCodeFixes()); - }, - _a)); - this.eventHander = canUseEvents - ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) - : undefined; - this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); - this.gcTimer = new server.GcTimer(host, 7000, logger); - var _a; + this.cancellationToken = cancellationToken; + this.useSingleInferredProject = useSingleInferredProject; + this.typingsInstaller = typingsInstaller; + this.eventHandler = eventHandler; + this.filenameToScriptInfo = ts.createFileMap(); + this.externalProjectToConfiguredProjectMap = ts.createMap(); + this.externalProjects = []; + this.inferredProjects = []; + this.configuredProjects = []; + this.openFiles = []; + this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.directoryWatchers = new DirectoryWatchers(this); + this.throttledOperations = new server.ThrottledOperations(host); + this.typingsInstaller.attach(this); + this.typingsCache = new server.TypingsCache(this.typingsInstaller); + this.hostConfiguration = { + formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + hostInfo: "Unknown host" + }; + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); } - Session.prototype.defaultEventHandler = function (event) { - var _this = this; - switch (event.eventName) { - case "context": - var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName); - this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); + ProjectService.prototype.getChangedFiles_TestOnly = function () { + return this.changedFiles; + }; + ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { + this.ensureInferredProjectsUpToDate(); + }; + ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { + return this.compilerOptionsForInferredProjects; + }; + ProjectService.prototype.updateTypingsForProject = function (response) { + var project = this.findProject(response.projectName); + if (!project) { + return; + } + switch (response.kind) { + case "set": + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); + project.updateGraph(); + break; + case "invalidate": + this.typingsCache.invalidateCachedTypingsForProject(project); break; - case "configFileDiag": - var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; - this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); } }; - Session.prototype.logError = function (err, cmd) { - var msg = "Exception on executing command " + cmd; - if (err.message) { - msg += ":\n" + err.message; - if (err.stack) { - msg += "\n" + err.stack; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { + this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); + this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + proj.setCompilerOptions(this.compilerOptionsForInferredProjects); + proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + } + this.updateProjectGraphs(this.inferredProjects); + }; + ProjectService.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchers.stopWatchingDirectory(directory); + }; + ProjectService.prototype.findProject = function (projectName) { + if (projectName === undefined) { + return undefined; + } + if (server.isInferredProjectName(projectName)) { + this.ensureInferredProjectsUpToDate(); + return findProjectByName(projectName, this.inferredProjects); + } + return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); + }; + ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { + if (refreshInferredProjects) { + this.ensureInferredProjectsUpToDate(); + } + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo && scriptInfo.getDefaultProject(); + }; + ProjectService.prototype.ensureInferredProjectsUpToDate = function () { + if (this.changedFiles) { + var projectsToUpdate = void 0; + if (this.changedFiles.length === 1) { + projectsToUpdate = this.changedFiles[0].containingProjects; + } + else { + projectsToUpdate = []; + for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { + var f = _a[_i]; + projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + } } + this.updateProjectGraphs(projectsToUpdate); + this.changedFiles = undefined; } - this.logger.msg(msg, server.Msg.Err); }; - Session.prototype.send = function (msg) { - if (msg.type === "event" && !this.canUseEvents) { - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + ProjectService.prototype.findContainingExternalProject = function (fileName) { + for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.containsFile(fileName)) { + return proj; + } + } + return undefined; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + var formatCodeSettings; + if (file) { + var info = this.getScriptInfoForNormalizedPath(file); + if (info) { + formatCodeSettings = info.getFormatCodeSettings(); + } + } + return formatCodeSettings || this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.updateProjectGraphs = function (projects) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { + var p = projects_2[_i]; + if (!p.updateGraph()) { + shouldRefreshInferredProjects = true; } + } + if (shouldRefreshInferredProjects) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onSourceFileChanged = function (fileName) { + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + this.logger.info("Error: got watch notification for unknown file: " + fileName); return; } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + if (!this.host.fileExists(fileName)) { + this.handleDeletedFile(info); + } + else { + if (info && (!info.isOpen)) { + info.reloadFromFile(); + this.updateProjectGraphs(info.containingProjects); + } + } }; - Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { - var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); - var ev = { - seq: 0, - type: "event", - event: "configFileDiag", - body: { - triggerFile: triggerFile, - configFile: configFile, - diagnostics: bakedDiags + ProjectService.prototype.handleDeletedFile = function (info) { + this.logger.info(info.fileName + " deleted"); + info.stopWatcher(); + if (!info.isOpen) { + this.filenameToScriptInfo.remove(info.path); + this.lastDeletedFile = info; + var containingProjects = info.containingProjects.slice(); + info.detachAllProjects(); + this.updateProjectGraphs(containingProjects); + this.lastDeletedFile = undefined; + if (!this.eventHandler) { + return; } - }; - this.send(ev); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var openFile = _a[_i]; + this.eventHandler({ eventName: "context", data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } }); + } + } + this.printProjects(); }; - Session.prototype.event = function (info, eventName) { - var ev = { - seq: 0, - type: "event", - event: eventName, - body: info - }; - this.send(ev); + ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { + var _this = this; + this.logger.info("Type root file " + fileName + " changed"); + this.throttledOperations.schedule(project.configFileName + " * type root", 250, function () { + project.updateTypes(); + _this.updateConfiguredProject(project); + _this.refreshInferredProjects(); + }); }; - Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { - if (reqSeq === void 0) { reqSeq = 0; } - var res = { - seq: 0, - type: "response", - command: cmdName, - request_seq: reqSeq, - success: !errorMsg - }; - if (!errorMsg) { - res.body = info; + ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { + var _this = this; + if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions())) { + return; + } + this.logger.info("Detected source file changes: " + fileName); + this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); + }; + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { + var _this = this; + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); + var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); + var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); + if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { + this.logger.info("Updating configured project"); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { + this.logger.info("Config file changed: " + project.configFileName); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + }; + ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { + if (ts.getBaseFileName(fileName) != "tsconfig.json") { + this.logger.info(fileName + " is not tsconfig.json"); + return; + } + var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; + this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); + this.logger.info("Detected newly added tsconfig file: " + fileName); + this.reloadProjects(); + }; + ProjectService.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + ProjectService.prototype.removeProject = function (project) { + this.logger.info("remove project: " + project.getRootFiles().toString()); + project.close(); + switch (project.projectKind) { + case server.ProjectKind.External: + server.removeItemFromSet(this.externalProjects, project); + break; + case server.ProjectKind.Configured: + server.removeItemFromSet(this.configuredProjects, project); + break; + case server.ProjectKind.Inferred: + server.removeItemFromSet(this.inferredProjects, project); + break; + } + }; + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + var externalProject = this.findContainingExternalProject(info.fileName); + if (externalProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + var foundConfiguredProject = false; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + foundConfiguredProject = true; + if (addToListOfOpenFiles) { + (p).addOpenRef(); + } + } + } + if (foundConfiguredProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + if (info.containingProjects.length === 0) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); + if (!this.useSingleInferredProject) { + for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { + var f = _c[_b]; + if (f.containingProjects.length === 0) { + continue; + } + var defaultProject = f.getDefaultProject(); + if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { + this.removeProject(defaultProject); + f.attachToProject(inferredProject); + } + } + } + } + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + }; + ProjectService.prototype.closeOpenFile = function (info) { + info.reloadFromFile(); + server.removeItemFromSet(this.openFiles, info); + info.isOpen = false; + var projectsToRemove; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + if (p.deleteOpenRef() === 0) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + if (projectsToRemove) { + for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { + var project = projectsToRemove_1[_b]; + this.removeProject(project); + } + var orphanFiles = void 0; + for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { + var f = _d[_c]; + if (f.containingProjects.length === 0) { + (orphanFiles || (orphanFiles = [])).push(f); + } + } + if (orphanFiles) { + for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { + var f = orphanFiles_1[_e]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + } + } + if (info.containingProjects.length === 0) { + this.filenameToScriptInfo.remove(info.path); + } + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + var searchPath = ts.getDirectoryPath(fileName); + this.logger.info("Search path: " + searchPath); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + if (!configFileName) { + this.logger.info("No config files found."); + return {}; + } + this.logger.info("Config file name: " + configFileName); + var project = this.findConfiguredProjectByProjectName(configFileName); + if (!project) { + var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; + if (!success) { + return { configFileName: configFileName, configFileErrors: errors }; + } + this.logger.info("Opened configuration file " + configFileName); + if (errors && errors.length > 0) { + return { configFileName: configFileName, configFileErrors: errors }; + } } else { - res.message = errorMsg; + this.updateConfiguredProject(project); } - this.send(res); + return { configFileName: configFileName }; }; - Session.prototype.semanticCheck = function (file, project) { - try { - var diags = []; - if (!shouldSkipSematicCheck(project)) { - diags = project.getLanguageService().getSemanticDiagnostics(file); + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; + } + var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; + } + var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.printProjects = function () { + if (!this.logger.hasLevel(server.LogLevel.verbose)) { + return; + } + this.logger.startGroup(); + var counter = 0; + counter = printProjects(this.logger, this.externalProjects, counter); + counter = printProjects(this.logger, this.configuredProjects, counter); + counter = printProjects(this.logger, this.inferredProjects, counter); + this.logger.info("Open files: "); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var rootFile = _a[_i]; + this.logger.info(rootFile.fileName); + } + this.logger.endGroup(); + function printProjects(logger, projects, counter) { + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var project = projects_3[_i]; + project.updateGraph(); + logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + logger.info(project.filesToString()); + logger.info("-----------------------------------------------"); + counter++; + } + return counter; + } + }; + ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { + return findProjectByName(configFileName, this.configuredProjects); + }; + ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { + return findProjectByName(projectFileName, this.externalProjects); + }; + ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { + configFilename = ts.normalizePath(configFilename); + var configFileContent = this.host.readFile(configFilename); + var errors; + var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); + var config = result.config; + if (result.error) { + var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; + config = sanitizedConfig; + errors = diagnostics.length ? diagnostics : [result.error]; + } + var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename); + if (parsedCommandLine.errors.length) { + errors = ts.concatenate(errors, parsedCommandLine.errors); + } + ts.Debug.assert(!!parsedCommandLine.fileNames); + if (parsedCommandLine.fileNames.length === 0) { + (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { success: false, configFileErrors: errors }; + } + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options, + configHasFilesProperty: config["files"] !== undefined, + wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), + typingOptions: parsedCommandLine.typingOptions, + compileOnSave: parsedCommandLine.compileOnSave + }; + return { success: true, projectOptions: projectOptions, configFileErrors: errors }; + }; + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + if (options && options.disableSizeLimit || !this.host.getFileSize) { + return false; + } + var totalNonTsFileSize = 0; + for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { + var f = fileNames_3[_i]; + var fileName = propertyReader.getFileName(f); + if (ts.hasTypeScriptFileExtension(fileName)) { + continue; + } + totalNonTsFileSize += this.host.getFileSize(fileName); + if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { + return true; + } + } + return false; + }; + ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { + var compilerOptions = convertCompilerOptions(options); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); + this.externalProjects.push(project); + return project; + }; + ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: "configFileDiag", + data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } + }); + }; + ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { + var _this = this; + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors); + project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); + if (!sizeLimitExceeded) { + this.watchConfigDirectoryForProject(project, projectOptions); + } + project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); + this.configuredProjects.push(project); + return project; + }; + ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { + var _this = this; + if (!options.configHasFilesProperty) { + project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + } + }; + ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typingOptions, configFileErrors) { + var errors; + for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { + var f = files_4[_i]; + var rootFilename = propertyReader.getFileName(f); + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + if (this.host.fileExists(rootFilename)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + } + } + project.setProjectErrors(ts.concatenate(configFileErrors, errors)); + project.setTypingOptions(typingOptions); + project.updateGraph(); + }; + ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { + var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); + var projectOptions = conversionResult.success + ? conversionResult.projectOptions + : { files: [], compilerOptions: {} }; + var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); + return { + success: conversionResult.success, + project: project, + errors: project.getProjectErrors() + }; + }; + ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors) { + var oldRootScriptInfos = project.getRootScriptInfos(); + var newRootScriptInfos = []; + var newRootScriptInfoMap = server.createNormalizedPathMap(); + var projectErrors; + var rootFilesChanged = false; + for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { + var f = newUncheckedFiles_1[_i]; + var newRootFile = propertyReader.getFileName(f); + if (!this.host.fileExists(newRootFile)) { + (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); + continue; + } + var normalizedPath = server.toNormalizedPath(newRootFile); + var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); + if (!scriptInfo || !project.isRoot(scriptInfo)) { + rootFilesChanged = true; + if (!scriptInfo) { + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + } } - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); - } - catch (err) { - this.logError(err, "semantic check"); + newRootScriptInfos.push(scriptInfo); + newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); } - }; - Session.prototype.syntacticCheck = function (file, project) { - try { - var diags = project.getLanguageService().getSyntacticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); + if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { + var toAdd = void 0; + var toRemove = void 0; + for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { + var oldFile = oldRootScriptInfos_1[_a]; + if (!newRootScriptInfoMap.contains(oldFile.fileName)) { + (toRemove || (toRemove = [])).push(oldFile); + } } - } - catch (err) { - this.logError(err, "syntactic check"); - } - }; - Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { - var _this = this; - if (ms === void 0) { ms = 1500; } - this.host.setTimeout(function () { - if (matchSeq(seq)) { - _this.projectService.refreshInferredProjects(); + for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { + var newFile = newRootScriptInfos_1[_b]; + if (!project.isRoot(newFile)) { + (toAdd || (toAdd = [])).push(newFile); + } } - }, ms); - }; - Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { - var _this = this; - if (ms === void 0) { ms = 1500; } - if (followMs === void 0) { followMs = 200; } - if (requireOpen === void 0) { requireOpen = true; } - if (followMs > ms) { - followMs = ms; - } - if (this.errorTimer) { - this.host.clearTimeout(this.errorTimer); - } - if (this.immediateId) { - this.host.clearImmediate(this.immediateId); - this.immediateId = undefined; - } - var index = 0; - var checkOne = function () { - if (matchSeq(seq)) { - var checkSpec_1 = checkList[index]; - index++; - if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { - _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = _this.host.setImmediate(function () { - _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = undefined; - if (checkList.length > index) { - _this.errorTimer = _this.host.setTimeout(checkOne, followMs); - } - else { - _this.errorTimer = undefined; + if (toRemove) { + for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { + var f = toRemove_1[_c]; + project.removeFile(f); + } + } + if (toAdd) { + for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { + var f = toAdd_1[_d]; + if (f.isOpen && isRootFileInInferredProject(f)) { + var inferredProject = f.containingProjects[0]; + inferredProject.removeFile(f); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); } - }); + } + project.addRoot(f); } } - }; - if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = this.host.setTimeout(checkOne, ms); } + project.setCompilerOptions(newOptions); + project.setTypingOptions(newTypingOptions); + if (compileOnSave !== undefined) { + project.compileOnSaveEnabled = compileOnSave; + } + project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); + project.updateGraph(); }; - Session.prototype.cleanProjects = function (caption, projects) { - if (!projects) { + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.configFileName)) { + this.logger.info("Config file deleted"); + this.removeProject(project); return; } - this.logger.info("cleaning " + caption); - for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { - var p = projects_4[_i]; - p.getLanguageService(false).cleanupSemanticCache(); + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + if (!success) { + this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); + return configFileErrors; } - }; - Session.prototype.cleanup = function () { - this.cleanProjects("inferred projects", this.projectService.inferredProjects); - this.cleanProjects("configured projects", this.projectService.configuredProjects); - this.cleanProjects("external projects", this.projectService.externalProjects); - if (this.host.gc) { - this.logger.info("host.gc()"); - this.host.gc(); + if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + project.setCompilerOptions(projectOptions.compilerOptions); + if (!project.languageServiceEnabled) { + return; + } + project.disableLanguageService(); + project.stopWatchingDirectory(); + } + else { + if (!project.languageServiceEnabled) { + project.enableLanguageService(); + } + this.watchConfigDirectoryForProject(project, projectOptions); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors); } }; - Session.prototype.getEncodedSemanticClassifications = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEncodedSemanticClassifications(file, args); + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + var _this = this; + var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; + var project = useExistingProject + ? this.inferredProjects[0] + : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); + project.addRoot(root); + this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); + project.updateGraph(); + if (!useExistingProject) { + this.inferredProjects.push(project); + } + return project; }; - Session.prototype.getProject = function (projectFileName) { - return projectFileName && this.projectService.findProject(projectFileName); + ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { + return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); }; - Session.prototype.getCompilerOptionsDiagnostics = function (args) { - var project = this.getProject(args.projectFileName); - return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); + ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); }; - Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { var _this = this; - return diagnostics.map(function (d) { return ({ - message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), - start: d.start, - length: d.length, - category: ts.DiagnosticCategory[d.category].toLowerCase(), - code: d.code, - startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), - endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) - }); }); - }; - Session.prototype.getDiagnosticsWorker = function (args, selector, includeLinePosition) { - var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (shouldSkipSematicCheck(project)) { - return []; - } - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var diagnostics = selector(project, file); - return includeLinePosition - ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) - : diagnostics.map(function (d) { return formatDiag(file, project, d); }); - }; - Session.prototype.getDefinition = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - if (simplifiedResult) { - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + var content = void 0; + if (this.host.fileExists(fileName)) { + content = fileContent || (hasMixedContent ? "" : this.host.readFile(fileName)); + } + if (!content) { + if (openedByClient) { + content = ""; + } + } + if (content !== undefined) { + info = new server.ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent); + this.filenameToScriptInfo.set(info.path, info); + if (!info.isOpen && !hasMixedContent) { + info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); + } + } } - else { - return definitions; + if (info) { + if (fileContent !== undefined) { + info.reload(fileContent); + } + if (openedByClient) { + info.isOpen = true; + } } + return info; }; - Session.prototype.getTypeDefinition = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); - if (!definitions) { - return undefined; - } - return definitions.map(function (def) { - var defScriptInfo = project.getScriptInfo(def.fileName); - return { - file: def.fileName, - start: defScriptInfo.positionToLineOffset(def.textSpan.start), - end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) - }; - }); + ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { + return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); }; - Session.prototype.getImplementation = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var implementations = project.getLanguageService().getImplementationAtPosition(file, position); - if (!implementations) { - return []; - } - if (simplifiedResult) { - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: scriptInfo.positionToLineOffset(impl.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) - }); }); + ProjectService.prototype.getScriptInfoForPath = function (fileName) { + return this.filenameToScriptInfo.get(fileName); + }; + ProjectService.prototype.setHostConfiguration = function (args) { + if (args.file) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); + if (info) { + info.setFormatOptions(convertFormatOptions(args.formatOptions)); + this.logger.info("Host configuration update for file " + args.file); + } } else { - return implementations; - } - }; - Session.prototype.getOccurrences = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); - if (!occurrences) { - return undefined; + if (args.hostInfo !== undefined) { + this.hostConfiguration.hostInfo = args.hostInfo; + this.logger.info("Host information " + args.hostInfo); + } + if (args.formatOptions) { + server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.logger.info("Format host information updated"); + } } - return occurrences.map(function (occurrence) { - var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; - var scriptInfo = project.getScriptInfo(fileName); - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { - start: start, - end: end, - file: fileName, - isWriteAccess: isWriteAccess - }; - }); - }; - Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; - Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + ProjectService.prototype.closeLog = function () { + this.logger.close(); }; - Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); - if (!documentHighlights) { - return undefined; + ProjectService.prototype.reloadProjects = function () { + this.logger.info("reload projects."); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); } - if (simplifiedResult) { - return documentHighlights.map(convertToDocumentHighlightsItem); + this.refreshInferredProjects(); + }; + ProjectService.prototype.refreshInferredProjects = function () { + this.logger.info("updating project structure from ..."); + this.printProjects(); + var orphantedFiles = []; + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + if (info.containingProjects.length === 0) { + orphantedFiles.push(info); + } + else { + if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { + var inferredProject = info.containingProjects[0]; + ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); + inferredProject.removeFile(info); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + } } - else { - return documentHighlights; + for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { + var f = orphantedFiles_1[_b]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); } - function convertToDocumentHighlightsItem(documentHighlights) { - var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; - var scriptInfo = project.getScriptInfo(fileName); - return { - file: fileName, - highlightSpans: highlightSpans.map(convertHighlightSpan) - }; - function convertHighlightSpan(highlightSpan) { - var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; - var start = scriptInfo.positionToLineOffset(textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { start: start, end: end, kind: kind }; - } + for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { + var p = _d[_c]; + p.updateGraph(); } + this.printProjects(); }; - Session.prototype.setCompilerOptionsForInferredProjects = function (args) { - this.projectService.setCompilerOptionsForInferredProjects(args.options); + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); }; - Session.prototype.getProjectInfo = function (args) { - return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + var _a = this.findContainingExternalProject(fileName) + ? {} + : this.openOrUpdateConfiguredProjectForFile(fileName), _b = _a.configFileName, configFileName = _b === void 0 ? undefined : _b, _c = _a.configFileErrors, configFileErrors = _c === void 0 ? undefined : _c; + var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); + this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.printProjects(); + return { configFileName: configFileName, configFileErrors: configFileErrors }; }; - Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { - var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; - var projectInfo = { - configFileName: project.getProjectName(), - languageServiceDisabled: !project.languageServiceEnabled, - fileNames: needFileNameList ? project.getFileNames() : undefined + ProjectService.prototype.closeClientFile = function (uncheckedFileName) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + if (info) { + this.closeOpenFile(info); + info.isOpen = false; + } + this.printProjects(); + }; + ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { + var _loop_3 = function (proj) { + var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; - return projectInfo; + for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { + var proj = currentProjects_1[_i]; + _loop_3(proj); + } }; - Session.prototype.getRenameInfo = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return project.getLanguageService().getRenameInfo(file, position); + ProjectService.prototype.synchronizeProjectList = function (knownProjects) { + var files = []; + this.collectChanges(knownProjects, this.externalProjects, files); + this.collectChanges(knownProjects, this.configuredProjects, files); + this.collectChanges(knownProjects, this.inferredProjects, files); + return files; }; - Session.prototype.getProjects = function (args) { - var projects; - if (args.projectFileName) { - var project = this.getProject(args.projectFileName); - if (project) { - projects = [project]; + ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { + var recordChangedFiles = changedFiles && !openFiles && !closedFiles; + if (openFiles) { + for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { + var file = openFiles_1[_i]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); + var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); } } - else { - var scriptInfo = this.projectService.getScriptInfo(args.file); - projects = scriptInfo.containingProjects; - } - projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); - if (!projects || !projects.length) { - return server.Errors.ThrowNoProject(); - } - return projects; - }; - Session.prototype.getRenameLocations = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var info = this.projectService.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, info); - var projects = this.getProjects(args); - if (simplifiedResult) { - var defaultProject = projects[0]; - var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; - } - var fileSpans = server.combineProjectOutput(projects, function (project) { - var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); - if (!renameLocations) { - return []; + if (changedFiles) { + for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { + var file = changedFiles_1[_a]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!!scriptInfo); + for (var i = file.changes.length - 1; i >= 0; i--) { + var change = file.changes[i]; + scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); } - return renameLocations.map(function (location) { - var locationScriptInfo = project.getScriptInfo(location.fileName); - return { - file: location.fileName, - start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)) - }; - }); - }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); - var locs = fileSpans.reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; + if (recordChangedFiles) { + if (!this.changedFiles) { + this.changedFiles = [scriptInfo]; + } + else if (this.changedFiles.indexOf(scriptInfo) < 0) { + this.changedFiles.push(scriptInfo); } } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); - } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: locs }; + } + } + if (closedFiles) { + for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { + var file = closedFiles_1[_b]; + this.closeClientFile(file); + } + } + if (openFiles || closedFiles) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.closeConfiguredProject = function (configFile) { + var configuredProject = this.findConfiguredProjectByProjectName(configFile); + if (configuredProject && configuredProject.deleteOpenRef() === 0) { + this.removeProject(configuredProject); + } + }; + ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { + if (suppressRefresh === void 0) { suppressRefresh = false; } + var fileName = server.toNormalizedPath(uncheckedFileName); + var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + if (configFiles) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { + var configFile = configFiles_1[_i]; + if (this.closeConfiguredProject(configFile)) { + shouldRefreshInferredProjects = true; + } + } + delete this.externalProjectToConfiguredProjectMap[fileName]; + if (shouldRefreshInferredProjects && !suppressRefresh) { + this.refreshInferredProjects(); + } } else { - return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); + var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); + if (externalProject) { + this.removeProject(externalProject); + if (!suppressRefresh) { + this.refreshInferredProjects(); + } + } } - function renameLocationIsEqualTo(a, b) { - if (a === b) { - return true; + }; + ProjectService.prototype.openExternalProject = function (proj) { + var tsConfigFiles; + var rootFiles = []; + for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { + var file = _a[_i]; + var normalized = server.toNormalizedPath(file.fileName); + if (ts.getBaseFileName(normalized) === "tsconfig.json") { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); } - if (!a || !b) { - return false; + else { + rootFiles.push(file); } - return a.fileName === b.fileName && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; } - function compareRenameLocation(a, b) { - if (a.file < b.file) { - return -1; + if (tsConfigFiles) { + tsConfigFiles.sort(); + } + var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); + var exisingConfigFiles; + if (externalProject) { + if (!tsConfigFiles) { + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, undefined); + return; } - else if (a.file > b.file) { - return 1; + this.closeExternalProject(proj.projectFileName, true); + } + else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + if (!tsConfigFiles) { + this.closeExternalProject(proj.projectFileName, true); } else { - if (a.start.line < b.start.line) { - return 1; - } - else if (a.start.line > b.start.line) { - return -1; + var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + var iNew = 0; + var iOld = 0; + while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { + var newConfig = tsConfigFiles[iNew]; + var oldConfig = oldConfigFiles[iOld]; + if (oldConfig < newConfig) { + this.closeConfiguredProject(oldConfig); + iOld++; + } + else if (oldConfig > newConfig) { + iNew++; + } + else { + (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); + iOld++; + iNew++; + } } - else { - return b.start.offset - a.start.offset; + for (var i = iOld; i < oldConfigFiles.length; i++) { + this.closeConfiguredProject(oldConfigFiles[i]); } } } - }; - Session.prototype.getReferences = function (args, simplifiedResult) { - var file = server.toNormalizedPath(args.file); - var projects = this.getProjects(args); - var defaultProject = projects[0]; - var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - if (simplifiedResult) { - var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; - var nameText = scriptInfo.snap().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var refs = server.combineProjectOutput(projects, function (project) { - var references = project.getLanguageService().getReferencesAtPosition(file, position); - if (!references) { - return []; + if (tsConfigFiles) { + this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { + var tsconfigFile = tsConfigFiles_1[_b]; + var project = this.findConfiguredProjectByProjectName(tsconfigFile); + if (!project) { + var result = this.openConfigFile(tsconfigFile); + project = result.success && result.project; + } + if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { + project.addOpenRef(); } - return references.map(function (ref) { - var refScriptInfo = project.getScriptInfo(ref.fileName); - var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); - var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); - var lineText = refScriptInfo.snap().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start: start, - lineText: lineText, - end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess, - isDefinition: ref.isDefinition - }; - }); - }, compareFileStart, areReferencesResponseItemsForTheSameLocation); - return { - refs: refs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; - } - else { - return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); - } - function areReferencesResponseItemsForTheSameLocation(a, b) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; } - return false; } - }; - Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - if (this.eventHander) { - this.eventHander({ - eventName: "configFileDiag", - data: { fileName: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } - }); + else { + delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions); } + this.refreshInferredProjects(); }; - Session.prototype.getPosition = function (args, scriptInfo) { - return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); - }; - Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { - if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } - return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); - }; - Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { - if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } - return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); - }; - Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { - var file = server.toNormalizedPath(uncheckedFileName); - var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); - if (!project && errorOnMissingProject) { - return server.Errors.ThrowNoProject(); + return ProjectService; + }()); + server.ProjectService = ProjectService; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + function hrTimeToMilliseconds(time) { + var seconds = time[0]; + var nanoseconds = time[1]; + return ((1e9 * seconds) + nanoseconds) / 1000000.0; + } + function shouldSkipSematicCheck(project) { + if (project.getCompilerOptions().skipLibCheck !== undefined) { + return false; + } + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { + return true; + } + return false; + } + function compareNumber(a, b) { + return a - b; + } + function compareFileStart(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file == b.file) { + var n = compareNumber(a.start.line, b.start.line); + if (n === 0) { + return compareNumber(a.start.offset, b.start.offset); } - return { file: file, project: project }; - }; - Session.prototype.getOutliningSpans = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - return project.getLanguageService(false).getOutliningSpans(file); - }; - Session.prototype.getTodoComments = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getTodoComments(file, args.descriptors); - }; - Session.prototype.getDocCommentTemplate = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); - }; - Session.prototype.getIndentation = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - var options = args.options || this.projectService.getFormatCodeOptions(file); - var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); - return { position: position, indentation: indentation }; - }; - Session.prototype.getBreakpointStatement = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); - }; - Session.prototype.getNameOrDottedNameSpan = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); + else + return n; + } + else { + return 1; + } + } + function formatDiag(fileName, project, diag) { + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); + return { + start: scriptInfo.positionToLineOffset(diag.start), + end: scriptInfo.positionToLineOffset(diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + code: diag.code }; - Session.prototype.isValidBraceCompletion = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); + } + function formatConfigFileDiag(diag) { + return { + start: undefined, + end: undefined, + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") }; - Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); - if (!quickInfo) { - return undefined; - } - if (simplifiedResult) { - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); - return { - kind: quickInfo.kind, - kindModifiers: quickInfo.kindModifiers, - start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), - displayString: displayString, - documentation: docString - }; - } - else { - return quickInfo; + } + function allEditsBeforePos(edits, pos) { + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var edit = edits_1[_i]; + if (ts.textSpanEnd(edit.span) >= pos) { + return false; } - }; - Session.prototype.getFormattingEditsForRange = function (args) { + } + return true; + } + var CommandNames; + (function (CommandNames) { + CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; + CommandNames.Exit = "exit"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; + CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; + CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; + CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; + CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; + CommandNames.Saveto = "saveto"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; + CommandNames.TypeDefinition = "typeDefinition"; + CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; + CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); + function formatMessage(msg, logger, byteLength, newLine) { + var verboseLogging = logger.hasLevel(server.LogLevel.verbose); + var json = JSON.stringify(msg); + if (verboseLogging) { + logger.info(msg.type + ": " + json); + } + var len = byteLength(json, "utf8"); + return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + } + server.formatMessage = formatMessage; + var Session = (function () { + function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { + var _this = this; + this.host = host; + this.typingsInstaller = typingsInstaller; + this.byteLength = byteLength; + this.hrtime = hrtime; + this.logger = logger; + this.canUseEvents = canUseEvents; + this.changeSeq = 0; + this.handlers = ts.createMap((_a = {}, + _a[CommandNames.OpenExternalProject] = function (request) { + _this.projectService.openExternalProject(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.OpenExternalProjects] = function (request) { + for (var _i = 0, _a = request.arguments.projects; _i < _a.length; _i++) { + var proj = _a[_i]; + _this.projectService.openExternalProject(proj); + } + return _this.requiredResponse(true); + }, + _a[CommandNames.CloseExternalProject] = function (request) { + _this.projectService.closeExternalProject(request.arguments.projectFileName); + return _this.requiredResponse(true); + }, + _a[CommandNames.SynchronizeProjectList] = function (request) { + var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); + if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { + return _this.requiredResponse(result); + } + var converted = ts.map(result, function (p) { + if (!p.projectErrors || p.projectErrors.length === 0) { + return p; + } + return { + info: p.info, + changes: p.changes, + files: p.files, + projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) + }; + }); + return _this.requiredResponse(converted); + }, + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); + _this.changeSeq++; + return _this.requiredResponse(true); + }, + _a[CommandNames.Exit] = function () { + _this.exit(); + return _this.notRequired(); + }, + _a[CommandNames.Definition] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, true)); + }, + _a[CommandNames.DefinitionFull] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, false)); + }, + _a[CommandNames.TypeDefinition] = function (request) { + return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); + }, + _a[CommandNames.Implementation] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, true)); + }, + _a[CommandNames.ImplementationFull] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, false)); + }, + _a[CommandNames.References] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, true)); + }, + _a[CommandNames.ReferencesFull] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, false)); + }, + _a[CommandNames.Rename] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); + }, + _a[CommandNames.RenameLocationsFull] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); + }, + _a[CommandNames.RenameInfoFull] = function (request) { + return _this.requiredResponse(_this.getRenameInfo(request.arguments)); + }, + _a[CommandNames.Open] = function (request) { + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + return _this.notRequired(); + }, + _a[CommandNames.Quickinfo] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); + }, + _a[CommandNames.QuickinfoFull] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); + }, + _a[CommandNames.OutliningSpans] = function (request) { + return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); + }, + _a[CommandNames.TodoComments] = function (request) { + return _this.requiredResponse(_this.getTodoComments(request.arguments)); + }, + _a[CommandNames.Indentation] = function (request) { + return _this.requiredResponse(_this.getIndentation(request.arguments)); + }, + _a[CommandNames.NameOrDottedNameSpan] = function (request) { + return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); + }, + _a[CommandNames.BreakpointStatement] = function (request) { + return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); + }, + _a[CommandNames.BraceCompletion] = function (request) { + return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); + }, + _a[CommandNames.DocCommentTemplate] = function (request) { + return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); + }, + _a[CommandNames.Format] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); + }, + _a[CommandNames.Formatonkey] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); + }, + _a[CommandNames.FormatFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); + }, + _a[CommandNames.FormatonkeyFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); + }, + _a[CommandNames.FormatRangeFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); + }, + _a[CommandNames.Completions] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + }, + _a[CommandNames.CompletionsFull] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, false)); + }, + _a[CommandNames.CompletionDetails] = function (request) { + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); + }, + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { + return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); + }, + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { + return _this.requiredResponse(_this.emitFile(request.arguments)); + }, + _a[CommandNames.SignatureHelp] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); + }, + _a[CommandNames.SignatureHelpFull] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); + }, + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { + return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); + }, + _a[CommandNames.Cleanup] = function () { + _this.cleanup(); + return _this.requiredResponse(true); + }, + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { + return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); + }, + _a[CommandNames.Geterr] = function (request) { + var geterrArgs = request.arguments; + return { response: _this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false }; + }, + _a[CommandNames.GeterrForProject] = function (request) { + var _a = request.arguments, file = _a.file, delay = _a.delay; + return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; + }, + _a[CommandNames.Change] = function (request) { + _this.change(request.arguments); + return _this.notRequired(); + }, + _a[CommandNames.Configure] = function (request) { + _this.projectService.setHostConfiguration(request.arguments); + _this.output(undefined, CommandNames.Configure, request.seq); + return _this.notRequired(); + }, + _a[CommandNames.Reload] = function (request) { + _this.reload(request.arguments, request.seq); + return _this.requiredResponse({ reloadFinished: true }); + }, + _a[CommandNames.Saveto] = function (request) { + var savetoArgs = request.arguments; + _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + return _this.notRequired(); + }, + _a[CommandNames.Close] = function (request) { + var closeArgs = request.arguments; + _this.closeClientFile(closeArgs.file); + return _this.notRequired(); + }, + _a[CommandNames.Navto] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); + }, + _a[CommandNames.NavtoFull] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); + }, + _a[CommandNames.Brace] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); + }, + _a[CommandNames.BraceFull] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); + }, + _a[CommandNames.NavBar] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); + }, + _a[CommandNames.NavBarFull] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); + }, + _a[CommandNames.NavTree] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); + }, + _a[CommandNames.NavTreeFull] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); + }, + _a[CommandNames.Occurrences] = function (request) { + return _this.requiredResponse(_this.getOccurrences(request.arguments)); + }, + _a[CommandNames.DocumentHighlights] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); + }, + _a[CommandNames.DocumentHighlightsFull] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { + _this.setCompilerOptionsForInferredProjects(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.ProjectInfo] = function (request) { + return _this.requiredResponse(_this.getProjectInfo(request.arguments)); + }, + _a[CommandNames.ReloadProjects] = function () { + _this.projectService.reloadProjects(); + return _this.notRequired(); + }, + _a[CommandNames.GetCodeFixes] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); + }, + _a[CommandNames.GetCodeFixesFull] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); + }, + _a[CommandNames.GetSupportedCodeFixes] = function () { + return _this.requiredResponse(_this.getSupportedCodeFixes()); + }, + _a)); + this.eventHander = canUseEvents + ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + : undefined; + this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.gcTimer = new server.GcTimer(host, 7000, logger); + var _a; + } + Session.prototype.defaultEventHandler = function (event) { var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); - if (!edits) { - return undefined; + switch (event.eventName) { + case "context": + var _a = event.data, project = _a.project, fileName = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName); + this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); + break; + case "configFileDiag": + var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; + this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); } - return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); }; - Session.prototype.getFormattingEditsForRangeFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); - }; - Session.prototype.getFormattingEditsForDocumentFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsForDocument(file, options); - }; - Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); - return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); - }; - Session.prototype.getFormattingEditsAfterKeystroke = function (args) { - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var formatOptions = this.projectService.getFormatCodeOptions(file); - var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); - if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { - var lineInfo = scriptInfo.getLineInfo(args.line); - if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; - if (lineText.search("\\S") < 0) { - var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); - var hasIndent = 0; - var i = void 0, len = void 0; - for (i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { - hasIndent++; - } - else if (lineText.charAt(i) == "\t") { - hasIndent += formatOptions.tabSize; - } - else { - break; - } - } - if (preferredIndent !== hasIndent) { - var firstNoWhiteSpacePosition = lineInfo.offset + i; - edits.push({ - span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), - newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) - }); - } - } + Session.prototype.logError = function (err, cmd) { + var msg = "Exception on executing command " + cmd; + if (err.message) { + msg += ":\n" + err.message; + if (err.stack) { + msg += "\n" + err.stack; } } - if (!edits) { - return undefined; - } - return edits.map(function (edit) { - return { - start: scriptInfo.positionToLineOffset(edit.span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); - }; - Session.prototype.getCompletions = function (args, simplifiedResult) { - var _this = this; - var prefix = args.prefix || ""; - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var completions = project.getLanguageService().getCompletionsAtPosition(file, position); - if (!completions) { - return undefined; - } - if (simplifiedResult) { - return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - 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_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); - } - return result; - }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); - } - else { - return completions; - } + this.logger.msg(msg, server.Msg.Err); }; - Session.prototype.getCompletionEntryDetails = function (args) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - return args.entryNames.reduce(function (accum, entryName) { - var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); - if (details) { - accum.push(details); + Session.prototype.send = function (msg) { + if (msg.type === "event" && !this.canUseEvents) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); } - return accum; - }, []); - }; - Session.prototype.getCompileOnSaveAffectedFileList = function (args) { - var info = this.projectService.getScriptInfo(args.file); - var result = []; - if (!info) { - return []; + return; } - var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; - for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { - var project = projectsToSearch_1[_i]; - if (project.compileOnSaveEnabled && project.languageServiceEnabled) { - result.push({ - projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info) - }); + this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + }; + Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { + var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); + var ev = { + seq: 0, + type: "event", + event: "configFileDiag", + body: { + triggerFile: triggerFile, + configFile: configFile, + diagnostics: bakedDiags } - } - return result; + }; + this.send(ev); }; - Session.prototype.emitFile = function (args) { - var _this = this; - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - if (!project) { - server.Errors.ThrowNoProject(); - } - var scriptInfo = project.getScriptInfo(file); - return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); + Session.prototype.event = function (info, eventName) { + var ev = { + seq: 0, + type: "event", + event: eventName, + body: info, + }; + this.send(ev); }; - Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var position = this.getPosition(args, scriptInfo); - var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); - if (!helpItems) { - return undefined; - } - if (simplifiedResult) { - var span_16 = helpItems.applicableSpan; - return { - items: helpItems.items, - applicableSpan: { - start: scriptInfo.positionToLineOffset(span_16.start), - end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount - }; + Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { + if (reqSeq === void 0) { reqSeq = 0; } + var res = { + seq: 0, + type: "response", + command: cmdName, + request_seq: reqSeq, + success: !errorMsg, + }; + if (!errorMsg) { + res.body = info; } else { - return helpItems; + res.message = errorMsg; } + this.send(res); }; - Session.prototype.getDiagnostics = function (delay, fileNames) { - var _this = this; - var checkList = fileNames.reduce(function (accum, uncheckedFileName) { - var fileName = server.toNormalizedPath(uncheckedFileName); - var project = _this.projectService.getDefaultProjectForFile(fileName, true); - if (project) { - accum.push({ fileName: fileName, project: project }); + Session.prototype.semanticCheck = function (file, project) { + try { + var diags = []; + if (!shouldSkipSematicCheck(project)) { + diags = project.getLanguageService().getSemanticDiagnostics(file); } - return accum; - }, []); - if (checkList.length > 0) { - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); } - }; - Session.prototype.change = function (args) { - var _this = this; - var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; - if (project) { - var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); - var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); - if (start >= 0) { - scriptInfo.editContent(start, end, args.insertString); - this.changeSeq++; - } - this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); + catch (err) { + this.logError(err, "semantic check"); } }; - Session.prototype.reload = function (args, reqSeq) { - var file = server.toNormalizedPath(args.file); - var project = this.projectService.getDefaultProjectForFile(file, true); - if (project) { - this.changeSeq++; - if (project.reloadScript(file)) { - this.output(undefined, CommandNames.Reload, reqSeq); + Session.prototype.syntacticCheck = function (file, project) { + try { + var diags = project.getLanguageService().getSyntacticDiagnostics(file); + if (diags) { + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); } } - }; - Session.prototype.saveToTmp = function (fileName, tempFileName) { - var scriptInfo = this.projectService.getScriptInfo(fileName); - if (scriptInfo) { - scriptInfo.saveTo(tempFileName); - } - }; - Session.prototype.closeClientFile = function (fileName) { - if (!fileName) { - return; + catch (err) { + this.logError(err, "syntactic check"); } - var file = ts.normalizePath(fileName); - this.projectService.closeClientFile(file); }; - Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { + Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { var _this = this; - return ts.map(items, function (item) { return ({ - text: item.text, - kind: item.kind, - kindModifiers: item.kindModifiers, - spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), - childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), - indent: item.indent - }); }); - }; - Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var items = project.getLanguageService(false).getNavigationBarItems(file); - return !items - ? undefined - : simplifiedResult - ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) - : items; + if (ms === void 0) { ms = 1500; } + this.host.setTimeout(function () { + if (matchSeq(seq)) { + _this.projectService.refreshInferredProjects(); + } + }, ms); }; - Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { + Session.prototype.updateErrorCheck = function (checkList, seq, matchSeq, ms, followMs, requireOpen) { var _this = this; - return { - text: tree.text, - kind: tree.kind, - kindModifiers: tree.kindModifiers, - spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), - childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) - }; - }; - Session.prototype.decorateSpan = function (span, scriptInfo) { - return { - start: scriptInfo.positionToLineOffset(span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) - }; - }; - Session.prototype.getNavigationTree = function (args, simplifiedResult) { - var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var tree = project.getLanguageService(false).getNavigationTree(file); - return !tree - ? undefined - : simplifiedResult - ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) - : tree; - }; - Session.prototype.getNavigateToItems = function (args, simplifiedResult) { - var projects = this.getProjects(args); - var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; - if (simplifiedResult) { - return server.combineProjectOutput(projects, function (project) { - var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); - if (!navItems) { - return []; - } - return navItems.map(function (navItem) { - var scriptInfo = project.getScriptInfo(navItem.fileName); - var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); - var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); - var bakedItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: start, - end: end - }; - if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }, undefined, areNavToItemsForTheSameLocation); + if (ms === void 0) { ms = 1500; } + if (followMs === void 0) { followMs = 200; } + if (requireOpen === void 0) { requireOpen = true; } + if (followMs > ms) { + followMs = ms; } - else { - return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); + if (this.errorTimer) { + this.host.clearTimeout(this.errorTimer); } - function navigateToItemIsEqualTo(a, b) { - if (a === b) { - return true; - } - if (!a || !b) { - return false; - } - return a.containerKind === b.containerKind && - a.containerName === b.containerName && - a.fileName === b.fileName && - a.isCaseSensitive === b.isCaseSensitive && - a.kind === b.kind && - a.kindModifiers === b.containerName && - a.matchKind === b.matchKind && - a.name === b.name && - a.textSpan.start === b.textSpan.start && - a.textSpan.length === b.textSpan.length; + if (this.immediateId) { + this.host.clearImmediate(this.immediateId); + this.immediateId = undefined; } - function areNavToItemsForTheSameLocation(a, b) { - if (a && b) { - return a.file === b.file && - a.start === b.start && - a.end === b.end; + var index = 0; + var checkOne = function () { + if (matchSeq(seq)) { + var checkSpec_1 = checkList[index]; + index++; + if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { + _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); + _this.immediateId = _this.host.setImmediate(function () { + _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); + _this.immediateId = undefined; + if (checkList.length > index) { + _this.errorTimer = _this.host.setTimeout(checkOne, followMs); + } + else { + _this.errorTimer = undefined; + } + }); + } } - return false; + }; + if ((checkList.length > index) && (matchSeq(seq))) { + this.errorTimer = this.host.setTimeout(checkOne, ms); + } + }; + Session.prototype.cleanProjects = function (caption, projects) { + if (!projects) { + return; + } + this.logger.info("cleaning " + caption); + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var p = projects_4[_i]; + p.getLanguageService(false).cleanupSemanticCache(); } }; - Session.prototype.getSupportedCodeFixes = function () { - return ts.getSupportedCodeFixes(); + Session.prototype.cleanup = function () { + this.cleanProjects("inferred projects", this.projectService.inferredProjects); + this.cleanProjects("configured projects", this.projectService.configuredProjects); + this.cleanProjects("external projects", this.projectService.externalProjects); + if (this.host.gc) { + this.logger.info("host.gc()"); + this.host.gc(); + } }; - Session.prototype.getCodeFixes = function (args, simplifiedResult) { + Session.prototype.getEncodedSemanticClassifications = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getEncodedSemanticClassifications(file, args); + }; + Session.prototype.getProject = function (projectFileName) { + return projectFileName && this.projectService.findProject(projectFileName); + }; + Session.prototype.getCompilerOptionsDiagnostics = function (args) { + var project = this.getProject(args.projectFileName); + return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); + }; + Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + return diagnostics.map(function (d) { return ({ + message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), + start: d.start, + length: d.length, + category: ts.DiagnosticCategory[d.category].toLowerCase(), + code: d.code, + startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), + endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) + }); }); + }; + Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { + var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; + if (isSemantic && shouldSkipSematicCheck(project)) { + return []; + } var scriptInfo = project.getScriptInfoForNormalizedPath(file); - var startPosition = getStartPosition(); - var endPosition = getEndPosition(); - var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); - if (!codeActions) { + var diagnostics = selector(project, file); + return includeLinePosition + ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) + : diagnostics.map(function (d) { return formatDiag(file, project, d); }); + }; + Session.prototype.getDefinition = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); + if (!definitions) { return undefined; } if (simplifiedResult) { - return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); } else { - return codeActions; - } - function getStartPosition() { - return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); - } - function getEndPosition() { - return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + return definitions; } }; - Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { - var _this = this; - return { - description: codeAction.description, - changes: codeAction.changes.map(function (change) { return ({ - fileName: change.fileName, - textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) - }); }) - }; - }; - Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { - return { - start: scriptInfo.positionToLineOffset(change.span.start), - end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), - newText: change.newText ? change.newText : "" - }; - }; - Session.prototype.getBraceMatching = function (args, simplifiedResult) { - var _this = this; - var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + Session.prototype.getTypeDefinition = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); - var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); - return !spans - ? undefined - : simplifiedResult - ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) - : spans; + var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); + if (!definitions) { + return undefined; + } + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); }; - Session.prototype.getDiagnosticsForProject = function (delay, fileName) { - var _this = this; - var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; - if (languageServiceDisabled) { - return; + Session.prototype.getImplementation = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var implementations = project.getLanguageService().getImplementationAtPosition(file, position); + if (!implementations) { + return []; } - var fileNamesInProject = fileNames.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); - var highPriorityFiles = []; - var mediumPriorityFiles = []; - var lowPriorityFiles = []; - var veryLowPriorityFiles = []; - var normalizedFileName = server.toNormalizedPath(fileName); - var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); - for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { - var fileNameInProject = fileNamesInProject_1[_i]; - if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) - highPriorityFiles.push(fileNameInProject); - else { - var info = this.projectService.getScriptInfo(fileNameInProject); - if (!info.isOpen) { - if (fileNameInProject.indexOf(".d.ts") > 0) - veryLowPriorityFiles.push(fileNameInProject); - else - lowPriorityFiles.push(fileNameInProject); - } - else - mediumPriorityFiles.push(fileNameInProject); - } + if (simplifiedResult) { + return implementations.map(function (impl) { return ({ + file: impl.fileName, + start: scriptInfo.positionToLineOffset(impl.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) + }); }); } - fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); - if (fileNamesInProject.length > 0) { - var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + else { + return implementations; } }; - Session.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - Session.prototype.exit = function () { + Session.prototype.getOccurrences = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); + if (!occurrences) { + return undefined; + } + return occurrences.map(function (occurrence) { + var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; + var scriptInfo = project.getScriptInfo(fileName); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { + start: start, + end: end, + file: fileName, + isWriteAccess: isWriteAccess, + }; + }); }; - Session.prototype.notRequired = function () { - return { responseRequired: false }; + Session.prototype.getSyntacticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; - Session.prototype.requiredResponse = function (response) { - return { response: response, responseRequired: true }; + Session.prototype.getSemanticDiagnosticsSync = function (args) { + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); }; - Session.prototype.addProtocolHandler = function (command, handler) { - if (command in this.handlers) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); + Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); + if (!documentHighlights) { + return undefined; } - this.handlers[command] = handler; - }; - Session.prototype.executeCommand = function (request) { - var handler = this.handlers[request.command]; - if (handler) { - return handler(request); + if (simplifiedResult) { + return documentHighlights.map(convertToDocumentHighlightsItem); } else { - this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); - this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); - return { responseRequired: false }; - } - }; - Session.prototype.onMessage = function (message) { - this.gcTimer.scheduleCollect(); - var start; - if (this.logger.hasLevel(server.LogLevel.requestTime)) { - start = this.hrtime(); - if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("request: " + message); - } - } - var request; - try { - request = JSON.parse(message); - var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; - if (this.logger.hasLevel(server.LogLevel.requestTime)) { - var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); - if (responseRequired) { - this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); - } - else { - this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); - } - } - if (response) { - this.output(response, request.command, request.seq); - } - else if (responseRequired) { - this.output(undefined, request.command, request.seq, "No content available."); - } + return documentHighlights; } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - this.output({ canceled: true }, request.command, request.seq); - return; + function convertToDocumentHighlightsItem(documentHighlights) { + var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + var scriptInfo = project.getScriptInfo(fileName); + return { + file: fileName, + highlightSpans: highlightSpans.map(convertHighlightSpan) + }; + function convertHighlightSpan(highlightSpan) { + var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); + return { start: start, end: end, kind: kind }; } - this.logError(err, message); - this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); } }; - return Session; - }()); - server.Session = Session; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - var lineCollectionCapacity = 4; - (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"; - })(server.CharRangeSection || (server.CharRangeSection = {})); - var CharRangeSection = server.CharRangeSection; - var BaseLineIndexWalker = (function () { - function BaseLineIndexWalker() { - this.goSubtree = true; - this.done = false; - } - BaseLineIndexWalker.prototype.leaf = function (rangeStart, rangeLength, ll) { + Session.prototype.setCompilerOptionsForInferredProjects = function (args) { + this.projectService.setCompilerOptionsForInferredProjects(args.options); }; - 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; + Session.prototype.getProjectInfo = function (args) { + return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); + }; + Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { + var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; + var projectInfo = { + configFileName: project.getProjectName(), + languageServiceDisabled: !project.languageServiceEnabled, + fileNames: needFileNameList ? project.getFileNames() : undefined + }; + return projectInfo; + }; + Session.prototype.getRenameInfo = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService().getRenameInfo(file, position); + }; + Session.prototype.getProjects = function (args) { + var projects; + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + projects = [project]; + } } else { - insertedText = this.initialText + this.trailingText; + var scriptInfo = this.projectService.getScriptInfo(args.file); + projects = scriptInfo.containingProjects; } - var lm = LineIndex.linesFromText(insertedText); - var lines = lm.lines; - if (lines.length > 1) { - if (lines[lines.length - 1] == "") { - lines.length--; - } + projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); + if (!projects || !projects.length) { + return server.Errors.ThrowNoProject(); } - 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; - } + return projects; + }; + Session.prototype.getRenameLocations = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var info = this.projectService.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, info); + var projects = this.getProjects(args); + if (simplifiedResult) { + var defaultProject = projects[0]; + var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); + if (!renameInfo) { + return undefined; } - } - 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, len_1 = lines.length; i < len_1; 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; + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var fileSpans = server.combineProjectOutput(projects, function (project) { + var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); + if (!renameLocations) { + return []; } - 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; + return renameLocations.map(function (location) { + var locationScriptInfo = project.getScriptInfo(location.fileName); + return { + file: location.fileName, + start: locationScriptInfo.positionToLineOffset(location.textSpan.start), + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), + }; + }); + }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); + var locs = fileSpans.reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file !== cur.file) { + curFileAccum = undefined; + } } - this.lineIndex.root.updateCounts(); - } - else { - for (var j = this.startPath.length - 2; j >= 0; j--) { - this.startPath[j].updateCounts(); + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); } - } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: locs }; } 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, parent, nodeType) { - 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; + return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); } - var child; - function fresh(node) { - if (node.isLeaf()) { - return new LineLeaf(""); + function renameLocationIsEqualTo(a, b) { + if (a === b) { + return true; } - else - return new LineNode(); + if (!a || !b) { + return false; + } + return a.fileName === b.fileName && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; } - 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; - } + function compareRenameLocation(a, b) { + if (a.file < b.file) { + return -1; + } + else if (a.file > b.file) { + return 1; + } + else { + if (a.start.line < b.start.line) { + return 1; } - break; - case CharRangeSection.Mid: - this.goSubtree = false; - break; - case CharRangeSection.End: - if (this.state !== CharRangeSection.End) { - this.goSubtree = false; + else if (a.start.line > b.start.line) { + return -1; } 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); + return b.start.offset - a.start.offset; } - 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); + Session.prototype.getReferences = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var projects = this.getProjects(args); + var defaultProject = projects[0]; + var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + if (simplifiedResult) { + var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; + } + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; + var nameText = scriptInfo.snap().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var refs = server.combineProjectOutput(projects, function (project) { + var references = project.getLanguageService().getReferencesAtPosition(file, position); + if (!references) { + return []; + } + return references.map(function (ref) { + var refScriptInfo = project.getScriptInfo(ref.fileName); + var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); + var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); + var lineText = refScriptInfo.snap().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); + return { + file: ref.fileName, + start: start, + lineText: lineText, + end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), + isWriteAccess: ref.isWriteAccess, + isDefinition: ref.isDefinition + }; + }); + }, compareFileStart, areReferencesResponseItemsForTheSameLocation); + return { + refs: refs, + symbolName: nameText, + symbolStartOffset: nameColStart, + symbolDisplayString: displayString + }; } else { - this.trailingText = ll.text.substring(relativeStart + relativeLength); + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); + } + function areReferencesResponseItemsForTheSameLocation(a, b) { + if (a && b) { + return a.file === b.file && + a.start === b.start && + a.end === b.end; + } + return false; } }; - 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; + Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + if (this.eventHander) { + this.eventHander({ + eventName: "configFileDiag", + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + }); } - return version % ScriptVersionCache.maxVersions; }; - ScriptVersionCache.prototype.currentVersionToIndex = function () { - return this.currentVersion % ScriptVersionCache.maxVersions; + Session.prototype.getPosition = function (args, scriptInfo) { + return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); }; - 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(); - } + Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); }; - ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersionToIndex()]; + Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); }; - ScriptVersionCache.prototype.latestVersion = function () { - if (this.changes.length > 0) { - this.getSnapshot(); + Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { + var file = server.toNormalizedPath(uncheckedFileName); + var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); + if (!project && errorOnMissingProject) { + return server.Errors.ThrowNoProject(); } - return this.currentVersion; + return { file: file, project: project }; }; - ScriptVersionCache.prototype.reloadFromFile = function (filename) { - var content = this.host.readFile(filename); - if (!content) { - content = ""; - } - this.reload(content); + Session.prototype.getOutliningSpans = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + return project.getLanguageService(false).getOutliningSpans(file); }; - 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; + Session.prototype.getTodoComments = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getTodoComments(file, args.descriptors); }; - ScriptVersionCache.prototype.getSnapshot = function () { - 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]; - 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; + Session.prototype.getDocCommentTemplate = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); }; - 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 j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { - var textChange = snap.changesSincePreviousVersion[j]; - textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); - } - } - return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); - } - else { - return undefined; - } + Session.prototype.getIndentation = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); + return { position: position, indentation: indentation }; + }; + Session.prototype.getBreakpointStatement = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); + }; + Session.prototype.getNameOrDottedNameSpan = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); + }; + Session.prototype.isValidBraceCompletion = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); + }; + Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); + if (!quickInfo) { + return undefined; + } + if (simplifiedResult) { + var displayString = ts.displayPartsToString(quickInfo.displayParts); + var docString = ts.displayPartsToString(quickInfo.documentation); + return { + kind: quickInfo.kind, + kindModifiers: quickInfo.kindModifiers, + start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), + displayString: displayString, + documentation: docString, + }; } else { - return ts.unchangedTextChangeRange; + return quickInfo; } }; - 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; + Session.prototype.getFormattingEditsForRange = function (args) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); + if (!edits) { + return undefined; + } + return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); }; - 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); + Session.prototype.getFormattingEditsForRangeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); }; - LineIndexSnapshot.prototype.getLength = function () { - return this.index.root.charCount(); + Session.prototype.getFormattingEditsForDocumentFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForDocument(file, options); }; - LineIndexSnapshot.prototype.getLineStartPositions = function () { - var starts = [-1]; - var count = 1; - var pos = 0; - this.index.every(function (ll, s, len) { - starts[count] = pos; - count++; - pos += ll.text.length; - return true; - }, 0); - return starts; + Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); }; - LineIndexSnapshot.prototype.getLineMapper = function () { - var _this = this; - return function (line) { - return _this.index.lineNumberToInfo(line).offset; - }; + Session.prototype.getFormattingEditsAfterKeystroke = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var formatOptions = this.projectService.getFormatCodeOptions(file); + var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); + if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + var lineInfo = scriptInfo.getLineInfo(args.line); + if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { + var lineText = lineInfo.leaf.text; + if (lineText.search("\\S") < 0) { + var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); + var hasIndent = 0; + var i = void 0, len = void 0; + for (i = 0, len = lineText.length; i < len; i++) { + if (lineText.charAt(i) == " ") { + hasIndent++; + } + else if (lineText.charAt(i) == "\t") { + hasIndent += formatOptions.tabSize; + } + else { + break; + } + } + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; + edits.push({ + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) + }); + } + } + } + } + if (!edits) { + return undefined; + } + return edits.map(function (edit) { + return { + start: scriptInfo.positionToLineOffset(edit.span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), + newText: edit.newText ? edit.newText : "" + }; + }); }; - LineIndexSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - if (this.version <= scriptVersion) { - return ts.unchangedTextChangeRange; + Session.prototype.getCompletions = function (args, simplifiedResult) { + var _this = this; + var prefix = args.prefix || ""; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position); + if (!completions) { + return undefined; + } + if (simplifiedResult) { + return completions.entries.reduce(function (result, entry) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { + 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_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + } + return result; + }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); } else { - return this.cache.getTextChangesBetweenVersions(scriptVersion, this.version); + return completions; } }; - LineIndexSnapshot.prototype.getChangeRange = function (oldSnapshot) { - var oldSnap = oldSnapshot; - return this.getTextChangeRangeSinceVersion(oldSnap.version); + Session.prototype.getCompletionEntryDetails = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return args.entryNames.reduce(function (accum, entryName) { + var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); + if (details) { + accum.push(details); + } + return accum; + }, []); }; - return LineIndexSnapshot; - }()); - server.LineIndexSnapshot = LineIndexSnapshot; - var LineIndex = (function () { - function LineIndex() { - this.checkEdits = false; - } - LineIndex.prototype.charOffsetToLineNumberAndPos = function (charOffset) { - return this.root.charOffsetToLineNumberAndPos(1, charOffset); + Session.prototype.getCompileOnSaveAffectedFileList = function (args) { + var info = this.projectService.getScriptInfo(args.file); + var result = []; + if (!info) { + return []; + } + var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; + for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { + var project = projectsToSearch_1[_i]; + if (project.compileOnSaveEnabled && project.languageServiceEnabled) { + result.push({ + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info) + }); + } + } + return result; }; - 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; + Session.prototype.emitFile = function (args) { + var _this = this; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + if (!project) { + server.Errors.ThrowNoProject(); } - else { + var scriptInfo = project.getScriptInfo(file); + return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); + }; + Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); + if (!helpItems) { + return undefined; + } + if (simplifiedResult) { + var span_16 = helpItems.applicableSpan; return { - line: lineNumber, - offset: this.root.charCount() + items: helpItems.items, + applicableSpan: { + start: scriptInfo.positionToLineOffset(span_16.start), + end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount, }; } + else { + return helpItems; + } }; - LineIndex.prototype.load = function (lines) { - if (lines.length > 0) { - var leaves = []; - for (var i = 0, len = lines.length; i < len; i++) { - leaves[i] = new LineLeaf(lines[i]); + Session.prototype.getDiagnostics = function (delay, fileNames) { + var _this = this; + var checkList = fileNames.reduce(function (accum, uncheckedFileName) { + var fileName = server.toNormalizedPath(uncheckedFileName); + var project = _this.projectService.getDefaultProjectForFile(fileName, true); + if (project) { + accum.push({ fileName: fileName, project: project }); } - this.root = LineIndex.buildTreeFromBottom(leaves); + return accum; + }, []); + if (checkList.length > 0) { + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); } - else { - this.root = new LineNode(); + }; + Session.prototype.change = function (args) { + var _this = this; + var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; + if (project) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + if (start >= 0) { + scriptInfo.editContent(start, end, args.insertString); + this.changeSeq++; + } + this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); } }; - LineIndex.prototype.walk = function (rangeStart, rangeLength, walkFns) { - this.root.walk(rangeStart, rangeLength, walkFns); + Session.prototype.reload = function (args, reqSeq) { + var file = server.toNormalizedPath(args.file); + var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); + var project = this.projectService.getDefaultProjectForFile(file, true); + if (project) { + this.changeSeq++; + if (project.reloadScript(file, tempFileName)) { + this.output(undefined, CommandNames.Reload, reqSeq); + } + } + }; + Session.prototype.saveToTmp = function (fileName, tempFileName) { + var scriptInfo = this.projectService.getScriptInfo(fileName); + if (scriptInfo) { + scriptInfo.saveTo(tempFileName); + } + }; + Session.prototype.closeClientFile = function (fileName) { + if (!fileName) { + return; + } + var file = ts.normalizePath(fileName); + this.projectService.closeClientFile(file); + }; + Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { + var _this = this; + return ts.map(items, function (item) { return ({ + text: item.text, + kind: item.kind, + kindModifiers: item.kindModifiers, + spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), + indent: item.indent + }); }); }; - 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; + Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var items = project.getLanguageService(false).getNavigationBarItems(file); + return !items + ? undefined + : simplifiedResult + ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) + : items; }; - LineIndex.prototype.getLength = function () { - return this.root.charCount(); + Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { + var _this = this; + return { + text: tree.text, + kind: tree.kind, + kindModifiers: tree.kindModifiers, + spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) + }; }; - 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; - } - } + Session.prototype.decorateSpan = function (span, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) }; - 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; + Session.prototype.getNavigationTree = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var tree = project.getLanguageService(false).getNavigationTree(file); + return !tree + ? undefined + : simplifiedResult + ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) + : tree; + }; + Session.prototype.getNavigateToItems = function (args, simplifiedResult) { + var projects = this.getProjects(args); + var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; + if (simplifiedResult) { + return server.combineProjectOutput(projects, function (project) { + var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); + if (!navItems) { + return []; } - 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; + return navItems.map(function (navItem) { + var scriptInfo = project.getScriptInfo(navItem.fileName); + var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); + var bakedItem = { + name: navItem.name, + kind: navItem.kind, + file: navItem.fileName, + start: start, + end: end, + }; + if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { + bakedItem.kindModifiers = navItem.kindModifiers; } - else { - newText = lineInfo.text; + if (navItem.matchKind !== "none") { + bakedItem.matchKind = navItem.matchKind; } - } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + }, undefined, areNavToItemsForTheSameLocation); + } + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); + } + function navigateToItemIsEqualTo(a, b) { + if (a === b) { + return true; } - if (pos < this.root.charCount()) { - this.root.walk(pos, deleteLength, walker); - walker.insertLines(newText); + if (!a || !b) { + return false; } - if (this.checkEdits) { - var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + return a.containerKind === b.containerKind && + a.containerName === b.containerName && + a.fileName === b.fileName && + a.isCaseSensitive === b.isCaseSensitive && + a.kind === b.kind && + a.kindModifiers === b.containerName && + a.matchKind === b.matchKind && + a.name === b.name && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } + function areNavToItemsForTheSameLocation(a, b) { + if (a && b) { + return a.file === b.file && + a.start === b.start && + a.end === b.end; } - return walker.lineIndex; + return false; } }; - 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; + Session.prototype.getSupportedCodeFixes = function () { + return ts.getSupportedCodeFixes(); + }; + Session.prototype.getCodeFixes = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = getStartPosition(); + var endPosition = getEndPosition(); + var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + if (!codeActions) { + return undefined; } - if (interiorNodes.length === 1) { - return interiorNodes[0]; + if (simplifiedResult) { + return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); } 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]); + return codeActions; } - var endText = text.substring(lineStarts[lc]); - if (endText.length > 0) { - lines[lc] = endText; + function getStartPosition() { + return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); } - else { - lines.length--; + function getEndPosition() { + return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); } - 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; + Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { + var _this = this; + return { + description: codeAction.description, + changes: codeAction.changes.map(function (change) { return ({ + fileName: change.fileName, + textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) + }); }) + }; }; - 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]; - this.totalChars += child.charCount(); - this.totalLines += child.lineCount(); - } + Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(change.span.start), + end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), + newText: change.newText ? change.newText : "" + }; }; - LineNode.prototype.execWalk = function (rangeStart, rangeLength, walkFns, childIndex, nodeType) { - if (walkFns.pre) { - walkFns.pre(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + Session.prototype.getBraceMatching = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); + return !spans + ? undefined + : simplifiedResult + ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) + : spans; + }; + Session.prototype.getDiagnosticsForProject = function (delay, fileName) { + var _this = this; + var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; + if (languageServiceDisabled) { + return; } - if (walkFns.goSubtree) { - this.children[childIndex].walk(rangeStart, rangeLength, walkFns); - if (walkFns.post) { - walkFns.post(rangeStart, rangeLength, this.children[childIndex], this, nodeType); + var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); + var highPriorityFiles = []; + var mediumPriorityFiles = []; + var lowPriorityFiles = []; + var veryLowPriorityFiles = []; + var normalizedFileName = server.toNormalizedPath(fileName); + var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); + for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { + var fileNameInProject = fileNamesInProject_1[_i]; + if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + highPriorityFiles.push(fileNameInProject); + else { + var info = this.projectService.getScriptInfo(fileNameInProject); + if (!info.isOpen) { + if (fileNameInProject.indexOf(".d.ts") > 0) + veryLowPriorityFiles.push(fileNameInProject); + else + lowPriorityFiles.push(fileNameInProject); + } + else + mediumPriorityFiles.push(fileNameInProject); } } - else { - walkFns.goSubtree = true; + fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); + if (fileNamesInProject.length > 0) { + var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); + this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); } - 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; - } + Session.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); }; - 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(); + Session.prototype.exit = function () { + }; + Session.prototype.notRequired = function () { + return { responseRequired: false }; + }; + Session.prototype.requiredResponse = function (response) { + return { response: response, responseRequired: true }; + }; + Session.prototype.addProtocolHandler = function (command, handler) { + if (command in this.handlers) { + throw new Error("Protocol handler already exists for command \"" + command + "\""); } - if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, CharRangeSection.Entire)) { - return; - } + this.handlers[command] = handler; + }; + Session.prototype.executeCommand = function (request) { + var handler = this.handlers[request.command]; + if (handler) { + return handler(request); } 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; - } + this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + return { responseRequired: false }; + } + }; + Session.prototype.onMessage = function (message) { + this.gcTimer.scheduleCollect(); + var start; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + start = this.hrtime(); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("request: " + message); } } - 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); + var request; + try { + request = JSON.parse(message); + var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); + if (responseRequired) { + this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + } + else { + this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); } } - } - }; - 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) - }; + if (response) { + this.output(response, request.command, request.seq); } - else { - var lineNode = (childInfo.child); - return lineNode.charOffsetToLineNumberAndPos(childInfo.lineNumber, childInfo.charOffset); + else if (responseRequired) { + this.output(undefined, request.command, request.seq, "No content available."); } } - else { - var lineInfo = this.lineNumberToInfo(this.lineCount(), 0); - return { line: this.lineCount(), offset: lineInfo.leaf.charCount() }; + catch (err) { + if (err instanceof ts.OperationCanceledException) { + this.output({ canceled: true }, request.command, request.seq); + return; + } + this.logError(err, message); + this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); } }; - LineNode.prototype.lineNumberToInfo = function (lineNumber, charOffset) { - var childInfo = this.childFromLineNumber(lineNumber, charOffset); - if (!childInfo.child) { - return { - line: lineNumber, - offset: charOffset - }; + return Session; + }()); + server.Session = Session; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var lineCollectionCapacity = 4; + (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"; + })(server.CharRangeSection || (server.CharRangeSection = {})); + var 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 = ""; } - else if (childInfo.child.isLeaf()) { - return { - line: lineNumber, - offset: childInfo.charOffset, - text: (childInfo.child).text, - leaf: (childInfo.child) - }; + if (insertedText) { + insertedText = this.initialText + insertedText + this.trailingText; } else { - var lineNode = (childInfo.child); - return lineNode.lineNumberToInfo(childInfo.relativeLineNumber, childInfo.charOffset); + insertedText = this.initialText + this.trailingText; } - }; - 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(); + var lm = LineIndex.linesFromText(insertedText); + var lines = lm.lines; + if (lines.length > 1) { + if (lines[lines.length - 1] == "") { + lines.length--; } } - 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; + 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, len_1 = lines.length; i < len_1; 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 { - charOffset -= child.charCount(); - lineNumber += child.lineCount(); + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); + } } } - 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++; + else { + insertionNode.remove(leafNode); + for (var j = this.startPath.length - 2; j >= 0; j--) { + this.startPath[j].updateCounts(); } - splitNode.updateCounts(); } - this.children.length = endLength; - return splitNode; + return this.lineIndex; }; - 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]; - } + EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { + if (lineCollection === this.lineCollectionAtBranch) { + this.state = CharRangeSection.End; } - 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; + this.stack.length--; + return undefined; }; - 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 []; + 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; } - else { - var shiftNode = this.splitAfter(childIndex); - var nodeIndex = 0; - childIndex++; - while ((childIndex < lineCollectionCapacity) && (nodeIndex < nodeCount)) { - this.children[childIndex] = nodes[nodeIndex]; - childIndex++; - nodeIndex++; + var child; + function fresh(node) { + if (node.isLeaf()) { + return new LineLeaf(""); } - 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(); + else + return new LineNode(); + } + switch (nodeType) { + case CharRangeSection.PreStart: + this.goSubtree = false; + if (this.state !== CharRangeSection.End) { + currentNode.add(lineCollection); } - var splitNode = splitNodes[0]; - while (nodeIndex < nodeCount) { - splitNode.add(nodes[nodeIndex]); - nodeIndex++; - if (splitNode.children.length === lineCollectionCapacity) { - splitNodeIndex++; - splitNode = splitNodes[splitNodeIndex]; + 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; } } - for (var i = splitNodes.length - 1; i >= 0; i--) { - if (splitNodes[i].children.length === 0) { - splitNodes.length--; + 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; } } - } - if (shiftNode) { - splitNodes[splitNodes.length] = shiftNode; - } - this.updateCounts(); - for (var i = 0; i < splitNodeCount; i++) { - splitNodes[i].updateCounts(); - } - return splitNodes; + 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; }; - LineNode.prototype.add = function (collection) { - this.children[this.children.length] = collection; - return (this.children.length < lineCollectionCapacity); - }; - LineNode.prototype.charCount = function () { - return this.totalChars; + 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); + } }; - LineNode.prototype.lineCount = function () { - return this.totalLines; + 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 LineNode; + return TextChange; }()); - server.LineNode = LineNode; - var LineLeaf = (function () { - function LineLeaf(text) { - this.text = text; + server.TextChange = TextChange; + var ScriptVersionCache = (function () { + function ScriptVersionCache() { + this.changes = []; + this.versions = new Array(ScriptVersionCache.maxVersions); + this.minVersion = 0; + this.currentVersion = 0; } - LineLeaf.prototype.isLeaf = function () { - return true; + ScriptVersionCache.prototype.versionToIndex = function (version) { + if (version < this.minVersion || version > this.currentVersion) { + return undefined; + } + return version % ScriptVersionCache.maxVersions; }; - LineLeaf.prototype.walk = function (rangeStart, rangeLength, walkFns) { - walkFns.leaf(rangeStart, rangeLength, this); + ScriptVersionCache.prototype.currentVersionToIndex = function () { + return this.currentVersion % ScriptVersionCache.maxVersions; }; - LineLeaf.prototype.charCount = function () { - return this.text.length; + 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(); + } }; - LineLeaf.prototype.lineCount = function () { - return 1; + ScriptVersionCache.prototype.latest = function () { + return this.versions[this.currentVersionToIndex()]; }; - return LineLeaf; - }()); - server.LineLeaf = LineLeaf; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var debugObjectHost = (function () { return this; })(); -var ts; -(function (ts) { - function logInternalError(logger, err) { - if (logger) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); - } - } - var ScriptSnapshotShimAdapter = (function () { - function ScriptSnapshotShimAdapter(scriptSnapshotShim) { - this.scriptSnapshotShim = scriptSnapshotShim; - } - ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { - return this.scriptSnapshotShim.getText(start, end); - }; - ScriptSnapshotShimAdapter.prototype.getLength = function () { - return this.scriptSnapshotShim.getLength(); - }; - ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { - return null; - } - var decoded = JSON.parse(encoded); - return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); - return ts.map(moduleNames, function (name) { - var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - LanguageServiceShimHostAdapter.prototype.log = function (s) { - if (this.loggingEnabled) { - this.shimHost.log(s); - } - }; - LanguageServiceShimHostAdapter.prototype.trace = function (s) { - if (this.tracingEnabled) { - this.shimHost.trace(s); - } - }; - LanguageServiceShimHostAdapter.prototype.error = function (s) { - this.shimHost.error(s); - }; - LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { - if (!this.shimHost.getProjectVersion) { - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { - return this.shimHost.getScriptVersion(fileName); - }; - LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { - return null; - } - try { - return JSON.parse(diagnosticMessagesJson); - } - catch (e) { - this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); - return null; - } - }; - LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); - }; - LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { - return this.shimHost.getCurrentDirectory(); - }; - LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); + 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, len = this.changes.length; i < len; i++) { + var change = this.changes[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 j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { + var textChange = snap.changesSincePreviousVersion[j]; + textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); + } } + return ts.collapseTextChangeRangesAcrossMultipleVersions(textChangeRanges); + } + else { + return undefined; } } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof result === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; + else { + return ts.unchangedTextChangeRange; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); - } - } - return result; - } - function forwardJSONCall(logger, actionDescription, action, logPerformance) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: result }) : result; - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - return JSON.stringify({ canceled: true }); - } - logInternalError(logger, err); - err.description = actionDescription; - return JSON.stringify({ error: err }); - } - } - var ShimBase = (function () { - function ShimBase(factory) { - this.factory = factory; - factory.registerShim(this); - } - ShimBase.prototype.dispose = function (dummy) { - this.factory.unregisterShim(this); - }; - return ShimBase; - }()); - function realizeDiagnostics(diagnostics, newLine) { - return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); - } - ts.realizeDiagnostics = realizeDiagnostics; - function realizeDiagnostic(diagnostic, newLine) { - return { - message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), - start: diagnostic.start, - length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - var LanguageServiceShimObject = (function (_super) { - __extends(LanguageServiceShimObject, _super); - function LanguageServiceShimObject(factory, host, languageService) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); - }; - LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { - var _this = this; - this.forwardJSONCall("cleanupSemanticCache()", function () { - _this.languageService.cleanupSemanticCache(); - return null; - }); - }; - LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { - var _this = this; - return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { - var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { - var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); - }; - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { - var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - return LanguageServiceShimObject; - }(ShimBase)); - function convertClassifications(classifications) { - return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; - } - var ClassifierShimObject = (function (_super) { - __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory, logger) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { - var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); - }; - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; + }; + 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 = []; } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; - } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + 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; }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; + }; + 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) { + var oldSnap = oldSnapshot; + return this.getTextChangeRangeSinceVersion(oldSnap.version); + }; + return LineIndexSnapshot; + }()); + server.LineIndexSnapshot = LineIndexSnapshot; + var LineIndex = (function () { + function LineIndex() { + this.checkEdits = false; } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos - }); + 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, len = lines.length; i < len; 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 = []; } - return result; - }; - CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { - var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileTextToJson(fileName, text); - if (result.error) { + LineNode.prototype.isLeaf = function () { + return false; + }; + 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]; + 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 { - options: {}, - typingOptions: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] + line: lineNumber, + offset: charOffset, }; } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + 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 { - options: configFile.options, - typingOptions: configFile.typingOptions, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") + child: child, + childIndex: i, + relativeLineNumber: relativeLineNumber, + charOffset: charOffset }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); - }); - }; - return CoreServicesShimObject; - }(ShimBase)); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - TypeScriptServicesFactory.prototype.getServicesVersion = function () { - return ts.servicesVersion; - }; - TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { - try { - if (this.documentRegistry === undefined) { - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + }; + 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(); + } } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); - return new LanguageServiceShimObject(this, host, languageService); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { - try { - return new ClassifierShimObject(this, logger); - } - catch (err) { - logInternalError(logger, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { - try { - var adapter = new CoreServicesShimHostAdapter(host); - return new CoreServicesShimObject(this, host, adapter); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.close = function () { - this._shims = []; - this.documentRegistry = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { - if (this._shims[i] === shim) { - delete this._shims[i]; - return; + 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; } - throw new Error("Invalid operation"); - }; - return TypeScriptServicesFactory; - }()); - ts.TypeScriptServicesFactory = TypeScriptServicesFactory; - if (typeof module !== "undefined" && module.exports) { - module.exports = ts; - } + 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 TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var toolsVersion = "2.1"; + +//# sourceMappingURL=tsserverlibrary.js.map diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index c915bd9efc877..ba46bcf1540d5 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -47,241 +47,241 @@ declare namespace ts { ConflictMarkerTrivia = 7, NumericLiteral = 8, StringLiteral = 9, - RegularExpressionLiteral = 10, - NoSubstitutionTemplateLiteral = 11, - TemplateHead = 12, - TemplateMiddle = 13, - TemplateTail = 14, - OpenBraceToken = 15, - CloseBraceToken = 16, - OpenParenToken = 17, - CloseParenToken = 18, - OpenBracketToken = 19, - CloseBracketToken = 20, - DotToken = 21, - DotDotDotToken = 22, - SemicolonToken = 23, - CommaToken = 24, - LessThanToken = 25, - LessThanSlashToken = 26, - GreaterThanToken = 27, - LessThanEqualsToken = 28, - GreaterThanEqualsToken = 29, - EqualsEqualsToken = 30, - ExclamationEqualsToken = 31, - EqualsEqualsEqualsToken = 32, - ExclamationEqualsEqualsToken = 33, - EqualsGreaterThanToken = 34, - PlusToken = 35, - MinusToken = 36, - AsteriskToken = 37, - AsteriskAsteriskToken = 38, - SlashToken = 39, - PercentToken = 40, - PlusPlusToken = 41, - MinusMinusToken = 42, - LessThanLessThanToken = 43, - GreaterThanGreaterThanToken = 44, - GreaterThanGreaterThanGreaterThanToken = 45, - AmpersandToken = 46, - BarToken = 47, - CaretToken = 48, - ExclamationToken = 49, - TildeToken = 50, - AmpersandAmpersandToken = 51, - BarBarToken = 52, - QuestionToken = 53, - ColonToken = 54, - AtToken = 55, - EqualsToken = 56, - PlusEqualsToken = 57, - MinusEqualsToken = 58, - AsteriskEqualsToken = 59, - AsteriskAsteriskEqualsToken = 60, - SlashEqualsToken = 61, - PercentEqualsToken = 62, - LessThanLessThanEqualsToken = 63, - GreaterThanGreaterThanEqualsToken = 64, - GreaterThanGreaterThanGreaterThanEqualsToken = 65, - AmpersandEqualsToken = 66, - BarEqualsToken = 67, - CaretEqualsToken = 68, - Identifier = 69, - BreakKeyword = 70, - CaseKeyword = 71, - CatchKeyword = 72, - ClassKeyword = 73, - ConstKeyword = 74, - ContinueKeyword = 75, - DebuggerKeyword = 76, - DefaultKeyword = 77, - DeleteKeyword = 78, - DoKeyword = 79, - ElseKeyword = 80, - EnumKeyword = 81, - ExportKeyword = 82, - ExtendsKeyword = 83, - FalseKeyword = 84, - FinallyKeyword = 85, - ForKeyword = 86, - FunctionKeyword = 87, - IfKeyword = 88, - ImportKeyword = 89, - InKeyword = 90, - InstanceOfKeyword = 91, - NewKeyword = 92, - NullKeyword = 93, - ReturnKeyword = 94, - SuperKeyword = 95, - SwitchKeyword = 96, - ThisKeyword = 97, - ThrowKeyword = 98, - TrueKeyword = 99, - TryKeyword = 100, - TypeOfKeyword = 101, - VarKeyword = 102, - VoidKeyword = 103, - WhileKeyword = 104, - WithKeyword = 105, - ImplementsKeyword = 106, - InterfaceKeyword = 107, - LetKeyword = 108, - PackageKeyword = 109, - PrivateKeyword = 110, - ProtectedKeyword = 111, - PublicKeyword = 112, - StaticKeyword = 113, - YieldKeyword = 114, - AbstractKeyword = 115, - AsKeyword = 116, - AnyKeyword = 117, - AsyncKeyword = 118, - AwaitKeyword = 119, - BooleanKeyword = 120, - ConstructorKeyword = 121, - DeclareKeyword = 122, - GetKeyword = 123, - IsKeyword = 124, - ModuleKeyword = 125, - NamespaceKeyword = 126, - NeverKeyword = 127, - ReadonlyKeyword = 128, - RequireKeyword = 129, - NumberKeyword = 130, - SetKeyword = 131, - StringKeyword = 132, - SymbolKeyword = 133, - TypeKeyword = 134, - UndefinedKeyword = 135, - FromKeyword = 136, - GlobalKeyword = 137, - OfKeyword = 138, - QualifiedName = 139, - ComputedPropertyName = 140, - TypeParameter = 141, - Parameter = 142, - Decorator = 143, - PropertySignature = 144, - PropertyDeclaration = 145, - MethodSignature = 146, - MethodDeclaration = 147, - Constructor = 148, - GetAccessor = 149, - SetAccessor = 150, - CallSignature = 151, - ConstructSignature = 152, - IndexSignature = 153, - TypePredicate = 154, - TypeReference = 155, - FunctionType = 156, - ConstructorType = 157, - TypeQuery = 158, - TypeLiteral = 159, - ArrayType = 160, - TupleType = 161, - UnionType = 162, - IntersectionType = 163, - ParenthesizedType = 164, - ThisType = 165, - LiteralType = 166, - ObjectBindingPattern = 167, - ArrayBindingPattern = 168, - BindingElement = 169, - ArrayLiteralExpression = 170, - ObjectLiteralExpression = 171, - PropertyAccessExpression = 172, - ElementAccessExpression = 173, - CallExpression = 174, - NewExpression = 175, - TaggedTemplateExpression = 176, - TypeAssertionExpression = 177, - ParenthesizedExpression = 178, - FunctionExpression = 179, - ArrowFunction = 180, - DeleteExpression = 181, - TypeOfExpression = 182, - VoidExpression = 183, - AwaitExpression = 184, - PrefixUnaryExpression = 185, - PostfixUnaryExpression = 186, - BinaryExpression = 187, - ConditionalExpression = 188, - TemplateExpression = 189, - YieldExpression = 190, - SpreadElementExpression = 191, - ClassExpression = 192, - OmittedExpression = 193, - ExpressionWithTypeArguments = 194, - AsExpression = 195, - NonNullExpression = 196, - TemplateSpan = 197, - SemicolonClassElement = 198, - Block = 199, - VariableStatement = 200, - EmptyStatement = 201, - ExpressionStatement = 202, - IfStatement = 203, - DoStatement = 204, - WhileStatement = 205, - ForStatement = 206, - ForInStatement = 207, - ForOfStatement = 208, - ContinueStatement = 209, - BreakStatement = 210, - ReturnStatement = 211, - WithStatement = 212, - SwitchStatement = 213, - LabeledStatement = 214, - ThrowStatement = 215, - TryStatement = 216, - DebuggerStatement = 217, - VariableDeclaration = 218, - VariableDeclarationList = 219, - FunctionDeclaration = 220, - ClassDeclaration = 221, - InterfaceDeclaration = 222, - TypeAliasDeclaration = 223, - EnumDeclaration = 224, - ModuleDeclaration = 225, - ModuleBlock = 226, - CaseBlock = 227, - NamespaceExportDeclaration = 228, - ImportEqualsDeclaration = 229, - ImportDeclaration = 230, - ImportClause = 231, - NamespaceImport = 232, - NamedImports = 233, - ImportSpecifier = 234, - ExportAssignment = 235, - ExportDeclaration = 236, - NamedExports = 237, - ExportSpecifier = 238, - MissingDeclaration = 239, - ExternalModuleReference = 240, - JsxElement = 241, - JsxSelfClosingElement = 242, - JsxOpeningElement = 243, - JsxText = 244, + JsxText = 10, + RegularExpressionLiteral = 11, + NoSubstitutionTemplateLiteral = 12, + TemplateHead = 13, + TemplateMiddle = 14, + TemplateTail = 15, + OpenBraceToken = 16, + CloseBraceToken = 17, + OpenParenToken = 18, + CloseParenToken = 19, + OpenBracketToken = 20, + CloseBracketToken = 21, + DotToken = 22, + DotDotDotToken = 23, + SemicolonToken = 24, + CommaToken = 25, + LessThanToken = 26, + LessThanSlashToken = 27, + GreaterThanToken = 28, + LessThanEqualsToken = 29, + GreaterThanEqualsToken = 30, + EqualsEqualsToken = 31, + ExclamationEqualsToken = 32, + EqualsEqualsEqualsToken = 33, + ExclamationEqualsEqualsToken = 34, + EqualsGreaterThanToken = 35, + PlusToken = 36, + MinusToken = 37, + AsteriskToken = 38, + AsteriskAsteriskToken = 39, + SlashToken = 40, + PercentToken = 41, + PlusPlusToken = 42, + MinusMinusToken = 43, + LessThanLessThanToken = 44, + GreaterThanGreaterThanToken = 45, + GreaterThanGreaterThanGreaterThanToken = 46, + AmpersandToken = 47, + BarToken = 48, + CaretToken = 49, + ExclamationToken = 50, + TildeToken = 51, + AmpersandAmpersandToken = 52, + BarBarToken = 53, + QuestionToken = 54, + ColonToken = 55, + AtToken = 56, + EqualsToken = 57, + PlusEqualsToken = 58, + MinusEqualsToken = 59, + AsteriskEqualsToken = 60, + AsteriskAsteriskEqualsToken = 61, + SlashEqualsToken = 62, + PercentEqualsToken = 63, + LessThanLessThanEqualsToken = 64, + GreaterThanGreaterThanEqualsToken = 65, + GreaterThanGreaterThanGreaterThanEqualsToken = 66, + AmpersandEqualsToken = 67, + BarEqualsToken = 68, + CaretEqualsToken = 69, + Identifier = 70, + BreakKeyword = 71, + CaseKeyword = 72, + CatchKeyword = 73, + ClassKeyword = 74, + ConstKeyword = 75, + ContinueKeyword = 76, + DebuggerKeyword = 77, + DefaultKeyword = 78, + DeleteKeyword = 79, + DoKeyword = 80, + ElseKeyword = 81, + EnumKeyword = 82, + ExportKeyword = 83, + ExtendsKeyword = 84, + FalseKeyword = 85, + FinallyKeyword = 86, + ForKeyword = 87, + FunctionKeyword = 88, + IfKeyword = 89, + ImportKeyword = 90, + InKeyword = 91, + InstanceOfKeyword = 92, + NewKeyword = 93, + NullKeyword = 94, + ReturnKeyword = 95, + SuperKeyword = 96, + SwitchKeyword = 97, + ThisKeyword = 98, + ThrowKeyword = 99, + TrueKeyword = 100, + TryKeyword = 101, + TypeOfKeyword = 102, + VarKeyword = 103, + VoidKeyword = 104, + WhileKeyword = 105, + WithKeyword = 106, + ImplementsKeyword = 107, + InterfaceKeyword = 108, + LetKeyword = 109, + PackageKeyword = 110, + PrivateKeyword = 111, + ProtectedKeyword = 112, + PublicKeyword = 113, + StaticKeyword = 114, + YieldKeyword = 115, + AbstractKeyword = 116, + AsKeyword = 117, + AnyKeyword = 118, + AsyncKeyword = 119, + AwaitKeyword = 120, + BooleanKeyword = 121, + ConstructorKeyword = 122, + DeclareKeyword = 123, + GetKeyword = 124, + IsKeyword = 125, + ModuleKeyword = 126, + NamespaceKeyword = 127, + NeverKeyword = 128, + ReadonlyKeyword = 129, + RequireKeyword = 130, + NumberKeyword = 131, + SetKeyword = 132, + StringKeyword = 133, + SymbolKeyword = 134, + TypeKeyword = 135, + UndefinedKeyword = 136, + FromKeyword = 137, + GlobalKeyword = 138, + OfKeyword = 139, + QualifiedName = 140, + ComputedPropertyName = 141, + TypeParameter = 142, + Parameter = 143, + Decorator = 144, + PropertySignature = 145, + PropertyDeclaration = 146, + MethodSignature = 147, + MethodDeclaration = 148, + Constructor = 149, + GetAccessor = 150, + SetAccessor = 151, + CallSignature = 152, + ConstructSignature = 153, + IndexSignature = 154, + TypePredicate = 155, + TypeReference = 156, + FunctionType = 157, + ConstructorType = 158, + TypeQuery = 159, + TypeLiteral = 160, + ArrayType = 161, + TupleType = 162, + UnionType = 163, + IntersectionType = 164, + ParenthesizedType = 165, + ThisType = 166, + LiteralType = 167, + ObjectBindingPattern = 168, + ArrayBindingPattern = 169, + BindingElement = 170, + ArrayLiteralExpression = 171, + ObjectLiteralExpression = 172, + PropertyAccessExpression = 173, + ElementAccessExpression = 174, + CallExpression = 175, + NewExpression = 176, + TaggedTemplateExpression = 177, + TypeAssertionExpression = 178, + ParenthesizedExpression = 179, + FunctionExpression = 180, + ArrowFunction = 181, + DeleteExpression = 182, + TypeOfExpression = 183, + VoidExpression = 184, + AwaitExpression = 185, + PrefixUnaryExpression = 186, + PostfixUnaryExpression = 187, + BinaryExpression = 188, + ConditionalExpression = 189, + TemplateExpression = 190, + YieldExpression = 191, + SpreadElementExpression = 192, + ClassExpression = 193, + OmittedExpression = 194, + ExpressionWithTypeArguments = 195, + AsExpression = 196, + NonNullExpression = 197, + TemplateSpan = 198, + SemicolonClassElement = 199, + Block = 200, + VariableStatement = 201, + EmptyStatement = 202, + ExpressionStatement = 203, + IfStatement = 204, + DoStatement = 205, + WhileStatement = 206, + ForStatement = 207, + ForInStatement = 208, + ForOfStatement = 209, + ContinueStatement = 210, + BreakStatement = 211, + ReturnStatement = 212, + WithStatement = 213, + SwitchStatement = 214, + LabeledStatement = 215, + ThrowStatement = 216, + TryStatement = 217, + DebuggerStatement = 218, + VariableDeclaration = 219, + VariableDeclarationList = 220, + FunctionDeclaration = 221, + ClassDeclaration = 222, + InterfaceDeclaration = 223, + TypeAliasDeclaration = 224, + EnumDeclaration = 225, + ModuleDeclaration = 226, + ModuleBlock = 227, + CaseBlock = 228, + NamespaceExportDeclaration = 229, + ImportEqualsDeclaration = 230, + ImportDeclaration = 231, + ImportClause = 232, + NamespaceImport = 233, + NamedImports = 234, + ImportSpecifier = 235, + ExportAssignment = 236, + ExportDeclaration = 237, + NamedExports = 238, + ExportSpecifier = 239, + MissingDeclaration = 240, + ExternalModuleReference = 241, + JsxElement = 242, + JsxSelfClosingElement = 243, + JsxOpeningElement = 244, JsxClosingElement = 245, JsxAttribute = 246, JsxSpreadAttribute = 247, @@ -327,31 +327,31 @@ declare namespace ts { NotEmittedStatement = 287, PartiallyEmittedExpression = 288, Count = 289, - FirstAssignment = 56, - LastAssignment = 68, - FirstCompoundAssignment = 57, - LastCompoundAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 138, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 154, - LastTypeNode = 166, - FirstPunctuation = 15, - LastPunctuation = 68, + FirstAssignment = 57, + LastAssignment = 69, + FirstCompoundAssignment = 58, + LastCompoundAssignment = 69, + FirstReservedWord = 71, + LastReservedWord = 106, + FirstKeyword = 71, + LastKeyword = 139, + FirstFutureReservedWord = 107, + LastFutureReservedWord = 115, + FirstTypeNode = 155, + LastTypeNode = 167, + FirstPunctuation = 16, + LastPunctuation = 69, FirstToken = 0, - LastToken = 138, + LastToken = 139, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 139, + LastLiteralToken = 12, + FirstTemplateToken = 12, + LastTemplateToken = 15, + FirstBinaryOperator = 26, + LastBinaryOperator = 69, + FirstNode = 140, FirstJSDocNode = 257, LastJSDocNode = 282, FirstJSDocTagNode = 273, @@ -406,6 +406,7 @@ declare namespace ts { AccessibilityModifier = 28, ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, + TypeScriptModifier = 2270, } enum JsxFlags { None = 0, @@ -1351,8 +1352,9 @@ declare namespace ts { TrueCondition = 32, FalseCondition = 64, SwitchClause = 128, - Referenced = 256, - Shared = 512, + ArrayMutation = 256, + Referenced = 512, + Shared = 1024, Label = 12, Condition = 96, } @@ -1380,6 +1382,10 @@ declare namespace ts { clauseEnd: number; antecedent: FlowNode; } + interface FlowArrayMutation extends FlowNode { + node: CallExpression | BinaryExpression; + antecedent: FlowNode; + } type FlowType = Type | IncompleteType; interface IncompleteType { flags: TypeFlags; @@ -1913,7 +1919,6 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, - ES6 = 5, ES2015 = 5, } enum JsxEmit { @@ -1939,9 +1944,10 @@ declare namespace ts { enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, ES2015 = 2, - Latest = 2, + ES2016 = 3, + ES2017 = 4, + Latest = 4, } enum LanguageVariant { Standard = 0, diff --git a/lib/typescript.js b/lib/typescript.js index c534a7259019f..dad603b624aa2 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -37,259 +37,259 @@ var ts; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 38] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 39] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 40] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 41] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 42] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 43] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 46] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 47] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 48] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 49] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 50] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 51] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 52] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 53] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 54] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 55] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 56] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 57] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 58] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 59] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 60] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 61] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 62] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 63] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 64] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 66] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 67] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 68] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 70] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 71] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 72] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 73] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 74] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 75] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 76] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 77] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 78] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 79] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 80] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 81] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 82] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 83] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 84] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 85] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 86] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 87] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 88] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 89] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 90] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 91] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 92] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 93] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 94] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 95] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 96] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 97] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 98] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 99] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 100] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 101] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 102] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 103] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 104] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 105] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 106] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 107] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 108] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 109] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 110] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 111] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 112] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 113] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 114] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 115] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 116] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 117] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 118] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 119] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 120] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 121] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 122] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 123] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 127] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 128] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 129] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 130] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 131] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 132] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 133] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 134] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 135] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 136] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 137] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 138] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 139] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 140] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 141] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 142] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 143] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 144] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 145] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 146] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 147] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 148] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 149] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 150] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 151] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 152] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 153] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 154] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 155] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 156] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 157] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 158] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 159] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 160] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 161] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 162] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 163] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 164] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 165] = "ThisType"; - SyntaxKind[SyntaxKind["LiteralType"] = 166] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 167] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 168] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 169] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 170] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 171] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 172] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 173] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 174] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 175] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 176] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 177] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 178] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 179] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 180] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 181] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 182] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 183] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 184] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 185] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 186] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 187] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 188] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 189] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 190] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 191] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 192] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 193] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 194] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 195] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 196] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 197] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 198] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 199] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 200] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 201] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 202] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 203] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 204] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 205] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 206] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 207] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 208] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 209] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 210] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 211] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 212] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 213] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 214] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 215] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 216] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 217] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 218] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 219] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 220] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 221] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 222] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 223] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 224] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 225] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 226] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 227] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 228] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 229] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 230] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 231] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 232] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 233] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 234] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 235] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 236] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 237] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 238] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 239] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 240] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 241] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 242] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 243] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 244] = "JsxText"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; @@ -346,31 +346,31 @@ var ts; // Enum value count SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 57] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 68] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 138] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 154] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 166] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 138] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 139] = "FirstNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; @@ -430,6 +430,7 @@ var ts; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; })(ts.ModifierFlags || (ts.ModifierFlags = {})); var ModifierFlags = ts.ModifierFlags; (function (JsxFlags) { @@ -466,8 +467,9 @@ var ts; FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["Referenced"] = 256] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 512] = "Shared"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(ts.FlowFlags || (ts.FlowFlags = {})); @@ -755,7 +757,6 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; @@ -781,9 +782,10 @@ var ts; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; - ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; - ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; })(ts.ScriptTarget || (ts.ScriptTarget = {})); var ScriptTarget = ts.ScriptTarget; (function (LanguageVariant) { @@ -940,55 +942,58 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; - TransformFlags[TransformFlags["ES7"] = 16] = "ES7"; - TransformFlags[TransformFlags["ContainsES7"] = 32] = "ContainsES7"; - TransformFlags[TransformFlags["ES6"] = 64] = "ES6"; - TransformFlags[TransformFlags["ContainsES6"] = 128] = "ContainsES6"; - TransformFlags[TransformFlags["DestructuringAssignment"] = 256] = "DestructuringAssignment"; - TransformFlags[TransformFlags["Generator"] = 512] = "Generator"; - TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsDecorators"] = 2048] = "ContainsDecorators"; - TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 4096] = "ContainsPropertyInitializer"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 16384] = "ContainsCapturedLexicalThis"; - TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 32768] = "ContainsLexicalThisInComputedPropertyName"; - TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 65536] = "ContainsDefaultValueAssignments"; - TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 131072] = "ContainsParameterPropertyAssignments"; - TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 262144] = "ContainsSpreadElementExpression"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 524288] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 1048576] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 2097152] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 4194304] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 8388608] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; - TransformFlags[TransformFlags["AssertES7"] = 48] = "AssertES7"; - TransformFlags[TransformFlags["AssertES6"] = 192] = "AssertES6"; - TransformFlags[TransformFlags["AssertGenerator"] = 1536] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["NodeExcludes"] = 536871765] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 550710101] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 550726485] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 550593365] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 550593365] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537590613] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546335573] = "ModuleExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537430869] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537133909] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 538968917] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 538968917] = "ParameterExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; // Masks // - Additional bitmasks - TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 137216] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES6FunctionSyntaxMask"] = 81920] = "ES6FunctionSyntaxMask"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; })(ts.TransformFlags || (ts.TransformFlags = {})); var TransformFlags = ts.TransformFlags; /* @internal */ @@ -1044,7 +1049,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -1146,6 +1151,8 @@ var ts; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; var createObject = Object.create; + // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. @@ -1171,7 +1178,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -1378,13 +1385,33 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + // Maps from T to T and avoids allocation if all elements map to themselves + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; /** * Flattens an array containing a mix of array or non-array elements. * @@ -1507,6 +1534,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -1520,8 +1559,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -1557,8 +1596,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -1857,8 +1896,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -1971,7 +2010,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -2002,7 +2041,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -2027,12 +2066,12 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; /* internal */ - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -2095,7 +2134,8 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { + // accent means a ≠ b, a ≠ á, a = A var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } @@ -2269,7 +2309,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; /* @internal */ @@ -2617,7 +2657,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -2632,7 +2672,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -2847,10 +2887,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -3230,7 +3270,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -3462,7 +3502,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { // encoding is automatically handled by the implementation in ChakraHost return ChakraHost.readFile(path); }, @@ -3480,9 +3520,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -4276,7 +4316,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4313,7 +4353,7 @@ var ts; 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" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); /// @@ -4322,133 +4362,133 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 69 /* Identifier */; + return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "abstract": 115 /* AbstractKeyword */, - "any": 117 /* AnyKeyword */, - "as": 116 /* AsKeyword */, - "boolean": 120 /* BooleanKeyword */, - "break": 70 /* BreakKeyword */, - "case": 71 /* CaseKeyword */, - "catch": 72 /* CatchKeyword */, - "class": 73 /* ClassKeyword */, - "continue": 75 /* ContinueKeyword */, - "const": 74 /* ConstKeyword */, - "constructor": 121 /* ConstructorKeyword */, - "debugger": 76 /* DebuggerKeyword */, - "declare": 122 /* DeclareKeyword */, - "default": 77 /* DefaultKeyword */, - "delete": 78 /* DeleteKeyword */, - "do": 79 /* DoKeyword */, - "else": 80 /* ElseKeyword */, - "enum": 81 /* EnumKeyword */, - "export": 82 /* ExportKeyword */, - "extends": 83 /* ExtendsKeyword */, - "false": 84 /* FalseKeyword */, - "finally": 85 /* FinallyKeyword */, - "for": 86 /* ForKeyword */, - "from": 136 /* FromKeyword */, - "function": 87 /* FunctionKeyword */, - "get": 123 /* GetKeyword */, - "if": 88 /* IfKeyword */, - "implements": 106 /* ImplementsKeyword */, - "import": 89 /* ImportKeyword */, - "in": 90 /* InKeyword */, - "instanceof": 91 /* InstanceOfKeyword */, - "interface": 107 /* InterfaceKeyword */, - "is": 124 /* IsKeyword */, - "let": 108 /* LetKeyword */, - "module": 125 /* ModuleKeyword */, - "namespace": 126 /* NamespaceKeyword */, - "never": 127 /* NeverKeyword */, - "new": 92 /* NewKeyword */, - "null": 93 /* NullKeyword */, - "number": 130 /* NumberKeyword */, - "package": 109 /* PackageKeyword */, - "private": 110 /* PrivateKeyword */, - "protected": 111 /* ProtectedKeyword */, - "public": 112 /* PublicKeyword */, - "readonly": 128 /* ReadonlyKeyword */, - "require": 129 /* RequireKeyword */, - "global": 137 /* GlobalKeyword */, - "return": 94 /* ReturnKeyword */, - "set": 131 /* SetKeyword */, - "static": 113 /* StaticKeyword */, - "string": 132 /* StringKeyword */, - "super": 95 /* SuperKeyword */, - "switch": 96 /* SwitchKeyword */, - "symbol": 133 /* SymbolKeyword */, - "this": 97 /* ThisKeyword */, - "throw": 98 /* ThrowKeyword */, - "true": 99 /* TrueKeyword */, - "try": 100 /* TryKeyword */, - "type": 134 /* TypeKeyword */, - "typeof": 101 /* TypeOfKeyword */, - "undefined": 135 /* UndefinedKeyword */, - "var": 102 /* VarKeyword */, - "void": 103 /* VoidKeyword */, - "while": 104 /* WhileKeyword */, - "with": 105 /* WithKeyword */, - "yield": 114 /* YieldKeyword */, - "async": 118 /* AsyncKeyword */, - "await": 119 /* AwaitKeyword */, - "of": 138 /* OfKeyword */, - "{": 15 /* OpenBraceToken */, - "}": 16 /* CloseBraceToken */, - "(": 17 /* OpenParenToken */, - ")": 18 /* CloseParenToken */, - "[": 19 /* OpenBracketToken */, - "]": 20 /* CloseBracketToken */, - ".": 21 /* DotToken */, - "...": 22 /* DotDotDotToken */, - ";": 23 /* SemicolonToken */, - ",": 24 /* CommaToken */, - "<": 25 /* LessThanToken */, - ">": 27 /* GreaterThanToken */, - "<=": 28 /* LessThanEqualsToken */, - ">=": 29 /* GreaterThanEqualsToken */, - "==": 30 /* EqualsEqualsToken */, - "!=": 31 /* ExclamationEqualsToken */, - "===": 32 /* EqualsEqualsEqualsToken */, - "!==": 33 /* ExclamationEqualsEqualsToken */, - "=>": 34 /* EqualsGreaterThanToken */, - "+": 35 /* PlusToken */, - "-": 36 /* MinusToken */, - "**": 38 /* AsteriskAsteriskToken */, - "*": 37 /* AsteriskToken */, - "/": 39 /* SlashToken */, - "%": 40 /* PercentToken */, - "++": 41 /* PlusPlusToken */, - "--": 42 /* MinusMinusToken */, - "<<": 43 /* LessThanLessThanToken */, - ">": 44 /* GreaterThanGreaterThanToken */, - ">>>": 45 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 46 /* AmpersandToken */, - "|": 47 /* BarToken */, - "^": 48 /* CaretToken */, - "!": 49 /* ExclamationToken */, - "~": 50 /* TildeToken */, - "&&": 51 /* AmpersandAmpersandToken */, - "||": 52 /* BarBarToken */, - "?": 53 /* QuestionToken */, - ":": 54 /* ColonToken */, - "=": 56 /* EqualsToken */, - "+=": 57 /* PlusEqualsToken */, - "-=": 58 /* MinusEqualsToken */, - "*=": 59 /* AsteriskEqualsToken */, - "**=": 60 /* AsteriskAsteriskEqualsToken */, - "/=": 61 /* SlashEqualsToken */, - "%=": 62 /* PercentEqualsToken */, - "<<=": 63 /* LessThanLessThanEqualsToken */, - ">>=": 64 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 66 /* AmpersandEqualsToken */, - "|=": 67 /* BarEqualsToken */, - "^=": 68 /* CaretEqualsToken */, - "@": 55 /* AtToken */ + "abstract": 116 /* AbstractKeyword */, + "any": 118 /* AnyKeyword */, + "as": 117 /* AsKeyword */, + "boolean": 121 /* BooleanKeyword */, + "break": 71 /* BreakKeyword */, + "case": 72 /* CaseKeyword */, + "catch": 73 /* CatchKeyword */, + "class": 74 /* ClassKeyword */, + "continue": 76 /* ContinueKeyword */, + "const": 75 /* ConstKeyword */, + "constructor": 122 /* ConstructorKeyword */, + "debugger": 77 /* DebuggerKeyword */, + "declare": 123 /* DeclareKeyword */, + "default": 78 /* DefaultKeyword */, + "delete": 79 /* DeleteKeyword */, + "do": 80 /* DoKeyword */, + "else": 81 /* ElseKeyword */, + "enum": 82 /* EnumKeyword */, + "export": 83 /* ExportKeyword */, + "extends": 84 /* ExtendsKeyword */, + "false": 85 /* FalseKeyword */, + "finally": 86 /* FinallyKeyword */, + "for": 87 /* ForKeyword */, + "from": 137 /* FromKeyword */, + "function": 88 /* FunctionKeyword */, + "get": 124 /* GetKeyword */, + "if": 89 /* IfKeyword */, + "implements": 107 /* ImplementsKeyword */, + "import": 90 /* ImportKeyword */, + "in": 91 /* InKeyword */, + "instanceof": 92 /* InstanceOfKeyword */, + "interface": 108 /* InterfaceKeyword */, + "is": 125 /* IsKeyword */, + "let": 109 /* LetKeyword */, + "module": 126 /* ModuleKeyword */, + "namespace": 127 /* NamespaceKeyword */, + "never": 128 /* NeverKeyword */, + "new": 93 /* NewKeyword */, + "null": 94 /* NullKeyword */, + "number": 131 /* NumberKeyword */, + "package": 110 /* PackageKeyword */, + "private": 111 /* PrivateKeyword */, + "protected": 112 /* ProtectedKeyword */, + "public": 113 /* PublicKeyword */, + "readonly": 129 /* ReadonlyKeyword */, + "require": 130 /* RequireKeyword */, + "global": 138 /* GlobalKeyword */, + "return": 95 /* ReturnKeyword */, + "set": 132 /* SetKeyword */, + "static": 114 /* StaticKeyword */, + "string": 133 /* StringKeyword */, + "super": 96 /* SuperKeyword */, + "switch": 97 /* SwitchKeyword */, + "symbol": 134 /* SymbolKeyword */, + "this": 98 /* ThisKeyword */, + "throw": 99 /* ThrowKeyword */, + "true": 100 /* TrueKeyword */, + "try": 101 /* TryKeyword */, + "type": 135 /* TypeKeyword */, + "typeof": 102 /* TypeOfKeyword */, + "undefined": 136 /* UndefinedKeyword */, + "var": 103 /* VarKeyword */, + "void": 104 /* VoidKeyword */, + "while": 105 /* WhileKeyword */, + "with": 106 /* WithKeyword */, + "yield": 115 /* YieldKeyword */, + "async": 119 /* AsyncKeyword */, + "await": 120 /* AwaitKeyword */, + "of": 139 /* OfKeyword */, + "{": 16 /* OpenBraceToken */, + "}": 17 /* CloseBraceToken */, + "(": 18 /* OpenParenToken */, + ")": 19 /* CloseParenToken */, + "[": 20 /* OpenBracketToken */, + "]": 21 /* CloseBracketToken */, + ".": 22 /* DotToken */, + "...": 23 /* DotDotDotToken */, + ";": 24 /* SemicolonToken */, + ",": 25 /* CommaToken */, + "<": 26 /* LessThanToken */, + ">": 28 /* GreaterThanToken */, + "<=": 29 /* LessThanEqualsToken */, + ">=": 30 /* GreaterThanEqualsToken */, + "==": 31 /* EqualsEqualsToken */, + "!=": 32 /* ExclamationEqualsToken */, + "===": 33 /* EqualsEqualsEqualsToken */, + "!==": 34 /* ExclamationEqualsEqualsToken */, + "=>": 35 /* EqualsGreaterThanToken */, + "+": 36 /* PlusToken */, + "-": 37 /* MinusToken */, + "**": 39 /* AsteriskAsteriskToken */, + "*": 38 /* AsteriskToken */, + "/": 40 /* SlashToken */, + "%": 41 /* PercentToken */, + "++": 42 /* PlusPlusToken */, + "--": 43 /* MinusMinusToken */, + "<<": 44 /* LessThanLessThanToken */, + ">": 45 /* GreaterThanGreaterThanToken */, + ">>>": 46 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 47 /* AmpersandToken */, + "|": 48 /* BarToken */, + "^": 49 /* CaretToken */, + "!": 50 /* ExclamationToken */, + "~": 51 /* TildeToken */, + "&&": 52 /* AmpersandAmpersandToken */, + "||": 53 /* BarBarToken */, + "?": 54 /* QuestionToken */, + ":": 55 /* ColonToken */, + "=": 57 /* EqualsToken */, + "+=": 58 /* PlusEqualsToken */, + "-=": 59 /* MinusEqualsToken */, + "*=": 60 /* AsteriskEqualsToken */, + "**=": 61 /* AsteriskAsteriskEqualsToken */, + "/=": 62 /* SlashEqualsToken */, + "%=": 63 /* PercentEqualsToken */, + "<<=": 64 /* LessThanLessThanEqualsToken */, + ">>=": 65 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 67 /* AmpersandEqualsToken */, + "|=": 68 /* BarEqualsToken */, + "^=": 69 /* CaretEqualsToken */, + "@": 56 /* AtToken */, }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -4952,7 +4992,7 @@ var ts; return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -5025,8 +5065,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, + isIdentifier: function () { return token === 70 /* Identifier */ || token > 106 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -5045,7 +5085,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -5174,7 +5214,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -5182,14 +5222,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 13 /* TemplateHead */ : 14 /* TemplateMiddle */; break; } // Escape character @@ -5367,7 +5407,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -5447,12 +5487,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 34 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 31 /* ExclamationEqualsToken */; + return pos += 2, token = 32 /* ExclamationEqualsToken */; } pos++; - return token = 49 /* ExclamationToken */; + return token = 50 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -5461,68 +5501,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* PercentEqualsToken */; + return pos += 2, token = 63 /* PercentEqualsToken */; } pos++; - return token = 40 /* PercentToken */; + return token = 41 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 51 /* AmpersandAmpersandToken */; + return pos += 2, token = 52 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AmpersandEqualsToken */; + return pos += 2, token = 67 /* AmpersandEqualsToken */; } pos++; - return token = 46 /* AmpersandToken */; + return token = 47 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 17 /* OpenParenToken */; + return token = 18 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 18 /* CloseParenToken */; + return token = 19 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* AsteriskEqualsToken */; + return pos += 2, token = 60 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 61 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 38 /* AsteriskAsteriskToken */; + return pos += 2, token = 39 /* AsteriskAsteriskToken */; } pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 41 /* PlusPlusToken */; + return pos += 2, token = 42 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* PlusEqualsToken */; + return pos += 2, token = 58 /* PlusEqualsToken */; } pos++; - return token = 35 /* PlusToken */; + return token = 36 /* PlusToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 42 /* MinusMinusToken */; + return pos += 2, token = 43 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* MinusEqualsToken */; + return pos += 2, token = 59 /* MinusEqualsToken */; } pos++; - return token = 36 /* MinusToken */; + return token = 37 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 22 /* DotDotDotToken */; + return pos += 3, token = 23 /* DotDotDotToken */; } pos++; - return token = 21 /* DotToken */; + return token = 22 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -5568,10 +5608,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* SlashEqualsToken */; + return pos += 2, token = 62 /* SlashEqualsToken */; } pos++; - return token = 39 /* SlashToken */; + return token = 40 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -5624,10 +5664,10 @@ var ts; return token = 8 /* NumericLiteral */; case 58 /* colon */: pos++; - return token = 54 /* ColonToken */; + return token = 55 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 23 /* SemicolonToken */; + return token = 24 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5640,20 +5680,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 64 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 43 /* LessThanLessThanToken */; + return pos += 2, token = 44 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 28 /* LessThanEqualsToken */; + return pos += 2, token = 29 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 26 /* LessThanSlashToken */; + return pos += 2, token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5666,15 +5706,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 33 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 30 /* EqualsEqualsToken */; + return pos += 2, token = 31 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 34 /* EqualsGreaterThanToken */; + return pos += 2, token = 35 /* EqualsGreaterThanToken */; } pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5686,43 +5726,43 @@ var ts; } } pos++; - return token = 27 /* GreaterThanToken */; + return token = 28 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 53 /* QuestionToken */; + return token = 54 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* CaretEqualsToken */; + return pos += 2, token = 69 /* CaretEqualsToken */; } pos++; - return token = 48 /* CaretToken */; + return token = 49 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 52 /* BarBarToken */; + return pos += 2, token = 53 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* BarEqualsToken */; + return pos += 2, token = 68 /* BarEqualsToken */; } pos++; - return token = 47 /* BarToken */; + return token = 48 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 50 /* TildeToken */; + return token = 51 /* TildeToken */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -5760,29 +5800,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27 /* GreaterThanToken */) { + if (token === 28 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 46 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 65 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 44 /* GreaterThanGreaterThanToken */; + return token = 45 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 29 /* GreaterThanEqualsToken */; + return token = 30 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { + if (token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -5827,7 +5867,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10 /* RegularExpressionLiteral */; + token = 11 /* RegularExpressionLiteral */; } return token; } @@ -5835,7 +5875,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -5852,14 +5892,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 26 /* LessThanSlashToken */; + return token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -5868,7 +5908,7 @@ var ts; break; } } - return token = 244 /* JsxText */; + return token = 10 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -5918,39 +5958,39 @@ var ts; return token = 5 /* WhitespaceTrivia */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: pos++; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 61 /* equals */: pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; } - if (isIdentifierStart(ch, 2 /* Latest */)) { + if (isIdentifierStart(ch, 4 /* Latest */)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2 /* Latest */) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4 /* Latest */) && pos < end) { pos++; } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } else { return pos += 1, token = 0 /* Unknown */; @@ -6189,11 +6229,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return true; } return false; @@ -6329,14 +6369,14 @@ var ts; function getLiteralText(node, sourceFile, languageVersion) { // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < 2 /* ES6 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + if (languageVersion < 2 /* ES2015 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { return getQuotedEscapedLiteralText('"', node.text, '"'); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + if (languageVersion < 2 /* ES2015 */ && isBinaryOrOctalIntegerLiteral(node, text)) { return node.text; } return text; @@ -6346,13 +6386,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: + case 14 /* TemplateMiddle */: return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: + case 15 /* TemplateTail */: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8 /* NumericLiteral */: return node.text; @@ -6398,7 +6438,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 /* ModuleDeclaration */ && + return node && node.kind === 226 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6408,11 +6448,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 === 225 /* ModuleDeclaration */ && (!node.body); + return node.kind === 226 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 /* SourceFile */ || - node.kind === 225 /* ModuleDeclaration */ || + node.kind === 226 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6430,7 +6470,7 @@ var ts; switch (node.parent.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node.parent); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6439,21 +6479,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: case 252 /* CatchClause */: - case 225 /* ModuleDeclaration */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 226 /* ModuleDeclaration */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return true; - case 199 /* Block */: + case 200 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6475,7 +6515,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 /* VariableDeclaration */ && + declaration.kind === 219 /* VariableDeclaration */ && declaration.parent && declaration.parent.kind === 252 /* CatchClause */; } @@ -6515,7 +6555,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199 /* Block */) { + if (node.body && node.body.kind === 200 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6538,23 +6578,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 224 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6577,7 +6617,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 /* EnumDeclaration */ && isConst(node); + return node.kind === 225 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6590,11 +6630,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 203 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6610,10 +6650,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 /* Parameter */ || - node.kind === 141 /* TypeParameter */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 180 /* ArrowFunction */) ? + var commentRanges = (node.kind === 143 /* Parameter */ || + node.kind === 142 /* TypeParameter */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 181 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6629,39 +6669,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 /* FirstTypeNode */ <= node.kind && node.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= node.kind && node.kind <= 167 /* LastTypeNode */) { return true; } switch (node.kind) { - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return true; - case 103 /* VoidKeyword */: - return node.parent.kind !== 183 /* VoidExpression */; - case 194 /* ExpressionWithTypeArguments */: + case 104 /* VoidKeyword */: + return node.parent.kind !== 184 /* VoidExpression */; + case 195 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 69 /* Identifier */: + case 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139 /* QualifiedName */: - case 172 /* PropertyAccessExpression */: - case 97 /* ThisKeyword */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 98 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 158 /* TypeQuery */) { + if (parent_1.kind === 159 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -6670,38 +6710,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (154 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 167 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return node === parent_1.constraint; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: return node === parent_1.type; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node === parent_1.type; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return node === parent_1.type; - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return node === parent_1.type; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6715,22 +6755,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitor(node); - case 227 /* CaseBlock */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 228 /* CaseBlock */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: case 250 /* DefaultClause */: - case 214 /* LabeledStatement */: - case 216 /* TryStatement */: + case 215 /* LabeledStatement */: + case 217 /* TryStatement */: case 252 /* CatchClause */: return ts.forEachChild(node, traverse); } @@ -6741,18 +6781,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* 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 // skipped in this traversal. @@ -6760,7 +6800,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 140 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 141 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -6779,14 +6819,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: case 255 /* EnumMember */: - case 142 /* Parameter */: + case 143 /* Parameter */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 254 /* ShorthandPropertyAssignment */: - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return true; } } @@ -6794,11 +6834,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */); + return node && (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */); + return node && (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6807,19 +6847,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return true; } return false; @@ -6827,13 +6867,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return true; } return false; @@ -6841,30 +6881,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return true; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 200 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 /* MethodDeclaration */ && node.parent.kind === 171 /* ObjectLiteralExpression */; + return node && node.kind === 148 /* MethodDeclaration */ && node.parent.kind === 172 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 /* MethodDeclaration */ && - (node.parent.kind === 171 /* ObjectLiteralExpression */ || - node.parent.kind === 192 /* ClassExpression */); + return node.kind === 148 /* MethodDeclaration */ && + (node.parent.kind === 172 /* ObjectLiteralExpression */ || + node.parent.kind === 193 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6900,7 +6940,7 @@ var ts; return undefined; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -6915,9 +6955,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -6928,25 +6968,25 @@ var ts; node = node.parent; } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 225 /* ModuleDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 226 /* ModuleDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 225 /* EnumDeclaration */: case 256 /* SourceFile */: return node; } @@ -6968,26 +7008,26 @@ var ts; return node; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: node = node.parent; break; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -7003,14 +7043,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */) { + if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 178 /* ParenthesizedExpression */) { + while (parent_2.kind === 179 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 174 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7021,20 +7061,20 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 /* PropertyAccessExpression */ || kind === 173 /* ElementAccessExpression */) - && node.expression.kind === 95 /* SuperKeyword */; + return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: return node; } } @@ -7043,10 +7083,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 143 /* Decorator */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 144 /* Decorator */: return true; default: return false; @@ -7054,7 +7094,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7063,25 +7103,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // classes are valid targets return true; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 221 /* ClassDeclaration */; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + return node.parent.kind === 222 /* ClassDeclaration */; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* 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 === 221 /* ClassDeclaration */; - case 142 /* Parameter */: + && node.parent.kind === 222 /* ClassDeclaration */; + case 143 /* 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 === 148 /* Constructor */ - || node.parent.kind === 147 /* MethodDeclaration */ - || node.parent.kind === 150 /* SetAccessor */) - && node.parent.parent.kind === 221 /* ClassDeclaration */; + && (node.parent.kind === 149 /* Constructor */ + || node.parent.kind === 148 /* MethodDeclaration */ + || node.parent.kind === 151 /* SetAccessor */) + && node.parent.parent.kind === 222 /* ClassDeclaration */; } return false; } @@ -7097,18 +7137,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147 /* MethodDeclaration */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 151 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 /* JsxOpeningElement */ || - parent.kind === 242 /* JsxSelfClosingElement */ || + if (parent.kind === 244 /* JsxOpeningElement */ || + parent.kind === 243 /* JsxSelfClosingElement */ || parent.kind === 245 /* JsxClosingElement */) { return parent.tagName === node; } @@ -7117,98 +7157,98 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 10 /* RegularExpressionLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 195 /* AsExpression */: - case 177 /* TypeAssertionExpression */: - case 196 /* NonNullExpression */: - case 178 /* ParenthesizedExpression */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 191 /* SpreadElementExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 193 /* OmittedExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 190 /* YieldExpression */: - case 184 /* AwaitExpression */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 11 /* RegularExpressionLiteral */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 196 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 197 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 192 /* SpreadElementExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 194 /* OmittedExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 191 /* YieldExpression */: + case 185 /* AwaitExpression */: return true; - case 139 /* QualifiedName */: - while (node.parent.kind === 139 /* QualifiedName */) { + case 140 /* QualifiedName */: + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node); - case 69 /* Identifier */: - if (node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node); + case 70 /* Identifier */: + if (node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: return parent_3.initializer === node; - case 202 /* ExpressionStatement */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 211 /* ReturnStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 203 /* ExpressionStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 212 /* ReturnStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: - case 215 /* ThrowStatement */: - case 213 /* SwitchStatement */: + case 216 /* ThrowStatement */: + case 214 /* SwitchStatement */: return parent_3.expression === node; - case 206 /* ForStatement */: + case 207 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forInStatement.expression === node; - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return node === parent_3.expression; - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return node === parent_3.expression; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return node === parent_3.expression; - case 143 /* Decorator */: + case 144 /* Decorator */: case 248 /* JsxExpression */: case 247 /* JsxSpreadAttribute */: return true; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7226,7 +7266,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7235,7 +7275,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7253,8 +7293,8 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 174 /* CallExpression */ && - expression.expression.kind === 69 /* Identifier */ && + var isRequire = expression.kind === 175 /* CallExpression */ && + expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); @@ -7269,9 +7309,9 @@ 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 === 218 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; } return false; } @@ -7282,15 +7322,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 187 /* BinaryExpression */) { + if (expression.kind !== 188 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 172 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 173 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; - if (lhs.expression.kind === 69 /* Identifier */) { + if (lhs.expression.kind === 70 /* Identifier */) { var lhsId = lhs.expression; if (lhsId.text === "exports") { // exports.name = expr @@ -7301,13 +7341,13 @@ var ts; return 2 /* ModuleExports */; } } - else if (lhs.expression.kind === 97 /* ThisKeyword */) { + else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 172 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 173 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69 /* Identifier */) { + if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { // module.exports.name = expr var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { @@ -7322,35 +7362,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 240 /* ExternalModuleReference */) { + if (reference.kind === 241 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 236 /* ExportDeclaration */) { + if (node.kind === 237 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 225 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 /* ImportDeclaration */ + return node.kind === 231 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7358,13 +7398,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142 /* Parameter */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 143 /* Parameter */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: case 254 /* ShorthandPropertyAssignment */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7434,25 +7474,25 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.parent.kind === 201 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.kind === 201 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 /* ModuleDeclaration */ && - node.parent && node.parent.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 226 /* ModuleDeclaration */) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 /* BinaryExpression */ && - parent_4.operatorToken.kind === 56 /* EqualsToken */ && - parent_4.parent.kind === 202 /* ExpressionStatement */; + parent_4.kind === 188 /* BinaryExpression */ && + parent_4.operatorToken.kind === 57 /* EqualsToken */ && + parent_4.parent.kind === 203 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -7461,7 +7501,7 @@ var ts; result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } // Pull parameter comments from declaring function as well - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7492,7 +7532,7 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69 /* Identifier */) { + else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { @@ -7518,7 +7558,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69 /* Identifier */) { + if (parameter.name && parameter.name.kind === 70 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; @@ -7568,12 +7608,12 @@ var ts; // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */) { node = node.parent; } while (true) { var parent_5 = node.parent; - if (parent_5.kind === 170 /* ArrayLiteralExpression */ || parent_5.kind === 191 /* SpreadElementExpression */) { + if (parent_5.kind === 171 /* ArrayLiteralExpression */ || parent_5.kind === 192 /* SpreadElementExpression */) { node = parent_5; continue; } @@ -7581,10 +7621,10 @@ var ts; node = parent_5.parent; continue; } - return parent_5.kind === 187 /* BinaryExpression */ && + return parent_5.kind === 188 /* BinaryExpression */ && isAssignmentOperator(parent_5.operatorToken.kind) && parent_5.left === node || - (parent_5.kind === 207 /* ForInStatement */ || parent_5.kind === 208 /* ForOfStatement */) && + (parent_5.kind === 208 /* ForInStatement */ || parent_5.kind === 209 /* ForOfStatement */) && parent_5.initializer === node; } } @@ -7610,11 +7650,11 @@ var ts; ts.isInAmbientContext = isInAmbientContext; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 70 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 234 /* ImportSpecifier */ || parent.kind === 238 /* ExportSpecifier */) { + if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7627,7 +7667,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 140 /* ComputedPropertyName */ && + node.parent.kind === 141 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -7635,31 +7675,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 139 /* QualifiedName */) { + while (parent.kind === 140 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 158 /* TypeQuery */; + return parent.kind === 159 /* TypeQuery */; } return false; - case 169 /* BindingElement */: - case 234 /* ImportSpecifier */: + case 170 /* BindingElement */: + case 235 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7675,13 +7715,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 228 /* NamespaceExportDeclaration */ || - node.kind === 231 /* ImportClause */ && !!node.name || - node.kind === 232 /* NamespaceImport */ || - node.kind === 234 /* ImportSpecifier */ || - node.kind === 238 /* ExportSpecifier */ || - node.kind === 235 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 229 /* NamespaceExportDeclaration */ || + node.kind === 232 /* ImportClause */ && !!node.name || + node.kind === 233 /* NamespaceImport */ || + node.kind === 235 /* ImportSpecifier */ || + node.kind === 239 /* ExportSpecifier */ || + node.kind === 236 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7689,17 +7729,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 107 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -7767,7 +7807,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 138 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 139 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -7794,7 +7834,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 /* ComputedPropertyName */ && + return name.kind === 141 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -7809,10 +7849,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 142 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 143 /* Parameter */) { return name.text; } - if (name.kind === 140 /* ComputedPropertyName */) { + if (name.kind === 141 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -7833,22 +7873,26 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 69 /* Identifier */ && node.text === "Symbol"; + return node.kind === 70 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 122 /* DeclareKeyword */: - case 77 /* DefaultKeyword */: - case 82 /* ExportKeyword */: - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 128 /* ReadonlyKeyword */: - case 113 /* StaticKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 114 /* StaticKeyword */: return true; } return false; @@ -7856,11 +7900,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142 /* Parameter */; + return root.kind === 143 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169 /* BindingElement */) { + while (node.kind === 170 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7868,14 +7912,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 179 /* FunctionExpression */ - || kind === 220 /* FunctionDeclaration */ - || kind === 180 /* ArrowFunction */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 225 /* ModuleDeclaration */ + return kind === 149 /* Constructor */ + || kind === 180 /* FunctionExpression */ + || kind === 221 /* FunctionDeclaration */ + || kind === 181 /* ArrowFunction */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 226 /* ModuleDeclaration */ || kind === 256 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -7937,38 +7981,38 @@ var ts; var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: - case 188 /* ConditionalExpression */: - case 190 /* YieldExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: + case 189 /* ConditionalExpression */: + case 191 /* YieldExpression */: return 1 /* Right */; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operator) { - case 38 /* AsteriskAsteriskToken */: - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 39 /* AsteriskAsteriskToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 1 /* Right */; } } @@ -7977,15 +8021,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187 /* BinaryExpression */) { + if (expression.kind === 188 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 185 /* PrefixUnaryExpression */ || expression.kind === 186 /* PostfixUnaryExpression */) { + else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -7995,106 +8039,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 69 /* Identifier */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 70 /* Identifier */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 189 /* TemplateExpression */: - case 178 /* ParenthesizedExpression */: - case 193 /* OmittedExpression */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 190 /* TemplateExpression */: + case 179 /* ParenthesizedExpression */: + case 194 /* OmittedExpression */: return 19; - case 176 /* TaggedTemplateExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 177 /* TaggedTemplateExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: return 18; - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 18 : 17; - case 174 /* CallExpression */: + case 175 /* CallExpression */: return 17; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return 16; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: return 15; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operatorKind) { - case 49 /* ExclamationToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 51 /* TildeToken */: return 15; - case 38 /* AsteriskAsteriskToken */: - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 39 /* AsteriskAsteriskToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 14; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 13; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 25 /* LessThanToken */: - case 28 /* LessThanEqualsToken */: - case 27 /* GreaterThanToken */: - case 29 /* GreaterThanEqualsToken */: - case 90 /* InKeyword */: - case 91 /* InstanceOfKeyword */: + case 26 /* LessThanToken */: + case 29 /* LessThanEqualsToken */: + case 28 /* GreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 91 /* InKeyword */: + case 92 /* InstanceOfKeyword */: return 11; - case 30 /* EqualsEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 10; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 9; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 8; - case 47 /* BarToken */: + case 48 /* BarToken */: return 7; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 6; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 5; - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 3; - case 24 /* CommaToken */: + case 25 /* CommaToken */: return 0; default: return -1; } - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return 4; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return 2; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return 1; default: return -1; @@ -8395,7 +8439,7 @@ var ts; var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -8427,7 +8471,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -8533,7 +8577,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8561,11 +8605,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 /* Identifier */ && identifierIsThisKeyword(node); + return node && node.kind === 70 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97 /* ThisKeyword */; + return id.originalKeywordKind === 98 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -8575,10 +8619,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 150 /* SetAccessor */) { + else if (accessor.kind === 151 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8587,7 +8631,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 /* GetAccessor */ || member.kind === 150 /* SetAccessor */) + if ((member.kind === 150 /* GetAccessor */ || member.kind === 151 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8598,10 +8642,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 /* GetAccessor */ && !getAccessor) { + if (member.kind === 150 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 150 /* SetAccessor */ && !setAccessor) { + if (member.kind === 151 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -8837,35 +8881,35 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 32 /* Static */; - case 112 /* PublicKeyword */: return 4 /* Public */; - case 111 /* ProtectedKeyword */: return 16 /* Protected */; - case 110 /* PrivateKeyword */: return 8 /* Private */; - case 115 /* AbstractKeyword */: return 128 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 2048 /* Const */; - case 77 /* DefaultKeyword */: return 512 /* Default */; - case 118 /* AsyncKeyword */: return 256 /* Async */; - case 128 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 114 /* StaticKeyword */: return 32 /* Static */; + case 113 /* PublicKeyword */: return 4 /* Public */; + case 112 /* ProtectedKeyword */: return 16 /* Protected */; + case 111 /* PrivateKeyword */: return 8 /* Private */; + case 116 /* AbstractKeyword */: return 128 /* Abstract */; + case 83 /* ExportKeyword */: return 1 /* Export */; + case 123 /* DeclareKeyword */: return 2 /* Ambient */; + case 75 /* ConstKeyword */: return 2048 /* Const */; + case 78 /* DefaultKeyword */: return 512 /* Default */; + case 119 /* AsyncKeyword */: return 256 /* Async */; + case 129 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 /* BarBarToken */ - || token === 51 /* AmpersandAmpersandToken */ - || token === 49 /* ExclamationToken */; + return token === 53 /* BarBarToken */ + || token === 52 /* AmpersandAmpersandToken */ + || token === 50 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; + return token >= 57 /* FirstAssignment */ && token <= 69 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ && - node.parent.token === 83 /* ExtendsKeyword */ && + if (node.kind === 195 /* ExpressionWithTypeArguments */ && + node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -8873,10 +8917,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.operatorToken.kind === 57 /* EqualsToken */) { var kind = node.left.kind; - return kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; + return kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; } } return false; @@ -8889,7 +8933,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { return true; } else if (isPropertyAccessExpression(node)) { @@ -8904,21 +8948,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 /* Identifier */ || - node.kind === 172 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + return node.kind === 70 /* Identifier */ || + node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171 /* ObjectLiteralExpression */) { + if (kind === 172 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 170 /* ArrayLiteralExpression */) { + if (kind === 171 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9070,49 +9114,49 @@ var ts; var kind = node.kind; if (kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 10 /* RegularExpressionLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 69 /* Identifier */ - || kind === 97 /* ThisKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */) { + || kind === 11 /* RegularExpressionLiteral */ + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 70 /* Identifier */ + || kind === 98 /* ThisKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 172 /* PropertyAccessExpression */) { + else if (kind === 173 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173 /* ElementAccessExpression */) { + else if (kind === 174 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */) { + else if (kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187 /* BinaryExpression */) { - return node.operatorToken.kind !== 38 /* AsteriskAsteriskToken */ + else if (kind === 188 /* BinaryExpression */) { + return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188 /* ConditionalExpression */) { + else if (kind === 189 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 /* VoidExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 181 /* DeleteExpression */) { + else if (kind === 184 /* VoidExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 182 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170 /* ArrayLiteralExpression */) { + else if (kind === 171 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 171 /* ObjectLiteralExpression */) { + else if (kind === 172 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 174 /* CallExpression */) { + else if (kind === 175 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9271,7 +9315,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -9279,33 +9323,28 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 230 /* ImportDeclaration */: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { - // import "mod" - // import x from "mod" where x is referenced - // import * as x from "mod" where x is referenced - // import { x, y } from "mod" where at least one import is referenced - externalImports.push(node); - } + case 231 /* ImportDeclaration */: + // import "mod" + // import x from "mod" + // import * as x from "mod" + // import { x, y } from "mod" + externalImports.push(node); break; - case 229 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 240 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced + case 230 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + // import x = require("mod") externalImports.push(node); } break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol + else { + // export { x, y } from "mod" externalImports.push(node); } } @@ -9318,7 +9357,7 @@ var ts; } } break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -9343,7 +9382,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 === 221 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 222 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9373,15 +9412,15 @@ var ts; ts.isNodeArray = isNodeArray; // Literals function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11 /* NoSubstitutionTemplateLiteral */; + return node.kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 12 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9390,22 +9429,22 @@ var ts; ts.isLiteralExpression = isLiteralExpression; // Pseudo-literals function isTemplateLiteralKind(kind) { - return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; + return 12 /* FirstTemplateToken */ <= kind && kind <= 15 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12 /* TemplateHead */; + return node.kind === 13 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 /* TemplateMiddle */ - || kind === 14 /* TemplateTail */; + return kind === 14 /* TemplateMiddle */ + || kind === 15 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { - return node.kind === 69 /* Identifier */; + return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -9420,90 +9459,90 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 139 /* QualifiedName */; + return node.kind === 140 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140 /* ComputedPropertyName */; + return node.kind === 141 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 140 /* ComputedPropertyName */; + || kind === 141 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 167 /* ObjectBindingPattern */ - || kind === 168 /* ArrayBindingPattern */; + return kind === 70 /* Identifier */ + || kind === 168 /* ObjectBindingPattern */ + || kind === 169 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 141 /* TypeParameter */; + return node.kind === 142 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142 /* Parameter */; + return node.kind === 143 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 145 /* PropertyDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 153 /* IndexSignature */ - || kind === 198 /* SemicolonClassElement */; + return kind === 149 /* Constructor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 154 /* IndexSignature */ + || kind === 199 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 /* PropertyAssignment */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 239 /* MissingDeclaration */; + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 240 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) - || kind === 117 /* AnyKeyword */ - || kind === 130 /* NumberKeyword */ - || kind === 120 /* BooleanKeyword */ - || kind === 132 /* StringKeyword */ - || kind === 133 /* SymbolKeyword */ - || kind === 103 /* VoidKeyword */ - || kind === 127 /* NeverKeyword */ - || kind === 194 /* ExpressionWithTypeArguments */; + return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + || kind === 118 /* AnyKeyword */ + || kind === 131 /* NumberKeyword */ + || kind === 121 /* BooleanKeyword */ + || kind === 133 /* StringKeyword */ + || kind === 134 /* SymbolKeyword */ + || kind === 104 /* VoidKeyword */ + || kind === 128 /* NeverKeyword */ + || kind === 195 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9518,95 +9557,95 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 /* ArrayBindingPattern */ - || kind === 167 /* ObjectBindingPattern */; + return kind === 169 /* ArrayBindingPattern */ + || kind === 168 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169 /* BindingElement */; + return node.kind === 170 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 /* BindingElement */ - || kind === 193 /* OmittedExpression */; + return kind === 170 /* BindingElement */ + || kind === 194 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression function isPropertyAccessExpression(node) { - return node.kind === 172 /* PropertyAccessExpression */; + return node.kind === 173 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173 /* ElementAccessExpression */; + return node.kind === 174 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187 /* BinaryExpression */; + return node.kind === 188 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188 /* ConditionalExpression */; + return node.kind === 189 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174 /* CallExpression */; + return node.kind === 175 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 /* TemplateExpression */ - || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 190 /* TemplateExpression */ + || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191 /* SpreadElementExpression */; + return node.kind === 192 /* SpreadElementExpression */; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194 /* ExpressionWithTypeArguments */; + return node.kind === 195 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 /* PropertyAccessExpression */ - || kind === 173 /* ElementAccessExpression */ - || kind === 175 /* NewExpression */ - || kind === 174 /* CallExpression */ - || kind === 241 /* JsxElement */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 176 /* TaggedTemplateExpression */ - || kind === 170 /* ArrayLiteralExpression */ - || kind === 178 /* ParenthesizedExpression */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 192 /* ClassExpression */ - || kind === 179 /* FunctionExpression */ - || kind === 69 /* Identifier */ - || kind === 10 /* RegularExpressionLiteral */ + return kind === 173 /* PropertyAccessExpression */ + || kind === 174 /* ElementAccessExpression */ + || kind === 176 /* NewExpression */ + || kind === 175 /* CallExpression */ + || kind === 242 /* JsxElement */ + || kind === 243 /* JsxSelfClosingElement */ + || kind === 177 /* TaggedTemplateExpression */ + || kind === 171 /* ArrayLiteralExpression */ + || kind === 179 /* ParenthesizedExpression */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 193 /* ClassExpression */ + || kind === 180 /* FunctionExpression */ + || kind === 70 /* Identifier */ + || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 189 /* TemplateExpression */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */ - || kind === 97 /* ThisKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 196 /* NonNullExpression */; + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 190 /* TemplateExpression */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */ + || kind === 98 /* ThisKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 197 /* NonNullExpression */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */ - || kind === 181 /* DeleteExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 183 /* VoidExpression */ - || kind === 184 /* AwaitExpression */ - || kind === 177 /* TypeAssertionExpression */ + return kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */ + || kind === 182 /* DeleteExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 184 /* VoidExpression */ + || kind === 185 /* AwaitExpression */ + || kind === 178 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9614,13 +9653,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 /* ConditionalExpression */ - || kind === 190 /* YieldExpression */ - || kind === 180 /* ArrowFunction */ - || kind === 187 /* BinaryExpression */ - || kind === 191 /* SpreadElementExpression */ - || kind === 195 /* AsExpression */ - || kind === 193 /* OmittedExpression */ + return kind === 189 /* ConditionalExpression */ + || kind === 191 /* YieldExpression */ + || kind === 181 /* ArrowFunction */ + || kind === 188 /* BinaryExpression */ + || kind === 192 /* SpreadElementExpression */ + || kind === 196 /* AsExpression */ + || kind === 194 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9629,8 +9668,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 /* TypeAssertionExpression */ - || kind === 195 /* AsExpression */; + return kind === 178 /* TypeAssertionExpression */ + || kind === 196 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -9647,17 +9686,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193 /* OmittedExpression */; + return node.kind === 194 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 197 /* TemplateSpan */; + return node.kind === 198 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 199 /* Block */; + return node.kind === 200 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9675,118 +9714,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218 /* VariableDeclaration */; + return node.kind === 219 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219 /* VariableDeclarationList */; + return node.kind === 220 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227 /* CaseBlock */; + return node.kind === 228 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 /* ModuleBlock */ - || kind === 225 /* ModuleDeclaration */; + return kind === 227 /* ModuleBlock */ + || kind === 226 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */; + return node.kind === 230 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231 /* ImportClause */; + return node.kind === 232 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 /* NamedImports */ - || kind === 232 /* NamespaceImport */; + return kind === 234 /* NamedImports */ + || kind === 233 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234 /* ImportSpecifier */; + return node.kind === 235 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237 /* NamedExports */; + return node.kind === 238 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238 /* ExportSpecifier */; + return node.kind === 239 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 /* ModuleDeclaration */ || node.kind === 224 /* EnumDeclaration */; + return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 /* ArrowFunction */ - || kind === 169 /* BindingElement */ - || kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 148 /* Constructor */ - || kind === 224 /* EnumDeclaration */ + return kind === 181 /* ArrowFunction */ + || kind === 170 /* BindingElement */ + || kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 149 /* Constructor */ + || kind === 225 /* EnumDeclaration */ || kind === 255 /* EnumMember */ - || kind === 238 /* ExportSpecifier */ - || kind === 220 /* FunctionDeclaration */ - || kind === 179 /* FunctionExpression */ - || kind === 149 /* GetAccessor */ - || kind === 231 /* ImportClause */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 234 /* ImportSpecifier */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 146 /* MethodSignature */ - || kind === 225 /* ModuleDeclaration */ - || kind === 228 /* NamespaceExportDeclaration */ - || kind === 232 /* NamespaceImport */ - || kind === 142 /* Parameter */ + || kind === 239 /* ExportSpecifier */ + || kind === 221 /* FunctionDeclaration */ + || kind === 180 /* FunctionExpression */ + || kind === 150 /* GetAccessor */ + || kind === 232 /* ImportClause */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 235 /* ImportSpecifier */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 147 /* MethodSignature */ + || kind === 226 /* ModuleDeclaration */ + || kind === 229 /* NamespaceExportDeclaration */ + || kind === 233 /* NamespaceImport */ + || kind === 143 /* Parameter */ || kind === 253 /* PropertyAssignment */ - || kind === 145 /* PropertyDeclaration */ - || kind === 144 /* PropertySignature */ - || kind === 150 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 145 /* PropertySignature */ + || kind === 151 /* SetAccessor */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 141 /* TypeParameter */ - || kind === 218 /* VariableDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 142 /* TypeParameter */ + || kind === 219 /* VariableDeclaration */ || kind === 279 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 220 /* FunctionDeclaration */ - || kind === 239 /* MissingDeclaration */ - || kind === 221 /* ClassDeclaration */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 224 /* EnumDeclaration */ - || kind === 225 /* ModuleDeclaration */ - || kind === 230 /* ImportDeclaration */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 236 /* ExportDeclaration */ - || kind === 235 /* ExportAssignment */ - || kind === 228 /* NamespaceExportDeclaration */; + return kind === 221 /* FunctionDeclaration */ + || kind === 240 /* MissingDeclaration */ + || kind === 222 /* ClassDeclaration */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 225 /* EnumDeclaration */ + || kind === 226 /* ModuleDeclaration */ + || kind === 231 /* ImportDeclaration */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 237 /* ExportDeclaration */ + || kind === 236 /* ExportAssignment */ + || kind === 229 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 /* BreakStatement */ - || kind === 209 /* ContinueStatement */ - || kind === 217 /* DebuggerStatement */ - || kind === 204 /* DoStatement */ - || kind === 202 /* ExpressionStatement */ - || kind === 201 /* EmptyStatement */ - || kind === 207 /* ForInStatement */ - || kind === 208 /* ForOfStatement */ - || kind === 206 /* ForStatement */ - || kind === 203 /* IfStatement */ - || kind === 214 /* LabeledStatement */ - || kind === 211 /* ReturnStatement */ - || kind === 213 /* SwitchStatement */ - || kind === 215 /* ThrowStatement */ - || kind === 216 /* TryStatement */ - || kind === 200 /* VariableStatement */ - || kind === 205 /* WhileStatement */ - || kind === 212 /* WithStatement */ + return kind === 211 /* BreakStatement */ + || kind === 210 /* ContinueStatement */ + || kind === 218 /* DebuggerStatement */ + || kind === 205 /* DoStatement */ + || kind === 203 /* ExpressionStatement */ + || kind === 202 /* EmptyStatement */ + || kind === 208 /* ForInStatement */ + || kind === 209 /* ForOfStatement */ + || kind === 207 /* ForStatement */ + || kind === 204 /* IfStatement */ + || kind === 215 /* LabeledStatement */ + || kind === 212 /* ReturnStatement */ + || kind === 214 /* SwitchStatement */ + || kind === 216 /* ThrowStatement */ + || kind === 217 /* TryStatement */ + || kind === 201 /* VariableStatement */ + || kind === 206 /* WhileStatement */ + || kind === 213 /* WithStatement */ || kind === 287 /* NotEmittedStatement */; } function isDeclaration(node) { @@ -9808,20 +9847,20 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199 /* Block */; + || kind === 200 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 240 /* ExternalModuleReference */ - || kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 241 /* ExternalModuleReference */ + || kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 243 /* JsxOpeningElement */; + return node.kind === 244 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -9830,17 +9869,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 /* ThisKeyword */ - || kind === 69 /* Identifier */ - || kind === 172 /* PropertyAccessExpression */; + return kind === 98 /* ThisKeyword */ + || kind === 70 /* Identifier */ + || kind === 173 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 /* JsxElement */ + return kind === 242 /* JsxElement */ || kind === 248 /* JsxExpression */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 244 /* JsxText */; + || kind === 243 /* JsxSelfClosingElement */ + || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -9905,7 +9944,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4 /* ES2017 */: + return "lib.es2017.d.ts"; + case 3 /* ES2016 */: + return "lib.es2016.d.ts"; + case 2 /* ES2015 */: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -10114,9 +10162,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141 /* TypeParameter */) { + if (d && d.kind === 142 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223 /* InterfaceDeclaration */) { return current; } } @@ -10124,11 +10172,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 148 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 149 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10136,14 +10184,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10159,14 +10207,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10271,7 +10319,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 /* TrueKeyword */ : 84 /* FalseKeyword */, location, /*flags*/ undefined); + return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); } else if (typeof value === "string") { var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); @@ -10289,7 +10337,7 @@ var ts; // Identifiers var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69 /* Identifier */, location); + var node = createNode(70 /* Identifier */, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0 /* None */; @@ -10298,7 +10346,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 1 /* Auto */; @@ -10311,7 +10359,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 2 /* Loop */; @@ -10321,7 +10369,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = text; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 3 /* Unique */; @@ -10331,7 +10379,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.original = node; name.text = ""; name.originalKeywordKind = 0 /* Unknown */; @@ -10348,23 +10396,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(95 /* SuperKeyword */); + var node = createNode(96 /* SuperKeyword */); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97 /* ThisKeyword */, location); + var node = createNode(98 /* ThisKeyword */, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93 /* NullKeyword */); + var node = createNode(94 /* NullKeyword */); return node; } ts.createNull = createNull; // Names function createComputedPropertyName(expression, location) { - var node = createNode(140 /* ComputedPropertyName */, location); + var node = createNode(141 /* ComputedPropertyName */, location); node.expression = expression; return node; } @@ -10387,7 +10435,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142 /* Parameter */, location, flags); + var node = createNode(143 /* Parameter */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10407,7 +10455,7 @@ var ts; ts.updateParameterDeclaration = updateParameterDeclaration; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145 /* PropertyDeclaration */, location); + var node = createNode(146 /* PropertyDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10425,7 +10473,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147 /* MethodDeclaration */, location, flags); + var node = createNode(148 /* MethodDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10445,7 +10493,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148 /* Constructor */, location, flags); + var node = createNode(149 /* Constructor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10463,7 +10511,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149 /* GetAccessor */, location, flags); + var node = createNode(150 /* GetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10482,7 +10530,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150 /* SetAccessor */, location, flags); + var node = createNode(151 /* SetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10501,7 +10549,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(167 /* ObjectBindingPattern */, location); + var node = createNode(168 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10514,7 +10562,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168 /* ArrayBindingPattern */, location); + var node = createNode(169 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10527,7 +10575,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169 /* BindingElement */, location); + var node = createNode(170 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10544,7 +10592,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170 /* ArrayLiteralExpression */, location); + var node = createNode(171 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10560,7 +10608,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171 /* ObjectLiteralExpression */, location); + var node = createNode(172 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10576,7 +10624,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172 /* PropertyAccessExpression */, location, flags); + var node = createNode(173 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10594,7 +10642,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173 /* ElementAccessExpression */, location); + var node = createNode(174 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10608,7 +10656,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174 /* CallExpression */, location, flags); + var node = createNode(175 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10625,7 +10673,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* NewExpression */, location, flags); + var node = createNode(176 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10640,7 +10688,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176 /* TaggedTemplateExpression */, location); + var node = createNode(177 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10654,7 +10702,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178 /* ParenthesizedExpression */, location); + var node = createNode(179 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10666,9 +10714,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179 /* FunctionExpression */, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180 /* FunctionExpression */, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -10678,20 +10726,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180 /* ArrowFunction */, location, flags); + var node = createNode(181 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); node.body = parenthesizeConciseBody(body); return node; } @@ -10704,7 +10752,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181 /* DeleteExpression */, location); + var node = createNode(182 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10717,7 +10765,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182 /* TypeOfExpression */, location); + var node = createNode(183 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10730,7 +10778,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183 /* VoidExpression */, location); + var node = createNode(184 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10743,7 +10791,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184 /* AwaitExpression */, location); + var node = createNode(185 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10756,7 +10804,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185 /* PrefixUnaryExpression */, location); + var node = createNode(186 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10770,7 +10818,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186 /* PostfixUnaryExpression */, location); + var node = createNode(187 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10786,7 +10834,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187 /* BinaryExpression */, location); + var node = createNode(188 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10801,7 +10849,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188 /* ConditionalExpression */, location); + var node = createNode(189 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10818,7 +10866,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189 /* TemplateExpression */, location); + var node = createNode(190 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10832,7 +10880,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190 /* YieldExpression */, location); + var node = createNode(191 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10846,7 +10894,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191 /* SpreadElementExpression */, location); + var node = createNode(192 /* SpreadElementExpression */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10859,7 +10907,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192 /* ClassExpression */, location); + var node = createNode(193 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10877,12 +10925,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193 /* OmittedExpression */, location); + var node = createNode(194 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194 /* ExpressionWithTypeArguments */, location); + var node = createNode(195 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10897,7 +10945,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(197 /* TemplateSpan */, location); + var node = createNode(198 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -10912,7 +10960,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(199 /* Block */, location, flags); + var block = createNode(200 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10928,7 +10976,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200 /* VariableStatement */, location, flags); + var node = createNode(201 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10943,7 +10991,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219 /* VariableDeclarationList */, location, flags); + var node = createNode(220 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10956,7 +11004,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218 /* VariableDeclaration */, location, flags); + var node = createNode(219 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10971,11 +11019,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201 /* EmptyStatement */, location); + return createNode(202 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202 /* ExpressionStatement */, location, flags); + var node = createNode(203 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10988,7 +11036,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203 /* IfStatement */, location); + var node = createNode(204 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11003,7 +11051,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204 /* DoStatement */, location); + var node = createNode(205 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11017,7 +11065,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205 /* WhileStatement */, location); + var node = createNode(206 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11031,7 +11079,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11047,7 +11095,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207 /* ForInStatement */, location); + var node = createNode(208 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11062,7 +11110,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208 /* ForOfStatement */, location); + var node = createNode(209 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11077,7 +11125,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209 /* ContinueStatement */, location); + var node = createNode(210 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11092,7 +11140,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210 /* BreakStatement */, location); + var node = createNode(211 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11107,7 +11155,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211 /* ReturnStatement */, location); + var node = createNode(212 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11120,7 +11168,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212 /* WithStatement */, location); + var node = createNode(213 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11134,7 +11182,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213 /* SwitchStatement */, location); + var node = createNode(214 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11148,7 +11196,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214 /* LabeledStatement */, location); + var node = createNode(215 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11162,7 +11210,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215 /* ThrowStatement */, location); + var node = createNode(216 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11175,7 +11223,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216 /* TryStatement */, location); + var node = createNode(217 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11190,7 +11238,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227 /* CaseBlock */, location); + var node = createNode(228 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11203,7 +11251,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220 /* FunctionDeclaration */, location, flags); + var node = createNode(221 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11223,7 +11271,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221 /* ClassDeclaration */, location); + var node = createNode(222 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11241,7 +11289,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230 /* ImportDeclaration */, location); + var node = createNode(231 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11257,7 +11305,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231 /* ImportClause */, location); + var node = createNode(232 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11271,7 +11319,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232 /* NamespaceImport */, location); + var node = createNode(233 /* NamespaceImport */, location); node.name = name; return node; } @@ -11284,7 +11332,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233 /* NamedImports */, location); + var node = createNode(234 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11297,7 +11345,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234 /* ImportSpecifier */, location); + var node = createNode(235 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11311,7 +11359,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235 /* ExportAssignment */, location); + var node = createNode(236 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11327,7 +11375,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236 /* ExportDeclaration */, location); + var node = createNode(237 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11343,7 +11391,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237 /* NamedExports */, location); + var node = createNode(238 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11356,7 +11404,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238 /* ExportSpecifier */, location); + var node = createNode(239 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11371,7 +11419,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241 /* JsxElement */, location); + var node = createNode(242 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11386,7 +11434,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242 /* JsxSelfClosingElement */, location); + var node = createNode(243 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11400,7 +11448,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243 /* JsxOpeningElement */, location); + var node = createNode(244 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11653,47 +11701,47 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; // Compound nodes function createComma(left, right) { - return createBinary(left, 24 /* CommaToken */, right); + return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25 /* LessThanToken */, right, location); + return createBinary(left, 26 /* LessThanToken */, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56 /* EqualsToken */, right, location); + return createBinary(left, 57 /* EqualsToken */, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 33 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 34 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35 /* PlusToken */, right); + return createBinary(left, 36 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36 /* MinusToken */, right); + return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41 /* PlusPlusToken */, location); + return createPostfix(operand, 42 /* PlusPlusToken */, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51 /* AmpersandAmpersandToken */, right); + return createBinary(left, 52 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52 /* BarBarToken */, right); + return createBinary(left, 53 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49 /* ExclamationToken */, operand); + return createPrefix(50 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -11714,7 +11762,7 @@ var ts; function createRestParameter(name) { return createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createToken(22 /* DotDotDotToken */), name, + /*modifiers*/ undefined, createToken(23 /* DotDotDotToken */), name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -11844,7 +11892,8 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37 /* AsteriskToken */), + var generatorFunc = createFunctionExpression( + /*modifiers*/ undefined, createToken(38 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -11935,6 +11984,7 @@ var ts; /*modifiers*/ undefined, createConstDeclarationList([ createVariableDeclaration("_super", /*type*/ undefined, createCall(createParen(createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ @@ -11963,19 +12013,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return cacheIdentifiers; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -11989,13 +12039,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95 /* SuperKeyword */) { + else if (callee.kind === 96 /* SuperKeyword */) { thisArg = createThis(); - target = languageVersion < 2 /* ES6 */ ? createIdentifier("_super", /*location*/ callee) : callee; + target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; } else { switch (callee.kind) { - case 172 /* PropertyAccessExpression */: { + case 173 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12009,7 +12059,7 @@ var ts; } break; } - case 173 /* ElementAccessExpression */: { + case 174 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12063,14 +12113,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); case 254 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12080,7 +12130,7 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression( + var getterFunction = createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, @@ -12091,7 +12141,7 @@ var ts; properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression( + var setterFunction = createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, @@ -12125,7 +12175,7 @@ var ts; /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, /*type*/ undefined, method.body, @@ -12150,7 +12200,7 @@ var ts; * @param visitor: Optional callback used to visit any custom prologue directives. */ function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -12163,16 +12213,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -12219,7 +12273,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 178 /* ParenthesizedExpression */) { + if (skipped.kind === 179 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12253,8 +12307,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12263,7 +12317,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 190 /* YieldExpression */) { + && operand.kind === 191 /* YieldExpression */) { return false; } return true; @@ -12300,7 +12354,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 35 /* PlusToken */) { + if (binaryOperator === 36 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12335,10 +12389,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 37 /* AsteriskToken */ - || binaryOperator === 47 /* BarToken */ - || binaryOperator === 46 /* AmpersandToken */ - || binaryOperator === 48 /* CaretToken */; + return binaryOperator === 38 /* AsteriskToken */ + || binaryOperator === 48 /* BarToken */ + || binaryOperator === 47 /* AmpersandToken */ + || binaryOperator === 49 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -12351,7 +12405,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 35 /* PlusToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12374,9 +12428,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return createParen(expression); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12401,7 +12455,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12439,7 +12493,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, 24 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12450,7 +12504,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 /* FunctionExpression */ || kind === 180 /* ArrowFunction */) { + if (kind === 180 /* FunctionExpression */ || kind === 181 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12458,7 +12512,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 /* ObjectLiteralExpression */ || leftmostExpressionKind === 179 /* FunctionExpression */) { + if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12482,18 +12536,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: node = node.operand; continue; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: node = node.left; continue; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: node = node.condition; continue; - case 174 /* CallExpression */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: node = node.expression; continue; case 288 /* PartiallyEmittedExpression */: @@ -12505,7 +12559,7 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { return createParen(body, /*location*/ body); } return body; @@ -12537,7 +12591,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */) { + while (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12771,10 +12825,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 231 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12845,10 +12899,10 @@ var ts; if (kind === 256 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69 /* Identifier */) { + else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139 /* FirstNode */) { + else if (kind < 140 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12891,10 +12945,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -12905,12 +12959,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12919,24 +12973,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12947,176 +13001,176 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 161 /* TupleType */: + case 162 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return visitNode(cbNode, node.literal); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195 /* AsExpression */: + case 196 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); case 256 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return visitNode(cbNode, node.label); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); case 249 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143 /* Decorator */: + case 144 /* Decorator */: return visitNode(cbNode, node.expression); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: 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 222 /* InterfaceDeclaration */: + case 223 /* 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 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13124,65 +13178,65 @@ var ts; case 255 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); case 251 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246 /* JsxAttribute */: @@ -13303,7 +13357,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 32768 /* DisallowInContext */ | 131072 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; @@ -13394,9 +13448,9 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -13406,7 +13460,7 @@ var ts; // .tsx and .jsx files are treated as jsx language variant. return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -13710,20 +13764,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 69 /* Identifier */) { + if (token() === 70 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 114 /* YieldKeyword */ && inYieldContext()) { + if (token() === 115 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 119 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 120 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 105 /* LastReservedWord */; + return token() > 106 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13766,22 +13820,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 16 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 17 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(23 /* SemicolonToken */); + return parseExpected(24 /* SemicolonToken */); } } // note: this function creates only node @@ -13790,8 +13844,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : - kind === 69 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13838,16 +13892,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69 /* Identifier */); + var node = createNode(70 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 69 /* Identifier */) { + if (token() !== 70 /* Identifier */) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13864,7 +13918,7 @@ var ts; if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token() === 19 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 20 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13882,13 +13936,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(140 /* ComputedPropertyName */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(141 /* ComputedPropertyName */); + parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -13902,21 +13956,21 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74 /* ConstKeyword */) { + if (token() === 75 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 81 /* EnumKeyword */; + return nextToken() === 82 /* EnumKeyword */; } - if (token() === 82 /* ExportKeyword */) { + if (token() === 83 /* ExportKeyword */) { nextToken(); - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 /* AsteriskToken */ && token() !== 116 /* AsKeyword */ && token() !== 15 /* OpenBraceToken */ && canFollowModifier(); + return token() !== 38 /* AsteriskToken */ && token() !== 117 /* AsKeyword */ && token() !== 16 /* OpenBraceToken */ && canFollowModifier(); } - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113 /* StaticKeyword */) { + if (token() === 114 /* StaticKeyword */) { nextToken(); return canFollowModifier(); } @@ -13926,16 +13980,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 /* OpenBracketToken */ - || token() === 15 /* OpenBraceToken */ - || token() === 37 /* AsteriskToken */ - || token() === 22 /* DotDotDotToken */ + return token() === 20 /* OpenBracketToken */ + || token() === 16 /* OpenBraceToken */ + || token() === 38 /* AsteriskToken */ + || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 /* ClassKeyword */ || token() === 87 /* FunctionKeyword */ || - (token() === 118 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 /* ClassKeyword */ || token() === 88 /* FunctionKeyword */ || + (token() === 119 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -13953,9 +14007,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -13963,19 +14017,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 23 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 19 /* OpenBracketToken */ || token() === 37 /* AsteriskToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13990,23 +14044,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token() === 24 /* CommaToken */ || isStartOfType(); + return token() === 25 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -14019,8 +14073,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15 /* OpenBraceToken */); - if (nextToken() === 16 /* CloseBraceToken */) { + ts.Debug.assert(token() === 16 /* OpenBraceToken */); + if (nextToken() === 17 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -14029,7 +14083,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; + return next === 25 /* CommaToken */ || next === 16 /* OpenBraceToken */ || next === 84 /* ExtendsKeyword */ || next === 107 /* ImplementsKeyword */; } return true; } @@ -14042,8 +14096,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 /* ImplementsKeyword */ || - token() === 83 /* ExtendsKeyword */) { + if (token() === 107 /* ImplementsKeyword */ || + token() === 84 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -14067,43 +14121,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 16 /* CloseBraceToken */ || token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 15 /* OpenBraceToken */ || token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 27 /* GreaterThanToken */ || token() === 17 /* OpenParenToken */ || token() === 15 /* OpenBraceToken */ || token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 23 /* SemicolonToken */; + return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 20 /* CloseBracketToken */; + return token() === 21 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 24 /* CommaToken */; + return token() !== 25 /* CommaToken */; case 20 /* HeritageClauses */: - return token() === 15 /* OpenBraceToken */ || token() === 16 /* CloseBraceToken */; + return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 27 /* GreaterThanToken */ || token() === 39 /* SlashToken */; + return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token() === 18 /* CloseParenToken */ || token() === 54 /* ColonToken */ || token() === 16 /* CloseBraceToken */; + return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token() === 27 /* GreaterThanToken */ || token() === 16 /* CloseBraceToken */; + return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token() === 20 /* CloseBracketToken */ || token() === 16 /* CloseBraceToken */; + return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -14121,7 +14175,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -14284,20 +14338,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148 /* Constructor */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 145 /* PropertyDeclaration */: - case 198 /* SemicolonClassElement */: + case 149 /* Constructor */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 199 /* SemicolonClassElement */: return true; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 70 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 122 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -14316,35 +14370,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 200 /* VariableStatement */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 202 /* ExpressionStatement */: - case 215 /* ThrowStatement */: - case 211 /* ReturnStatement */: - case 213 /* SwitchStatement */: - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 201 /* EmptyStatement */: - case 216 /* TryStatement */: - case 214 /* LabeledStatement */: - case 204 /* DoStatement */: - case 217 /* DebuggerStatement */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 201 /* VariableStatement */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 203 /* ExpressionStatement */: + case 216 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 214 /* SwitchStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 202 /* EmptyStatement */: + case 217 /* TryStatement */: + case 215 /* LabeledStatement */: + case 205 /* DoStatement */: + case 218 /* DebuggerStatement */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: return true; } } @@ -14356,18 +14410,18 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152 /* ConstructSignature */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 144 /* PropertySignature */: - case 151 /* CallSignature */: + case 153 /* ConstructSignature */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 145 /* PropertySignature */: + case 152 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218 /* VariableDeclaration */) { + if (node.kind !== 219 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14388,7 +14442,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142 /* Parameter */) { + if (node.kind !== 143 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -14445,7 +14499,7 @@ var ts; if (isListElement(kind, /*inErrorRecovery*/ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -14454,13 +14508,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(24 /* CommaToken */); + parseExpected(25 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 24 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -14499,8 +14553,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21 /* DotToken */)) { - var node = createNode(139 /* QualifiedName */, entity.pos); // !!! + while (parseOptional(22 /* DotToken */)) { + var node = createNode(140 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14533,33 +14587,33 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189 /* TemplateExpression */); + var template = createNode(190 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197 /* TemplateSpan */); + var span = createNode(198 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16 /* CloseBraceToken */) { + if (token() === 17 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); + literal = parseExpectedToken(15 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(17 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -14569,12 +14623,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 13 /* TemplateMiddle */ || fragment.kind === 14 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 /* TemplateMiddle */ || fragment.kind === 15 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -14606,35 +14660,35 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(155 /* TypeReference */, typeName.pos); + var node = createNode(156 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154 /* TypePredicate */, lhs.pos); + var node = createNode(155 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165 /* ThisType */); + var node = createNode(166 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158 /* TypeQuery */); - parseExpected(101 /* TypeOfKeyword */); + var node = createNode(159 /* TypeQuery */); + parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141 /* TypeParameter */); + var node = createNode(142 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(83 /* ExtendsKeyword */)) { + if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -14656,29 +14710,29 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(54 /* ColonToken */)) { + if (parseOptional(55 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 /* AtToken */ || token() === 97 /* ThisKeyword */; + return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(142 /* Parameter */); - if (token() === 97 /* ThisKeyword */) { + var node = createNode(143 /* Parameter */); + if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -14693,7 +14747,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(53 /* QuestionToken */); + node.questionToken = parseOptionalToken(54 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -14713,7 +14767,7 @@ var ts; return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 35 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -14738,7 +14792,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(17 /* OpenParenToken */)) { + if (parseExpected(18 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -14746,7 +14800,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(19 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -14761,7 +14815,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -14769,15 +14823,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152 /* ConstructSignature */) { - parseExpected(92 /* NewKeyword */); + if (kind === 153 /* ConstructSignature */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19 /* OpenBracketToken */) { + if (token() !== 20 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -14800,7 +14854,7 @@ var ts; // [] // nextToken(); - if (token() === 22 /* DotDotDotToken */ || token() === 20 /* CloseBracketToken */) { + if (token() === 23 /* DotDotDotToken */ || token() === 21 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -14819,49 +14873,49 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 53 /* QuestionToken */) { + if (token() !== 54 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || token() === 20 /* CloseBracketToken */; + return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153 /* IndexSignature */, fullStart); + var node = createNode(154 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - var method = createNode(146 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var method = createNode(147 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144 /* PropertySignature */, fullStart); + var property = createNode(145 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -14874,7 +14928,7 @@ var ts; function isTypeMemberStart() { var idToken; // Return true if we have the start of a signature member - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier @@ -14883,7 +14937,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -14894,21 +14948,21 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 17 /* OpenParenToken */ || - token() === 25 /* LessThanToken */ || - token() === 53 /* QuestionToken */ || - token() === 54 /* ColonToken */ || - token() === 24 /* CommaToken */ || + return token() === 18 /* OpenParenToken */ || + token() === 26 /* LessThanToken */ || + token() === 54 /* QuestionToken */ || + token() === 55 /* ColonToken */ || + token() === 25 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - return parseSignatureMember(151 /* CallSignature */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + return parseSignatureMember(152 /* CallSignature */); } - if (token() === 92 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(152 /* ConstructSignature */); + if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14919,18 +14973,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */; + return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(159 /* TypeLiteral */); + var node = createNode(160 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { members = createMissingList(); @@ -14938,31 +14992,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + var node = createNode(162 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164 /* ParenthesizedType */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(165 /* ParenthesizedType */); + parseExpected(18 /* OpenParenToken */); node.type = parseType(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157 /* ConstructorType */) { - parseExpected(92 /* NewKeyword */); + if (kind === 158 /* ConstructorType */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 /* DotToken */ ? undefined : node; + return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166 /* LiteralType */); + var node = createNode(167 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14972,42 +15026,42 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseLiteralTypeNode(); - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: return parseTokenNode(); - case 97 /* ThisKeyword */: { + case 98 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeQuery(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseTypeLiteral(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseTupleType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReference(); @@ -15015,29 +15069,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 97 /* ThisKeyword */: - case 101 /* TypeOfKeyword */: - case 127 /* NeverKeyword */: - case 15 /* OpenBraceToken */: - case 19 /* OpenBracketToken */: - case 25 /* LessThanToken */: - case 92 /* NewKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 98 /* ThisKeyword */: + case 102 /* TypeOfKeyword */: + case 128 /* NeverKeyword */: + case 16 /* OpenBraceToken */: + case 20 /* OpenBracketToken */: + case 26 /* LessThanToken */: + case 93 /* NewKeyword */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return true; - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -15047,13 +15101,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token() === 19 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { - parseExpected(20 /* CloseBracketToken */); - var node = createNode(160 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { + parseExpected(21 /* CloseBracketToken */); + var node = createNode(161 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -15074,27 +15128,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(164 /* IntersectionType */, parseArrayTypeOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(163 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { return true; } - return token() === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 97 /* ThisKeyword */) { + if (isIdentifier() || token() === 98 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 19 /* OpenBracketToken */ || token() === 15 /* OpenBraceToken */) { + if (token() === 20 /* OpenBracketToken */ || token() === 16 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -15104,7 +15158,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 /* CloseParenToken */ || token() === 22 /* DotDotDotToken */) { + if (token() === 19 /* CloseParenToken */ || token() === 23 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -15112,17 +15166,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || - token() === 53 /* QuestionToken */ || token() === 56 /* EqualsToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || + token() === 54 /* QuestionToken */ || token() === 57 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 18 /* CloseParenToken */) { + if (token() === 19 /* CloseParenToken */) { nextToken(); - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -15134,7 +15188,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(155 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15145,7 +15199,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -15157,37 +15211,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156 /* FunctionType */); + return parseFunctionOrConstructorType(157 /* FunctionType */); } - if (token() === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(157 /* ConstructorType */); + if (token() === 93 /* NewKeyword */) { + return parseFunctionOrConstructorType(158 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54 /* ColonToken */) ? parseType() : undefined; + return parseOptional(55 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 92 /* NewKeyword */: - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - case 69 /* Identifier */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 93 /* NewKeyword */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 70 /* Identifier */: return true; default: return isIdentifier(); @@ -15198,18 +15252,18 @@ var ts; return true; } switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: - case 25 /* LessThanToken */: - case 119 /* AwaitKeyword */: - case 114 /* YieldKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: + case 26 /* LessThanToken */: + case 120 /* AwaitKeyword */: + case 115 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -15227,10 +15281,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 15 /* OpenBraceToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && - token() !== 55 /* AtToken */ && + return token() !== 16 /* OpenBraceToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && + token() !== 56 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -15244,7 +15298,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(25 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -15253,7 +15307,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56 /* EqualsToken */) { + if (token() !== 57 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -15262,7 +15316,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -15270,7 +15324,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -15316,7 +15370,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -15332,7 +15386,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114 /* YieldKeyword */) { + if (token() === 115 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -15361,15 +15415,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190 /* YieldExpression */); + var node = createNode(191 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + (token() === 38 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15380,21 +15434,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180 /* ArrowFunction */, asyncModifier.pos); + node = createNode(181 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180 /* ArrowFunction */, identifier.pos); + node = createNode(181 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(142 /* Parameter */, identifier.pos); + var parameter = createNode(143 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -15419,8 +15473,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 /* EqualsGreaterThanToken */ || lastToken === 16 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); @@ -15430,10 +15484,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */ || token() === 118 /* AsyncKeyword */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */ || token() === 119 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -15443,28 +15497,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 17 /* OpenParenToken */ && token() !== 25 /* LessThanToken */) { + if (token() !== 18 /* OpenParenToken */ && token() !== 26 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 17 /* OpenParenToken */) { - if (second === 18 /* CloseParenToken */) { + if (first === 18 /* OpenParenToken */) { + if (second === 19 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 34 /* EqualsGreaterThanToken */: - case 54 /* ColonToken */: - case 15 /* OpenBraceToken */: + case 35 /* EqualsGreaterThanToken */: + case 55 /* ColonToken */: + case 16 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -15476,12 +15530,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { + if (second === 20 /* OpenBracketToken */ || second === 16 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 22 /* DotDotDotToken */) { + if (second === 23 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -15494,7 +15548,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 54 /* ColonToken */) { + if (nextToken() === 55 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -15502,7 +15556,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 25 /* LessThanToken */); + ts.Debug.assert(first === 26 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -15512,17 +15566,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83 /* ExtendsKeyword */) { + if (third === 84 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 56 /* EqualsToken */: - case 27 /* GreaterThanToken */: + case 57 /* EqualsToken */: + case 28 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 24 /* CommaToken */) { + else if (third === 25 /* CommaToken */) { return true; } return false; @@ -15541,7 +15595,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); @@ -15555,23 +15609,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a begining of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 34 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 35 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180 /* ArrowFunction */); + var node = createNode(181 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15581,7 +15635,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -15594,19 +15648,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 34 /* EqualsGreaterThanToken */ && token() !== 15 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 35 /* EqualsGreaterThanToken */ && token() !== 16 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token() !== 23 /* SemicolonToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && + if (token() !== 24 /* SemicolonToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -15631,17 +15685,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(53 /* QuestionToken */); + var questionToken = parseOptionalToken(54 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(188 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(189 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); + node.colonToken = parseExpectedToken(55 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(55 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15650,7 +15704,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 138 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 139 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15679,16 +15733,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 38 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 39 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 /* InKeyword */ && inDisallowInContext()) { + if (token() === 91 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -15709,48 +15763,48 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90 /* InKeyword */) { + if (inDisallowInContext() && token() === 91 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 1; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 2; - case 47 /* BarToken */: + case 48 /* BarToken */: return 3; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 4; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 5; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 6; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: return 7; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 9; - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 10; - case 38 /* AsteriskAsteriskToken */: + case 39 /* AsteriskAsteriskToken */: return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -15758,45 +15812,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187 /* BinaryExpression */, left.pos); + var node = createNode(188 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195 /* AsExpression */, left.pos); + var node = createNode(196 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185 /* PrefixUnaryExpression */); + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181 /* DeleteExpression */); + var node = createNode(182 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(182 /* TypeOfExpression */); + var node = createNode(183 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(183 /* VoidExpression */); + var node = createNode(184 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 119 /* AwaitKeyword */) { + if (token() === 120 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -15806,7 +15860,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184 /* AwaitExpression */); + var node = createNode(185 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15830,7 +15884,7 @@ var ts; */ if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 /* AsteriskAsteriskToken */ ? + return token() === 39 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } @@ -15847,9 +15901,9 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38 /* AsteriskAsteriskToken */) { + if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 178 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -15874,23 +15928,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 78 /* DeleteKeyword */: + case 79 /* DeleteKeyword */: return parseDeleteExpression(); - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return parseVoidExpression(); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 119 /* AwaitKeyword */: + case 120 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -15912,16 +15966,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - case 119 /* AwaitKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 120 /* AwaitKeyword */: return false; - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -15944,21 +15998,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseIncrementExpression() { - if (token() === 41 /* PlusPlusToken */ || token() === 42 /* MinusMinusToken */) { - var node = createNode(185 /* PrefixUnaryExpression */); + if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 /* PlusPlusToken */ || token() === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15997,7 +16051,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token() === 95 /* SuperKeyword */ + var expression = token() === 96 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -16057,14 +16111,14 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 /* OpenParenToken */ || token() === 21 /* DotToken */ || token() === 19 /* OpenBracketToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 22 /* DotToken */ || token() === 20 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(172 /* PropertyAccessExpression */, expression.pos); + var node = createNode(173 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } @@ -16072,10 +16126,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69 /* Identifier */) { + if (lhs.kind === 70 /* Identifier */) { return lhs.text === rhs.text; } - if (lhs.kind === 97 /* ThisKeyword */) { + if (lhs.kind === 98 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -16087,8 +16141,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243 /* JsxOpeningElement */) { - var node = createNode(241 /* JsxElement */, opening.pos); + if (opening.kind === 244 /* JsxOpeningElement */) { + var node = createNode(242 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16098,7 +16152,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16109,15 +16163,15 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 25 /* LessThanToken */) { + if (inExpressionContext && token() === 26 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187 /* BinaryExpression */, result.pos); + var badNode = createNode(188 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(25 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -16125,17 +16179,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244 /* JsxText */, scanner.getStartPos()); + var node = createNode(10 /* JsxText */, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244 /* JsxText */: + case 10 /* JsxText */: return parseJsxText(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -16146,7 +16200,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26 /* LessThanSlashToken */) { + if (token() === 27 /* LessThanSlashToken */) { // Closing tag break; } @@ -16164,27 +16218,27 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25 /* LessThanToken */); + parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (token() === 27 /* GreaterThanToken */) { + if (token() === 28 /* GreaterThanToken */) { // 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(243 /* JsxOpeningElement */, fullStart); + node = createNode(244 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(39 /* SlashToken */); + parseExpected(40 /* SlashToken */); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(242 /* JsxSelfClosingElement */, fullStart); + node = createNode(243 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16197,10 +16251,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 97 /* ThisKeyword */ ? + var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21 /* DotToken */)) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(22 /* DotToken */)) { + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16209,27 +16263,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248 /* JsxExpression */); - parseExpected(15 /* OpenBraceToken */); - if (token() !== 16 /* CloseBraceToken */) { + parseExpected(16 /* OpenBraceToken */); + if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { - parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(17 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -16243,71 +16297,71 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247 /* JsxSpreadAttribute */); - parseExpected(15 /* OpenBraceToken */); - parseExpected(22 /* DotDotDotToken */); + parseExpected(16 /* OpenBraceToken */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245 /* JsxClosingElement */); - parseExpected(26 /* LessThanSlashToken */); + parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177 /* TypeAssertionExpression */); - parseExpected(25 /* LessThanToken */); + var node = createNode(178 /* TypeAssertionExpression */); + parseExpected(26 /* LessThanToken */); node.type = parseType(); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21 /* DotToken */); + var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(173 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { + var indexedAccess = createNode(174 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token() !== 20 /* CloseBracketToken */) { + if (token() !== 21 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token() === 11 /* NoSubstitutionTemplateLiteral */ || token() === 12 /* TemplateHead */) { - var tagExpression = createNode(176 /* TaggedTemplateExpression */, expression.pos); + if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { + var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -16319,7 +16373,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -16328,15 +16382,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(174 /* CallExpression */, expression.pos); + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17 /* OpenParenToken */) { - var callExpr = createNode(174 /* CallExpression */, expression.pos); + else if (token() === 18 /* OpenParenToken */) { + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16346,17 +16400,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25 /* LessThanToken */)) { + if (!parseOptional(26 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(27 /* GreaterThanToken */)) { + if (!parseExpected(28 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -16368,32 +16422,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17 /* OpenParenToken */: // foo( + case 18 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 21 /* DotToken */: // foo. - case 18 /* CloseParenToken */: // foo) - case 20 /* CloseBracketToken */: // foo] - case 54 /* ColonToken */: // foo: - case 23 /* SemicolonToken */: // foo; - case 53 /* QuestionToken */: // foo? - case 30 /* EqualsEqualsToken */: // foo == - case 32 /* EqualsEqualsEqualsToken */: // foo === - case 31 /* ExclamationEqualsToken */: // foo != - case 33 /* ExclamationEqualsEqualsToken */: // foo !== - case 51 /* AmpersandAmpersandToken */: // foo && - case 52 /* BarBarToken */: // foo || - case 48 /* CaretToken */: // foo ^ - case 46 /* AmpersandToken */: // foo & - case 47 /* BarToken */: // foo | - case 16 /* CloseBraceToken */: // foo } + case 22 /* DotToken */: // foo. + case 19 /* CloseParenToken */: // foo) + case 21 /* CloseBracketToken */: // foo] + case 55 /* ColonToken */: // foo: + case 24 /* SemicolonToken */: // foo; + case 54 /* QuestionToken */: // foo? + case 31 /* EqualsEqualsToken */: // foo == + case 33 /* EqualsEqualsEqualsToken */: // foo === + case 32 /* ExclamationEqualsToken */: // foo != + case 34 /* ExclamationEqualsEqualsToken */: // foo !== + case 52 /* AmpersandAmpersandToken */: // foo && + case 53 /* BarBarToken */: // foo || + case 49 /* CaretToken */: // foo ^ + case 47 /* AmpersandToken */: // foo & + case 48 /* BarToken */: // foo | + case 17 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 24 /* CommaToken */: // foo, - case 15 /* OpenBraceToken */: // foo { + case 25 /* CommaToken */: // foo, + case 16 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -16406,21 +16460,21 @@ var ts; switch (token()) { case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseTokenNode(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedExpression(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 118 /* AsyncKeyword */: + case 119 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -16428,60 +16482,60 @@ var ts; break; } return parseFunctionExpression(); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassExpression(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionExpression(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseNewExpression(); - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + if (reScanSlashToken() === 11 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178 /* ParenthesizedExpression */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(179 /* ParenthesizedExpression */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191 /* SpreadElementExpression */); - parseExpected(22 /* DotDotDotToken */); + var node = createNode(192 /* SpreadElementExpression */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 24 /* CommaToken */ ? createNode(193 /* OmittedExpression */) : + return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 25 /* CommaToken */ ? createNode(194 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170 /* ArrayLiteralExpression */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(171 /* ArrayLiteralExpression */); + parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(149 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(124 /* GetKeyword */)) { + return parseAccessorDeclaration(150 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(131 /* SetKeyword */)) { - return parseAccessorDeclaration(150 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(132 /* SetKeyword */)) { + return parseAccessorDeclaration(151 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -16493,12 +16547,12 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // check if it is short-hand property assignment or normal property assignment @@ -16506,12 +16560,12 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 /* CommaToken */ || token() === 16 /* CloseBraceToken */ || token() === 56 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56 /* EqualsToken */); + var equalsToken = parseOptionalToken(57 /* EqualsToken */); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -16523,19 +16577,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171 /* ObjectLiteralExpression */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(172 /* ObjectLiteralExpression */); + parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -16548,10 +16602,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(179 /* FunctionExpression */); + var node = createNode(180 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); node.name = @@ -16559,7 +16613,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -16570,24 +16624,24 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175 /* NewExpression */); - parseExpected(92 /* NewKeyword */); + var node = createNode(176 /* NewExpression */); + parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17 /* OpenParenToken */) { + if (node.typeArguments || token() === 18 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199 /* Block */); - if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200 /* Block */); + if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -16614,51 +16668,51 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201 /* EmptyStatement */); - parseExpected(23 /* SemicolonToken */); + var node = createNode(202 /* EmptyStatement */); + parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(203 /* IfStatement */); - parseExpected(88 /* IfKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(204 /* IfStatement */); + parseExpected(89 /* IfKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204 /* DoStatement */); - parseExpected(79 /* DoKeyword */); + var node = createNode(205 /* DoStatement */); + parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(23 /* SemicolonToken */); + parseOptional(24 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205 /* WhileStatement */); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(206 /* WhileStatement */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86 /* ForKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(87 /* ForKeyword */); + parseExpected(18 /* OpenParenToken */); var initializer = undefined; - if (token() !== 23 /* SemicolonToken */) { - if (token() === 102 /* VarKeyword */ || token() === 108 /* LetKeyword */ || token() === 74 /* ConstKeyword */) { + if (token() !== 24 /* SemicolonToken */) { + if (token() === 103 /* VarKeyword */ || token() === 109 /* LetKeyword */ || token() === 75 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -16666,32 +16720,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(207 /* ForInStatement */, pos); + if (parseOptional(91 /* InKeyword */)) { + var forInStatement = createNode(208 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138 /* OfKeyword */)) { - var forOfStatement = createNode(208 /* ForOfStatement */, pos); + else if (parseOptional(139 /* OfKeyword */)) { + var forOfStatement = createNode(209 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206 /* ForStatement */, pos); + var forStatement = createNode(207 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(23 /* SemicolonToken */); - if (token() !== 23 /* SemicolonToken */ && token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23 /* SemicolonToken */); - if (token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 19 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -16699,7 +16753,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16707,8 +16761,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211 /* ReturnStatement */); - parseExpected(94 /* ReturnKeyword */); + var node = createNode(212 /* ReturnStatement */); + parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -16716,42 +16770,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212 /* WithStatement */); - parseExpected(105 /* WithKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(213 /* WithStatement */); + parseExpected(106 /* WithKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249 /* CaseClause */); - parseExpected(71 /* CaseKeyword */); + parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250 /* DefaultClause */); - parseExpected(77 /* DefaultKeyword */); - parseExpected(54 /* ColonToken */); + parseExpected(78 /* DefaultKeyword */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213 /* SwitchStatement */); - parseExpected(96 /* SwitchKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(214 /* SwitchStatement */); + parseExpected(97 /* SwitchKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(227 /* CaseBlock */, scanner.getStartPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(19 /* CloseParenToken */); + var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -16763,39 +16817,39 @@ 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(215 /* ThrowStatement */); - parseExpected(98 /* ThrowKeyword */); + var node = createNode(216 /* ThrowStatement */); + parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(216 /* TryStatement */); - parseExpected(100 /* TryKeyword */); + var node = createNode(217 /* TryStatement */); + parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 85 /* FinallyKeyword */) { - parseExpected(85 /* FinallyKeyword */); + if (!node.catchClause || token() === 86 /* FinallyKeyword */) { + parseExpected(86 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252 /* CatchClause */); - parseExpected(72 /* CatchKeyword */); - if (parseExpected(17 /* OpenParenToken */)) { + parseExpected(73 /* CatchKeyword */); + if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217 /* DebuggerStatement */); - parseExpected(76 /* DebuggerKeyword */); + var node = createNode(218 /* DebuggerStatement */); + parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -16805,14 +16859,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(214 /* LabeledStatement */, fullStart); + if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { + var labeledStatement = createNode(215 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16824,7 +16878,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 88 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -16833,12 +16887,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -16861,41 +16915,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 107 /* InterfaceKeyword */: - case 134 /* TypeKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 128 /* ReadonlyKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 129 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137 /* GlobalKeyword */: + case 138 /* GlobalKeyword */: nextToken(); - return token() === 15 /* OpenBraceToken */ || token() === 69 /* Identifier */ || token() === 82 /* ExportKeyword */; - case 89 /* ImportKeyword */: + return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; + case 90 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 82 /* ExportKeyword */: + return token() === 9 /* StringLiteral */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 83 /* ExportKeyword */: nextToken(); - if (token() === 56 /* EqualsToken */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || token() === 77 /* DefaultKeyword */ || - token() === 116 /* AsKeyword */) { + if (token() === 57 /* EqualsToken */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || token() === 78 /* DefaultKeyword */ || + token() === 117 /* AsKeyword */) { return true; } continue; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: nextToken(); continue; default: @@ -16908,49 +16962,49 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55 /* AtToken */: - case 23 /* SemicolonToken */: - case 15 /* OpenBraceToken */: - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 88 /* IfKeyword */: - case 79 /* DoKeyword */: - case 104 /* WhileKeyword */: - case 86 /* ForKeyword */: - case 75 /* ContinueKeyword */: - case 70 /* BreakKeyword */: - case 94 /* ReturnKeyword */: - case 105 /* WithKeyword */: - case 96 /* SwitchKeyword */: - case 98 /* ThrowKeyword */: - case 100 /* TryKeyword */: - case 76 /* DebuggerKeyword */: + case 56 /* AtToken */: + case 24 /* SemicolonToken */: + case 16 /* OpenBraceToken */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 89 /* IfKeyword */: + case 80 /* DoKeyword */: + case 105 /* WhileKeyword */: + case 87 /* ForKeyword */: + case 76 /* ContinueKeyword */: + case 71 /* BreakKeyword */: + case 95 /* ReturnKeyword */: + case 106 /* WithKeyword */: + case 97 /* SwitchKeyword */: + case 99 /* ThrowKeyword */: + case 101 /* TryKeyword */: + case 77 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return true; - case 74 /* ConstKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: + case 75 /* ConstKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: return isStartOfDeclaration(); - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 107 /* InterfaceKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 134 /* TypeKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 108 /* InterfaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 135 /* TypeKeyword */: + case 138 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -16960,7 +17014,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */; + return isIdentifier() || token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -16969,67 +17023,67 @@ var ts; } function parseStatement() { switch (token()) { - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: return parseEmptyStatement(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 88 /* IfKeyword */: + case 89 /* IfKeyword */: return parseIfStatement(); - case 79 /* DoKeyword */: + case 80 /* DoKeyword */: return parseDoStatement(); - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return parseWhileStatement(); - case 86 /* ForKeyword */: + case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(209 /* ContinueStatement */); - case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(210 /* BreakStatement */); - case 94 /* ReturnKeyword */: + case 76 /* ContinueKeyword */: + return parseBreakOrContinueStatement(210 /* ContinueStatement */); + case 71 /* BreakKeyword */: + return parseBreakOrContinueStatement(211 /* BreakStatement */); + case 95 /* ReturnKeyword */: return parseReturnStatement(); - case 105 /* WithKeyword */: + case 106 /* WithKeyword */: return parseWithStatement(); - case 96 /* SwitchKeyword */: + case 97 /* SwitchKeyword */: return parseSwitchStatement(); - case 98 /* ThrowKeyword */: + case 99 /* ThrowKeyword */: return parseThrowStatement(); - case 100 /* TryKeyword */: + case 101 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return parseTryStatement(); - case 76 /* DebuggerKeyword */: + case 77 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 55 /* AtToken */: + case 56 /* AtToken */: return parseDeclaration(); - case 118 /* AsyncKeyword */: - case 107 /* InterfaceKeyword */: - case 134 /* TypeKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 122 /* DeclareKeyword */: - case 74 /* ConstKeyword */: - case 81 /* EnumKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 115 /* AbstractKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 82 /* EnumKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 116 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: + case 138 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17042,33 +17096,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107 /* InterfaceKeyword */: + case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134 /* TypeKeyword */: + case 135 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81 /* EnumKeyword */: + case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137 /* GlobalKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 138 /* GlobalKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89 /* ImportKeyword */: + case 90 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: nextToken(); switch (token()) { - case 77 /* DefaultKeyword */: - case 56 /* EqualsToken */: + case 78 /* DefaultKeyword */: + case 57 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); - case 116 /* AsKeyword */: + case 117 /* AsKeyword */: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); @@ -17077,7 +17131,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(239 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17090,7 +17144,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 16 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -17098,24 +17152,24 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 24 /* CommaToken */) { - return createNode(193 /* OmittedExpression */); + if (token() === 25 /* CommaToken */) { + return createNode(194 /* OmittedExpression */); } - var node = createNode(169 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + var node = createNode(170 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169 /* BindingElement */); + var node = createNode(170 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -17123,33 +17177,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167 /* ObjectBindingPattern */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(168 /* ObjectBindingPattern */); + parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168 /* ArrayBindingPattern */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(169 /* ArrayBindingPattern */); + parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */ || isIdentifier(); + return token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218 /* VariableDeclaration */); + var node = createNode(219 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17158,14 +17212,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219 /* VariableDeclarationList */); + var node = createNode(220 /* VariableDeclarationList */); switch (token()) { - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: break; - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 74 /* ConstKeyword */: + case 75 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -17181,7 +17235,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 138 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17193,10 +17247,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200 /* VariableStatement */, fullStart); + var node = createNode(201 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17204,29 +17258,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* FunctionDeclaration */, fullStart); + var node = createNode(221 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148 /* Constructor */, pos); + var node = createNode(149 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121 /* ConstructorKeyword */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(122 /* ConstructorKeyword */); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147 /* MethodDeclaration */, fullStart); + var method = createNode(148 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -17234,12 +17288,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145 /* PropertyDeclaration */, fullStart); + var property = createNode(146 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -17261,12 +17315,12 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -17281,17 +17335,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: return true; default: return false; @@ -17299,7 +17353,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -17316,7 +17370,7 @@ var ts; } nextToken(); } - if (token() === 37 /* AsteriskToken */) { + if (token() === 38 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -17326,23 +17380,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 131 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 132 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 17 /* OpenParenToken */: // Method declaration - case 25 /* LessThanToken */: // Generic Method declaration - case 54 /* ColonToken */: // Type Annotation for declaration - case 56 /* EqualsToken */: // Initializer for declaration - case 53 /* QuestionToken */: + case 18 /* OpenParenToken */: // Method declaration + case 26 /* LessThanToken */: // Generic Method declaration + case 55 /* ColonToken */: // Type Annotation for declaration + case 57 /* EqualsToken */: // Initializer for declaration + case 54 /* QuestionToken */: return true; default: // Covers @@ -17359,10 +17413,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55 /* AtToken */)) { + if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(143 /* Decorator */, decoratorStart); + var decorator = createNode(144 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17389,7 +17443,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 75 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -17416,7 +17470,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -17427,8 +17481,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23 /* SemicolonToken */) { - var result = createNode(198 /* SemicolonClassElement */); + if (token() === 24 /* SemicolonToken */) { + var result = createNode(199 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17439,7 +17493,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121 /* ConstructorKeyword */) { + if (token() === 122 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -17450,13 +17504,13 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 37 /* AsteriskToken */ || - token() === 19 /* OpenBracketToken */) { + token() === 38 /* AsteriskToken */ || + token() === 20 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_10 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_10 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -17466,24 +17520,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 192 /* ClassExpression */); + /*modifiers*/ undefined, 193 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73 /* ClassKeyword */); + parseExpected(74 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); - if (parseExpected(15 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17501,9 +17555,9 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { @@ -17512,7 +17566,7 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */) { + if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { var node = createNode(251 /* HeritageClause */); node.token = token(); nextToken(); @@ -17522,38 +17576,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194 /* ExpressionWithTypeArguments */); + var node = createNode(195 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222 /* InterfaceDeclaration */, fullStart); + var node = createNode(223 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107 /* InterfaceKeyword */); + parseExpected(108 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* TypeAliasDeclaration */, fullStart); + var node = createNode(224 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134 /* TypeKeyword */); + parseExpected(135 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -17569,14 +17623,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* EnumDeclaration */, fullStart); + var node = createNode(225 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81 /* EnumKeyword */); + parseExpected(82 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17584,10 +17638,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(15 /* OpenBraceToken */)) { + var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -17595,7 +17649,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* 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 */; @@ -17603,16 +17657,16 @@ var ts; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21 /* DotToken */) + node.body = parseOptional(22 /* DotToken */) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -17620,7 +17674,7 @@ var ts; else { node.name = parseLiteralNode(/*internName*/ true); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -17630,15 +17684,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126 /* NamespaceKeyword */)) { + else if (parseOptional(127 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(125 /* ModuleKeyword */); + parseExpected(126 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -17646,57 +17700,57 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 /* RequireKeyword */ && + return token() === 130 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17 /* OpenParenToken */; + return nextToken() === 18 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 39 /* SlashToken */; + return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116 /* AsKeyword */); - parseExpected(126 /* NamespaceKeyword */); + parseExpected(117 /* AsKeyword */); + parseExpected(127 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); - parseExpected(23 /* SemicolonToken */); + parseExpected(24 /* SemicolonToken */); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89 /* ImportKeyword */); + parseExpected(90 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 /* CommaToken */ && token() !== 136 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 137 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(229 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(230 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } // Import statement - var importDeclaration = createNode(230 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */) { + token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136 /* FromKeyword */); + parseExpected(137 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17709,7 +17763,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(231 /* ImportClause */, fullStart); + var importClause = createNode(232 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17718,8 +17772,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token() === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(233 /* NamedImports */); + parseOptional(25 /* CommaToken */)) { + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(234 /* NamedImports */); } return finishNode(importClause); } @@ -17729,11 +17783,11 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(240 /* ExternalModuleReference */); - parseExpected(129 /* RequireKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(241 /* ExternalModuleReference */); + parseExpected(130 /* RequireKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -17752,9 +17806,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(232 /* NamespaceImport */); - parseExpected(37 /* AsteriskToken */); - parseExpected(116 /* AsKeyword */); + var namespaceImport = createNode(233 /* NamespaceImport */); + parseExpected(38 /* AsteriskToken */); + parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -17767,14 +17821,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 233 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 234 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238 /* ExportSpecifier */); + return parseImportOrExportSpecifier(239 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234 /* ImportSpecifier */); + return parseImportOrExportSpecifier(235 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17788,9 +17842,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(116 /* AsKeyword */); + parseExpected(117 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -17799,27 +17853,27 @@ var ts; else { node.name = identifierName; } - if (kind === 234 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 235 /* 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(236 /* ExportDeclaration */, fullStart); + var node = createNode(237 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(136 /* FromKeyword */); + if (parseOptional(38 /* AsteriskToken */)) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(238 /* 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. - if (token() === 136 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(136 /* FromKeyword */); + if (token() === 137 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17827,14 +17881,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235 /* ExportAssignment */, fullStart); + var node = createNode(236 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(77 /* DefaultKeyword */); + parseExpected(78 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -17909,10 +17963,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */ - || node.kind === 230 /* ImportDeclaration */ - || node.kind === 235 /* ExportAssignment */ - || node.kind === 236 /* ExportDeclaration */ + || node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */ + || node.kind === 231 /* ImportDeclaration */ + || node.kind === 236 /* ExportAssignment */ + || node.kind === 237 /* ExportDeclaration */ ? node : undefined; }); @@ -17957,24 +18011,24 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37 /* AsteriskToken */: - case 53 /* QuestionToken */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 49 /* ExclamationToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 22 /* DotDotDotToken */: - case 92 /* NewKeyword */: - case 97 /* ThisKeyword */: + case 38 /* AsteriskToken */: + case 54 /* QuestionToken */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 50 /* ExclamationToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 23 /* DotDotDotToken */: + case 93 /* NewKeyword */: + case 98 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = createSourceFile("file.js", 2 /* Latest */, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = createSourceFile("file.js", 4 /* Latest */, 1 /* JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -17987,21 +18041,21 @@ var ts; /* @internal */ function parseJSDocTypeExpression() { var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47 /* BarToken */) { + if (token() === 48 /* BarToken */) { var unionType = createNode(261 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; @@ -18012,20 +18066,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { var arrayType = createNode(260 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token() === 53 /* QuestionToken */) { + else if (token() === 54 /* QuestionToken */) { var nullableType = createNode(263 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49 /* ExclamationToken */) { + else if (token() === 50 /* ExclamationToken */) { var nonNullableType = createNode(264 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); @@ -18039,40 +18093,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: return parseJSDocAllType(); - case 53 /* QuestionToken */: + case 54 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseJSDocUnionType(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseJSDocTupleType(); - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJSDocRecordType(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 22 /* DotDotDotToken */: + case 23 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseJSDocConstructorType(); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return parseJSDocThisType(); - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -18080,14 +18134,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272 /* JSDocThisType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271 /* JSDocConstructorType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } @@ -18100,34 +18154,34 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269 /* JSDocFunctionType */); nextToken(); - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18 /* CloseParenToken */); - if (token() === 54 /* ColonToken */) { + parseExpected(19 /* CloseParenToken */); + if (token() === 55 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142 /* Parameter */); + var parameter = createNode(143 /* Parameter */); parameter.type = parseJSDocType(); - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? - parameter.questionToken = createNode(56 /* EqualsToken */); + parameter.questionToken = createNode(57 /* EqualsToken */); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21 /* DotToken */)) { - if (token() === 25 /* LessThanToken */) { + while (parseOptional(22 /* DotToken */)) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -18144,7 +18198,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -18155,7 +18209,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139 /* QualifiedName */, left.pos); + var result = createNode(140 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -18176,7 +18230,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -18189,13 +18243,13 @@ var ts; var result = createNode(261 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47 /* BarToken */)) { + while (parseOptional(48 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -18224,12 +18278,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 24 /* CommaToken */ || - token() === 16 /* CloseBraceToken */ || - token() === 18 /* CloseParenToken */ || - token() === 27 /* GreaterThanToken */ || - token() === 56 /* EqualsToken */ || - token() === 47 /* BarToken */) { + if (token() === 25 /* CommaToken */ || + token() === 17 /* CloseBraceToken */ || + token() === 19 /* CloseParenToken */ || + token() === 28 /* GreaterThanToken */ || + token() === 57 /* EqualsToken */ || + token() === 48 /* BarToken */) { var result = createNode(259 /* JSDocUnknownType */, pos); return finishNode(result); } @@ -18240,7 +18294,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); sourceFile = { languageVariant: 0 /* Standard */, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -18309,7 +18363,7 @@ var ts; } while (token() !== 1 /* EndOfFileToken */) { switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); parseTag(indent); @@ -18330,7 +18384,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -18343,7 +18397,7 @@ var ts; indent += asterisk.length; } break; - case 69 /* Identifier */: + case 70 /* Identifier */: // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. @@ -18404,8 +18458,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getTokenPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18457,7 +18511,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 56 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { switch (token()) { case 4 /* NewLineTrivia */: if (state >= 1 /* SawAsterisk */) { @@ -18466,7 +18520,7 @@ var ts; } indent = 0; break; - case 55 /* AtToken */: + case 56 /* AtToken */: // Done break; case 5 /* WhitespaceTrivia */: @@ -18482,7 +18536,7 @@ var ts; indent += whitespace.length; } break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -18495,7 +18549,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { // Done break; } @@ -18524,7 +18578,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15 /* OpenBraceToken */) { + if (token() !== 16 /* OpenBraceToken */) { return undefined; } return parseJSDocTypeExpression(); @@ -18536,15 +18590,15 @@ var ts; var name; var isBracketed; // Looking for something like '[foo]' or 'foo' - if (parseOptionalToken(19 /* OpenBracketToken */)) { + if (parseOptionalToken(20 /* OpenBracketToken */)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(56 /* EqualsToken */)) { + if (parseOptionalToken(57 /* EqualsToken */)) { parseExpression(); } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -18621,7 +18675,7 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69 /* Identifier */) { + if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_11 = jsDocTypeReference.name; if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -18645,7 +18699,7 @@ var ts; while (token() !== 1 /* EndOfFileToken */ && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -18659,13 +18713,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69 /* Identifier */: + case 70 /* Identifier */: canParseTag = false; case 1 /* EndOfFileToken */: break; @@ -18676,8 +18730,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getStartPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18717,11 +18771,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141 /* TypeParameter */, name_12.pos); + var typeParameter = createNode(142 /* TypeParameter */, name_12.pos); typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24 /* CommaToken */) { + if (token() === 25 /* CommaToken */) { nextJSDocToken(); skipWhitespace(); } @@ -18750,7 +18804,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69 /* Identifier */, pos); + var result = createNode(70 /* Identifier */, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -18868,8 +18922,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -18878,7 +18932,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: return true; } return false; @@ -19006,8 +19060,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -19249,16 +19303,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 224 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 226 /* ModuleBlock */) { + else if (node.kind === 227 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19277,7 +19331,7 @@ var ts; }); return state_1; } - else if (node.kind === 225 /* ModuleDeclaration */) { + else if (node.kind === 226 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -19415,7 +19469,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19428,7 +19482,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -19440,21 +19494,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return "__constructor"; - case 156 /* FunctionType */: - case 151 /* CallSignature */: + case 157 /* FunctionType */: + case 152 /* CallSignature */: return "__call"; - case 157 /* ConstructorType */: - case 152 /* ConstructSignature */: + case 158 /* ConstructorType */: + case 153 /* ConstructSignature */: return "__new"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "__index"; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return "__export"; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19469,12 +19523,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; case 269 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142 /* Parameter */: + case 143 /* 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 === 269 /* JSDocFunctionType */); @@ -19484,10 +19538,10 @@ var ts; case 279 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { nameFromParentNode = nameIdentifier.text; } } @@ -19571,7 +19625,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 === 235 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19591,7 +19645,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 238 /* ExportSpecifier */ || (node.kind === 229 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 239 /* ExportSpecifier */ || (node.kind === 230 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19753,64 +19807,64 @@ var ts; return; } switch (node.kind) { - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: bindWhileStatement(node); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: bindDoStatement(node); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: bindForStatement(node); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: bindIfStatement(node); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: bindTryStatement(node); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: bindSwitchStatement(node); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: bindCaseBlock(node); break; case 249 /* CaseClause */: bindCaseClause(node); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: bindLabeledStatement(node); break; - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19820,25 +19874,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return hasNarrowableArgument(expr); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 185 /* PrefixUnaryExpression */: - return expr.operator === 49 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 186 /* PrefixUnaryExpression */: + return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 /* Identifier */ || - expr.kind === 97 /* ThisKeyword */ || - expr.kind === 172 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + return expr.kind === 70 /* Identifier */ || + expr.kind === 98 /* ThisKeyword */ || + expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19849,41 +19903,41 @@ var ts; } } } - if (expr.expression.kind === 172 /* PropertyAccessExpression */ && + if (expr.expression.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 183 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableReference(expr.left); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -19903,7 +19957,7 @@ var ts; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 256 /* Referenced */ ? 512 /* Shared */ : 256 /* Referenced */; + flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -19918,8 +19972,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 99 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 84 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 100 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 85 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -19953,6 +20007,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256 /* ArrayMutation */, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -19966,34 +20028,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203 /* IfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 204 /* IfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: return parent.expression === node; - case 206 /* ForStatement */: - case 188 /* ConditionalExpression */: + case 207 /* ForStatement */: + case 189 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 185 /* PrefixUnaryExpression */ && node.operator === 49 /* ExclamationToken */) { + else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 187 /* BinaryExpression */ && (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 52 /* BarBarToken */); + return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */ || - node.parent.kind === 185 /* PrefixUnaryExpression */ && - node.parent.operator === 49 /* ExclamationToken */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */ || + node.parent.kind === 186 /* PrefixUnaryExpression */ && + node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -20066,7 +20128,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219 /* VariableDeclarationList */) { + if (node.initializer.kind !== 220 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20088,7 +20150,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211 /* ReturnStatement */) { + if (node.kind === 212 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20108,7 +20170,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20128,24 +20190,41 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; // TODO: Every statement in try block is potentially an exit point! bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + // in finally flow is combined from pre-try/flow from try/flow from catch + // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + // if flow after finally is unreachable - keep it + // otherwise check if flows after try and after catch are unreachable + // if yes - convert current flow to unreachable + // i.e. + // try { return "1" } finally { console.log(1); } + // console.log(2); // this line should be unreachable even if flow falls out of finally block + if (!(currentFlow.flags & 1 /* Unreachable */)) { + if ((flowAfterTry.flags & 1 /* Unreachable */) && (flowAfterCatch.flags & 1 /* Unreachable */)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - // if try statement has finally block and flow after finally block is unreachable - keep it - // otherwise use whatever flow was accumulated at postFinallyLabel - if (!node.finallyBlock || !(currentFlow.flags & 1 /* Unreachable */)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -20224,7 +20303,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20235,10 +20314,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170 /* ArrayLiteralExpression */) { + else if (node.kind === 171 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191 /* SpreadElementExpression */) { + if (e.kind === 192 /* SpreadElementExpression */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20246,7 +20325,7 @@ var ts; } } } - else if (node.kind === 171 /* ObjectLiteralExpression */) { + else if (node.kind === 172 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253 /* PropertyAssignment */) { @@ -20260,7 +20339,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -20271,7 +20350,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49 /* ExclamationToken */) { + if (node.operator === 50 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -20281,20 +20360,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 /* AmpersandAmpersandToken */ || operator === 52 /* BarBarToken */) { + if (operator === 52 /* AmpersandAmpersandToken */ || operator === 53 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -20306,14 +20385,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { + if (operator === 57 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172 /* PropertyAccessExpression */) { + if (node.expression.kind === 173 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20344,7 +20429,7 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 /* ForInStatement */ || node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 208 /* ForInStatement */ || node.parent.parent.kind === 209 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20353,10 +20438,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 178 /* ParenthesizedExpression */) { + while (expr.kind === 179 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 179 /* FunctionExpression */ || expr.kind === 180 /* ArrowFunction */) { + if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20364,54 +20449,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173 /* PropertyAccessExpression */) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return 1 /* IsContainer */; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; case 269 /* JSDocFunctionType */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: return 1 /* IsContainer */ | 32 /* HasLocals */; case 256 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; case 252 /* CatchClause */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 227 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 228 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 199 /* Block */: + case 200 /* 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 @@ -20448,18 +20539,18 @@ 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 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159 /* TypeLiteral */: - case 171 /* ObjectLiteralExpression */: - case 222 /* InterfaceDeclaration */: + case 160 /* TypeLiteral */: + case 172 /* ObjectLiteralExpression */: + case 223 /* InterfaceDeclaration */: case 265 /* JSDocRecordType */: case 281 /* JSDocTypeLiteral */: // Interface/Object-types always have their children added to the 'members' of @@ -20468,21 +20559,21 @@ var ts; // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* JSDocFunctionType */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -20504,10 +20595,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */)) { + if (body && (body.kind === 256 /* SourceFile */ || body.kind === 227 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 /* ExportDeclaration */ || stat.kind === 235 /* ExportAssignment */) { + if (stat.kind === 237 /* ExportDeclaration */ || stat.kind === 236 /* ExportAssignment */) { return true; } } @@ -20600,7 +20691,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69 /* Identifier */) { + if (prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20612,7 +20703,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 === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 147 /* MethodDeclaration */ + var currentKind = prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 148 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20634,7 +20725,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256 /* SourceFile */: @@ -20658,8 +20749,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 107 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 115 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { // Report error only if there are no parse errors in file @@ -20695,7 +20786,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 69 /* Identifier */) { + if (inStrictMode && node.expression.kind === 70 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span_2 = ts.getErrorSpanForNode(file, node.expression); @@ -20703,11 +20794,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69 /* Identifier */) { + if (name && name.kind === 70 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -20746,10 +20837,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration if (blockScopeContainer.kind !== 256 /* SourceFile */ && - blockScopeContainer.kind !== 225 /* ModuleDeclaration */ && + blockScopeContainer.kind !== 226 /* 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. @@ -20775,7 +20866,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -20815,7 +20906,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 138 /* LastToken */) { + if (node.kind > 139 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -20856,18 +20947,18 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: if (currentFlow && (ts.isExpression(node) || parent.kind === 254 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -20893,30 +20984,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252 /* CatchClause */: return checkStrictModeCatchClause(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkStrictModeWithStatement(node); - case 165 /* ThisType */: + case 166 /* ThisType */: seenThisKeyword = true; return; - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 142 /* Parameter */: + case 143 /* Parameter */: return bindParameter(node); - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 266 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); case 280 /* JSDocPropertyTag */: @@ -20929,90 +21020,90 @@ var ts; case 247 /* JsxSpreadAttribute */: emitFlags |= 16384 /* HasJsxSpreadAttributes */; return; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // 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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: case 269 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return bindFunctionExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); case 279 /* JSDocTypedefTag */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 229 /* ImportEqualsDeclaration */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return bindImportClause(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return bindExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return bindExportAssignment(node); case 256 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69 /* Identifier */) { + if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165 /* ThisType */) { + if (parameterName && parameterName.kind === 166 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -21035,7 +21126,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 === 235 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21081,7 +21172,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -21098,12 +21191,12 @@ 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 === 220 /* FunctionDeclaration */ || container.kind === 179 /* FunctionExpression */) { + if (container.kind === 221 /* FunctionDeclaration */ || container.kind === 180 /* 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 */); } - else if (container.kind === 148 /* Constructor */) { + else if (container.kind === 149 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -21154,7 +21247,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21298,13 +21391,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 201 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 202 /* EmptyStatement */) || // report error on class declarations - node.kind === 221 /* ClassDeclaration */ || + node.kind === 222 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 225 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 224 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 225 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21318,7 +21411,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 !== 200 /* VariableStatement */ || + (node.kind !== 201 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21338,52 +21431,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 225 /* ModuleDeclaration */: + case 176 /* NewExpression */: + return computeNewExpression(node, subtreeFlags); + case 226 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 142 /* Parameter */: + case 143 /* Parameter */: return computeParameter(node, subtreeFlags); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); case 251 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148 /* Constructor */: + case 149 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21394,44 +21489,60 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */ + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */ || isSuperOrSuperProperty(expression, expressionKind)) { // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537133909 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return true; - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95 /* SuperKeyword */; + return expressionKind === 96 /* SuperKeyword */; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { + // If the this node contains a SpreadElementExpression then it is an ES6 + // node. + transformFlags |= 768 /* AssertES2015 */; + } + node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 /* EqualsToken */ - && (leftKind === 171 /* ObjectLiteralExpression */ - || leftKind === 170 /* ArrayLiteralExpression */)) { + if (operatorTokenKind === 57 /* EqualsToken */ + && (leftKind === 172 /* ObjectLiteralExpression */ + || leftKind === 171 /* ArrayLiteralExpression */)) { // Destructuring assignments are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 256 /* DestructuringAssignment */; + transformFlags |= 768 /* AssertES2015 */ | 1024 /* DestructuringAssignment */; } - else if (operatorTokenKind === 38 /* AsteriskAsteriskToken */ - || operatorTokenKind === 60 /* AsteriskAsteriskEqualsToken */) { - // Exponentiation is ES7 syntax. - transformFlags |= 48 /* AssertES7 */; + else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ + || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { + // Exponentiation is ES2016 syntax. + transformFlags |= 192 /* AssertES2016 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21439,25 +21550,25 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - // If the parameter has a question token, then it is TypeScript syntax. - if (node.questionToken) { - transformFlags |= 3 /* AssertTypeScript */; - } - // If the parameter's name is 'this', then it is TypeScript syntax. - if (subtreeFlags & 2048 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { + // The '?' token, type annotations, decorators, and 'this' parameters are TypeSCript + // syntax. + if (node.questionToken + || node.type + || subtreeFlags & 8192 /* ContainsDecorators */ + || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. if (modifierFlags & 92 /* ParameterPropertyModifier */) { - transformFlags |= 3 /* AssertTypeScript */ | 131072 /* ContainsParameterPropertyAssignments */; + transformFlags |= 3 /* AssertTypeScript */ | 524288 /* ContainsParameterPropertyAssignments */; } // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. - if (subtreeFlags & 2097152 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { - transformFlags |= 192 /* AssertES6 */ | 65536 /* ContainsDefaultValueAssignments */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { + transformFlags |= 768 /* AssertES2015 */ | 262144 /* ContainsDefaultValueAssignments */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* ParameterExcludes */; + return transformFlags & ~545262933 /* ParameterExcludes */; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21467,17 +21578,17 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 195 /* AsExpression */ - || expressionKind === 177 /* TypeAssertionExpression */) { + if (expressionKind === 196 /* AsExpression */ + || expressionKind === 178 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 256 /* DestructuringAssignment */; + if (expressionTransformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 1024 /* DestructuringAssignment */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -21488,47 +21599,49 @@ var ts; } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | 192 /* AssertES6 */; + transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. // An exported declaration may be TypeScript syntax. - if ((subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) - || (modifierFlags & 1 /* Export */)) { + if ((subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */) + || (modifierFlags & 1 /* Export */) + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeClassExpression(node, subtreeFlags) { // A ClassExpression is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - if (subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) { + if (subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */ + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83 /* ExtendsKeyword */: + case 84 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 106 /* ImplementsKeyword */: + case 107 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -21537,65 +21650,65 @@ var ts; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionWithTypeArguments(node, subtreeFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { - // An overload constructor is TypeScript syntax. + // TypeScript-specific modifiers and overloads are TypeScript syntax + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* ConstructorExcludes */; + return transformFlags & ~591760725 /* ConstructorExcludes */; } function computeMethod(node, subtreeFlags) { // A MethodDeclaration is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || typeParameters - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and + // overloads are TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } + // An async method declaration is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // Currently, we only support generators that were originally async function bodies. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + // Decorators, TypeScript-specific modifiers, type annotations, and overloads are + // TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computePropertyDeclaration(node, subtreeFlags) { // A PropertyDeclaration is TypeScript syntax. @@ -21603,88 +21716,105 @@ var ts; // If the PropertyDeclaration has an initializer, we need to inform its ancestor // so that it handle the transformation. if (node.initializer) { - transformFlags |= 4096 /* ContainsPropertyInitializer */; + transformFlags |= 16384 /* ContainsPropertyInitializer */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2 /* Ambient */)) { // An ambient declaration is TypeScript syntax. // A FunctionDeclaration without a body is an overload and is TypeScript syntax. transformFlags = 3 /* AssertTypeScript */; } else { - transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; + transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 3 /* AssertTypeScript */ | 192 /* AssertES6 */; + transformFlags |= 3 /* AssertTypeScript */ | 768 /* AssertES2015 */; } - // If a FunctionDeclaration is async, then it is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (modifierFlags & 2270 /* TypeScriptModifier */ + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function declaration is ES2017 syntax. + if (modifierFlags & 256 /* Async */) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionDeclaration is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - // An async function expression is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function expression is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeArrowFunction(node, subtreeFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - // An async arrow function is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async arrow function is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { - transformFlags |= 16384 /* ContainsCapturedLexicalThis */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { + transformFlags |= 65536 /* ContainsCapturedLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550710101 /* ArrowFunctionExcludes */; + return transformFlags & ~592227669 /* ArrowFunctionExcludes */; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21692,21 +21822,25 @@ var ts; var expressionKind = expression.kind; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (expressionKind === 95 /* SuperKeyword */) { - transformFlags |= 8192 /* ContainsLexicalThis */; + if (expressionKind === 96 /* SuperKeyword */) { + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; // A VariableDeclaration with a binding pattern is ES6 syntax. - if (nameKind === 167 /* ObjectBindingPattern */ || nameKind === 168 /* ArrayBindingPattern */) { - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + if (nameKind === 168 /* ObjectBindingPattern */ || nameKind === 169 /* ArrayBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + } + // Type annotations are TypeScript syntax. + if (node.type) { + transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -21720,24 +21854,24 @@ var ts; transformFlags = subtreeFlags; // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; } - if (declarationListTransformFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + if (declarationListTransformFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */ + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */ && ts.isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21746,18 +21880,18 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // If the expression of an expression statement is a destructuring assignment, // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. - if (node.expression.transformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 192 /* AssertES6 */; + if (node.expression.transformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3 /* AssertTypeScript */; @@ -21766,46 +21900,49 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~546335573 /* ModuleExcludes */; + return transformFlags & ~574729557 /* ModuleExcludes */; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; - if (subtreeFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & 3 /* BlockScoped */) { - transformFlags |= 192 /* AssertES6 */ | 1048576 /* ContainsBlockScopedBinding */; + transformFlags |= 768 /* AssertES2015 */ | 4194304 /* ContainsBlockScopedBinding */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* VariableDeclarationListExcludes */; + return transformFlags & ~545262933 /* VariableDeclarationListExcludes */; } function computeOther(node, kind, subtreeFlags) { // Mark transformations needed for each node var transformFlags = subtreeFlags; - var excludeFlags = 536871765 /* NodeExcludes */; + var excludeFlags = 536874325 /* NodeExcludes */; switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 122 /* DeclareKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 184 /* AwaitExpression */: - case 224 /* EnumDeclaration */: + case 119 /* AsyncKeyword */: + case 185 /* AwaitExpression */: + // async/await is ES2017 syntax + transformFlags |= 48 /* AssertES2017 */; + break; + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: - case 196 /* NonNullExpression */: - case 128 /* ReadonlyKeyword */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: + case 197 /* NonNullExpression */: + case 129 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: - case 244 /* JsxText */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: + case 10 /* JsxText */: case 245 /* JsxClosingElement */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: @@ -21813,64 +21950,64 @@ var ts; // These nodes are Jsx syntax. transformFlags |= 12 /* AssertJsx */; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: // This node is both ES6 and TypeScript syntax. - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; break; - case 77 /* DefaultKeyword */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - case 189 /* TemplateExpression */: - case 176 /* TaggedTemplateExpression */: + case 78 /* DefaultKeyword */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + case 190 /* TemplateExpression */: + case 177 /* TaggedTemplateExpression */: case 254 /* ShorthandPropertyAssignment */: - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 4194304 /* ContainsYield */; + transformFlags |= 768 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 154 /* TypePredicate */: - case 155 /* TypeReference */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 155 /* TypePredicate */: + case 156 /* TypeReference */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. - transformFlags |= 524288 /* ContainsComputedPropertyName */; - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { + transformFlags |= 2097152 /* ContainsComputedPropertyName */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { // A computed method name like `[this.getName()](x: string) { ... }` needs to // distinguish itself from the normal case of a method body containing `this`: // `this` inside a method doesn't need to be rewritten (the method provides `this`), @@ -21879,70 +22016,70 @@ var ts; // `_this = this; () => class K { [_this.getName()]() { ... } }` // To make this distinction, use ContainsLexicalThisInComputedPropertyName // instead of ContainsLexicalThis for computed property names - transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; + transformFlags |= 131072 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: // This node is ES6 syntax, but is handled by a containing node. - transformFlags |= 262144 /* ContainsSpreadElementExpression */; + transformFlags |= 1048576 /* ContainsSpreadElementExpression */; break; - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; break; - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. - transformFlags |= 3 /* AssertTypeScript */ | 2048 /* ContainsDecorators */; + transformFlags |= 3 /* AssertTypeScript */ | 8192 /* ContainsDecorators */; break; - case 171 /* ObjectLiteralExpression */: - excludeFlags = 537430869 /* ObjectLiteralExcludes */; - if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { + case 172 /* ObjectLiteralExpression */: + excludeFlags = 539110741 /* ObjectLiteralExcludes */; + if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } break; - case 170 /* ArrayLiteralExpression */: - case 175 /* NewExpression */: - excludeFlags = 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */) { + case 171 /* ArrayLiteralExpression */: + case 176 /* NewExpression */: + excludeFlags = 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { // If the this node contains a SpreadElementExpression, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } break; - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { + transformFlags |= 768 /* AssertES2015 */; } break; case 256 /* SourceFile */: - if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 65536 /* ContainsCapturedLexicalThis */) { + transformFlags |= 768 /* AssertES2015 */; } break; - case 211 /* ReturnStatement */: - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: - transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; + case 212 /* ReturnStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: + transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21953,7 +22090,7 @@ var ts; /// var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -22724,6 +22861,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); @@ -22774,6 +22912,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; // The library files are only loaded when the feature is used. // This allows users to just specify library files they want to used through --lib @@ -23018,7 +23157,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 225 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 226 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 226 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23174,7 +23313,7 @@ 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 !== 218 /* VariableDeclaration */ || + return declaration.kind !== 219 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -23183,9 +23322,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200 /* VariableStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 201 /* VariableStatement */: + case 207 /* ForStatement */: + case 209 /* 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)) { @@ -23194,8 +23333,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23214,7 +23353,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 /* PropertyDeclaration */ && + current.parent.kind === 146 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -23250,8 +23389,8 @@ var ts; if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 273 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 142 /* Parameter */ || - lastLocation.kind === 141 /* TypeParameter */ + lastLocation.kind === 143 /* Parameter */ || + lastLocation.kind === 142 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -23260,9 +23399,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 142 /* Parameter */ || + lastLocation.kind === 143 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 142 /* Parameter */); + result.valueDeclaration.kind === 143 /* Parameter */); } } if (useResult) { @@ -23278,7 +23417,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local @@ -23303,7 +23442,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 238 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 239 /* ExportSpecifier */)) { break; } } @@ -23311,13 +23450,13 @@ var ts; break loop; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -23334,9 +23473,9 @@ var ts; } } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* 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 @@ -23347,7 +23486,7 @@ var ts; } break loop; } - if (location.kind === 192 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23363,9 +23502,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223 /* 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); @@ -23373,19 +23512,19 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23398,7 +23537,7 @@ var ts; } } break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -23407,7 +23546,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 142 /* Parameter */) { + if (location.parent && location.parent.kind === 143 /* Parameter */) { location = location.parent; } // @@ -23470,7 +23609,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 === 228 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 229 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23478,7 +23617,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); @@ -23523,10 +23662,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23548,7 +23687,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, 218 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23569,10 +23708,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 230 /* ImportDeclaration */) { + while (node && node.kind !== 231 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23582,10 +23721,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -23707,19 +23846,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return getTargetOfImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -23766,11 +23905,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235 /* ExportAssignment */) { + if (node.kind === 236 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 238 /* ExportSpecifier */) { + else if (node.kind === 239 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -23781,24 +23920,24 @@ var ts; } } // This function is only for imports with entity names - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { // There are three things we might try to look for. In the following examples, // the search term is enclosed in |...|: // // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 70 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 139 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 140 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 229 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 230 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -23811,16 +23950,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69 /* Identifier */) { + if (name.kind === 70 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 /* QualifiedName */ || name.kind === 172 /* PropertyAccessExpression */) { - var left = name.kind === 139 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 139 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 140 /* QualifiedName */ || name.kind === 173 /* PropertyAccessExpression */) { + var left = name.kind === 140 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 140 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -24027,7 +24166,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -24106,7 +24245,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24147,7 +24286,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24186,7 +24325,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, 238 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24201,10 +24340,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: continue; default: return false; @@ -24235,7 +24374,7 @@ var ts; return { accessibility: 1 /* NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined, }; } return hasAccessibleDeclarations; @@ -24272,7 +24411,7 @@ var ts; // Just a local name that is not accessible return { accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 /* Accessible */ }; @@ -24326,12 +24465,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 158 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 139 /* QualifiedName */ || entityName.kind === 172 /* PropertyAccessExpression */ || - entityName.parent.kind === 229 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 140 /* QualifiedName */ || entityName.kind === 173 /* PropertyAccessExpression */ || + entityName.parent.kind === 230 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24427,10 +24566,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164 /* ParenthesizedType */) { + while (node.kind === 165 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 224 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24438,7 +24577,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 /* ModuleBlock */ && + node.parent.kind === 227 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24452,10 +24591,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return "(Anonymous class)"; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24478,17 +24617,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); writer.writeSymbol(symbolName, symbol); } } @@ -24587,7 +24726,7 @@ var ts; } else if (type.flags & 256 /* EnumLiteral */) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 /* Class */ | 65536 /* Interface */ | 16 /* Enum */ | 16384 /* TypeParameter */)) { @@ -24617,23 +24756,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24 /* CommaToken */) { + if (delimiter !== 25 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 25 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -24642,29 +24781,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } if (pos < end) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); writeType(typeArguments[pos], 256 /* InFirstTypeArgument */); pos++; while (pos < end) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos], 0 /* None */); pos++; } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 19 /* OpenBracketToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else if (type.target.flags & 262144 /* Tuple */) { - writePunctuation(writer, 19 /* OpenBracketToken */); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24 /* CommaToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -24685,7 +24824,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); } } } @@ -24695,16 +24834,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } if (type.flags & 524288 /* Union */) { - writeTypeList(formatUnionTypes(type.types), 47 /* BarToken */); + writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); } else { - writeTypeList(type.types, 46 /* AmpersandToken */); + writeTypeList(type.types, 47 /* AmpersandToken */); } if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -24726,7 +24865,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 117 /* AnyKeyword */); + writeKeyword(writer, 118 /* AnyKeyword */); } } else { @@ -24750,7 +24889,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 226 /* ModuleBlock */; + return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 227 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -24760,37 +24899,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101 /* TypeOfKeyword */); + writeKeyword(writer, 102 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(info.type, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -24809,53 +24948,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15 /* OpenBraceToken */); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1 /* Construct */, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 130 /* NumberKeyword */); + writeIndexSignature(resolved.stringIndexInfo, 133 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 131 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -24865,21 +25004,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -24894,7 +25033,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83 /* ExtendsKeyword */); + writeKeyword(writer, 84 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -24902,7 +25041,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -24911,37 +25050,37 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 167 /* ObjectBindingPattern */) { - writePunctuation(writer, 15 /* OpenBraceToken */); + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { - writePunctuation(writer, 19 /* OpenBracketToken */); + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -24949,75 +25088,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - var flags_1 = 256 /* InFirstTypeArgument */; + writePunctuation(writer, 26 /* LessThanToken */); + var flags = 256 /* InFirstTypeArgument */; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); - flags_1 = 0 /* None */; + flags = 0 /* None */; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97 /* ThisKeyword */); + writeKeyword(writer, 98 /* ThisKeyword */); } writeSpace(writer); - writeKeyword(writer, 124 /* IsKeyword */); + writeKeyword(writer, 125 /* IsKeyword */); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 34 /* EqualsGreaterThanToken */); + writePunctuation(writer, 35 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); } writeSpace(writer); if (signature.typePredicate) { @@ -25030,7 +25169,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); } if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -25068,22 +25207,22 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 218 /* VariableDeclaration */: + case 219 /* 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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 220 /* FunctionDeclaration */: - case 224 /* EnumDeclaration */: - case 229 /* ImportEqualsDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 225 /* EnumDeclaration */: + case 230 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -25091,52 +25230,52 @@ var ts; var parent_10 = 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 !== 229 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_10); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 148 /* Constructor */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: - case 142 /* Parameter */: - case 226 /* ModuleBlock */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: - case 155 /* TypeReference */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: + case 149 /* Constructor */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: + case 143 /* Parameter */: + case 227 /* ModuleBlock */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: + case 156 /* TypeReference */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: return false; // Type parameters are always visible - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: // Source file and namespace export are always visible case 256 /* SourceFile */: - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return false; default: return false; @@ -25145,10 +25284,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 236 /* 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 === 238 /* ExportSpecifier */) { + else if (node.parent.kind === 239 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25242,12 +25381,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218 /* VariableDeclaration */: - case 219 /* VariableDeclarationList */: - case 234 /* ImportSpecifier */: - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - case 231 /* ImportClause */: + case 219 /* VariableDeclaration */: + case 220 /* VariableDeclarationList */: + case 235 /* ImportSpecifier */: + case 234 /* NamedImports */: + case 233 /* NamespaceImport */: + case 232 /* ImportClause */: node = node.parent; break; default: @@ -25282,12 +25421,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return name.text; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -25295,7 +25434,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { @@ -25315,7 +25454,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 167 /* ObjectBindingPattern */) { + if (pattern.kind === 168 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_14 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_14)) { @@ -25383,16 +25522,16 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 /* VariableDeclaration */ && - declaration.parent.kind === 219 /* VariableDeclarationList */ && - declaration.parent.parent.kind === 200 /* VariableStatement */) { + if (declaration.kind === 219 /* VariableDeclaration */ && + declaration.parent.kind === 220 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 201 /* VariableStatement */) { // @type annotation might have been on the variable statement, try that instead. var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142 /* Parameter */) { + else if (declaration.kind === 143 /* Parameter */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); @@ -25402,9 +25541,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 /* NullKeyword */ || expr.kind === 69 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 /* NullKeyword */ || expr.kind === 70 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; @@ -25421,10 +25564,10 @@ var ts; } } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 207 /* ForInStatement */) { + if (declaration.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 208 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 209 /* 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, @@ -25438,18 +25581,24 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - // Use control flow type inference for non-ambient, non-exported var or let variables with no initializer - // or a 'null' or 'undefined' initializer. - if (declaration.kind === 218 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { + // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no + // initializer or a 'null' or 'undefined' initializer. + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array + // literal initializer. + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 150 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149 /* GetAccessor */); + if (func.kind === 151 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -25464,8 +25613,7 @@ var ts; // Use contextual parameter type if one is available var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -25537,7 +25685,7 @@ var ts; var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { - return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); @@ -25556,7 +25704,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 /* ObjectBindingPattern */ + return pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25595,7 +25743,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 143 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -25611,7 +25759,7 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 235 /* ExportAssignment */) { + if (declaration.kind === 236 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) { @@ -25627,8 +25775,8 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 187 /* BinaryExpression */ || - declaration.kind === 172 /* PropertyAccessExpression */ && declaration.parent.kind === 187 /* BinaryExpression */) { + if (declaration.kind === 188 /* BinaryExpression */ || + declaration.kind === 173 /* PropertyAccessExpression */ && declaration.parent.kind === 188 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement if (declaration.flags & 1048576 /* JavaScriptFile */) { var typeTag = ts.getJSDocTypeTag(declaration.parent); @@ -25636,7 +25784,7 @@ var ts; return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 /* BinaryExpression */ ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -25664,7 +25812,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -25684,8 +25832,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 150 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 151 /* SetAccessor */); if (getter && getter.flags & 1048576 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -25729,7 +25877,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -25740,7 +25888,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -25836,9 +25984,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */ || - node.kind === 220 /* FunctionDeclaration */ || node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */ || node.kind === 180 /* ArrowFunction */) { + if (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */ || + node.kind === 221 /* FunctionDeclaration */ || node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */ || node.kind === 181 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -25848,7 +25996,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, 222 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -25857,8 +26005,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 221 /* ClassDeclaration */ || - node.kind === 192 /* ClassExpression */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 222 /* ClassDeclaration */ || + node.kind === 193 /* ClassExpression */ || node.kind === 224 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26001,7 +26149,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 === 222 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -26033,7 +26181,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 223 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26102,7 +26250,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -26128,14 +26276,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 69 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26163,7 +26311,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 === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26201,7 +26349,7 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -26254,20 +26402,20 @@ var ts; // considered independent. function isIndependentType(node) { switch (node.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 167 /* LiteralType */: return true; - case 160 /* ArrayType */: + case 161 /* ArrayType */: return isIndependentType(node.elementType); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26280,7 +26428,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -26301,12 +26449,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -26933,7 +27081,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69 /* Identifier */) { + if (node.parameterName.kind === 70 /* Identifier */) { var parameterName = node.parameterName; return { kind: 1 /* Identifier */, @@ -26976,7 +27124,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166 /* LiteralType */) { + if (param.type && param.type.kind === 167 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -26990,10 +27138,10 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 149 /* GetAccessor */ || declaration.kind === 150 /* SetAccessor */) && + if ((declaration.kind === 150 /* GetAccessor */ || declaration.kind === 151 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = declaration.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -27005,24 +27153,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 /* Constructor */ ? + var classType = declaration.kind === 149 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 /* TypePredicate */ ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -27040,8 +27185,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 149 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150 /* SetAccessor */); + if (declaration.kind === 150 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -27055,19 +27200,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* 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 @@ -27155,7 +27300,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 /* Constructor */ || signature.declaration.kind === 152 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 149 /* Constructor */ || signature.declaration.kind === 153 /* ConstructSignature */; var type = createObjectType(2097152 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -27169,7 +27314,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 130 /* NumberKeyword */ : 132 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 131 /* NumberKeyword */ : 133 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -27196,7 +27341,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 142 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -27229,7 +27374,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -27341,11 +27486,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; case 267 /* JSDocTypeReference */: return node.name; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27355,7 +27500,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -27386,12 +27531,12 @@ var ts; var type = void 0; if (node.kind === 267 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 155 /* TypeReference */ + var typeNameOrExpression = node.kind === 156 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -27426,9 +27571,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: return declaration; } } @@ -27838,9 +27983,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 148 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -27859,25 +28004,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117 /* AnyKeyword */: + case 118 /* AnyKeyword */: case 258 /* JSDocAllType */: case 259 /* JSDocUnknownType */: return anyType; - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return stringType; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return numberType; - case 120 /* BooleanKeyword */: + case 121 /* BooleanKeyword */: return booleanType; - case 133 /* SymbolKeyword */: + case 134 /* SymbolKeyword */: return esSymbolType; - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return voidType; - case 135 /* UndefinedKeyword */: + case 136 /* UndefinedKeyword */: return undefinedType; - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullType; - case 127 /* NeverKeyword */: + case 128 /* NeverKeyword */: return neverType; case 283 /* JSDocNullKeyword */: return nullType; @@ -27885,33 +28030,33 @@ var ts; return undefinedType; case 285 /* JSDocNeverKeyword */: return neverType; - case 165 /* ThisType */: - case 97 /* ThisKeyword */: + case 166 /* ThisType */: + case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 282 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 155 /* TypeReference */: + case 156 /* TypeReference */: case 267 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return booleanType; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: case 260 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 162 /* UnionType */: + case 163 /* UnionType */: case 261 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: case 263 /* JSDocNullableType */: case 264 /* JSDocNonNullableType */: case 271 /* JSDocConstructorType */: @@ -27920,16 +28065,16 @@ var ts; return getTypeFromTypeNode(node.type); case 265 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 269 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262 /* JSDocTupleType */: @@ -28097,23 +28242,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28123,14 +28268,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: return false; } @@ -28173,35 +28318,50 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187 /* BinaryExpression */: - return node.operatorToken.kind === 52 /* BarBarToken */ && + case 188 /* BinaryExpression */: + return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 /* ArrowFunction */ && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + // Functions with type parameters are not context sensitive. + if (node.typeParameters) { + return false; + } + // Functions with any parameters that lack type annotations are context sensitive. + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + // For arrow functions we now know we're not context sensitive. + if (node.kind === 181 /* ArrowFunction */) { + return false; + } + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. Otherwise we + // know that all parameters (including 'this') have type annotations and nothing is + // subject to contextual typing. + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -28691,8 +28851,8 @@ var ts; } if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ || source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target, /*reportErrors*/ false)) { - if (result &= eachTypeRelatedToSomeType(target, source, /*reportErrors*/ false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -28750,7 +28910,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -29414,7 +29574,7 @@ var ts; type.flags & 64 /* NumberLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -29422,7 +29582,7 @@ var ts; type.flags & 64 /* NumberLiteral */ && type.flags & 16777216 /* FreshLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } /** @@ -29549,10 +29709,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -29604,25 +29764,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142 /* Parameter */: + case 143 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169 /* BindingElement */: + case 170 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -29668,7 +29828,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -29676,7 +29836,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } // Return true if the given type could possibly reference a type parameter for which @@ -29957,7 +30117,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; // Infer widened union or supertype, or the unknown type for no common supertype var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, /*subtypeReduction*/ true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; @@ -30011,10 +30171,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return true; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: node = node.parent; continue; default: @@ -30028,14 +30188,14 @@ var ts; // leftmost identifier followed by zero or more property names separated by dots. // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97 /* ThisKeyword */) { + if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 173 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30043,31 +30203,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69 /* Identifier */: - return target.kind === 69 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 /* VariableDeclaration */ || target.kind === 169 /* BindingElement */) && + case 70 /* Identifier */: + return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 /* VariableDeclaration */ || target.kind === 170 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97 /* ThisKeyword */: - return target.kind === 97 /* ThisKeyword */; - case 172 /* PropertyAccessExpression */: - return target.kind === 172 /* PropertyAccessExpression */ && + case 98 /* ThisKeyword */: + return target.kind === 98 /* ThisKeyword */; + case 173 /* PropertyAccessExpression */: + return target.kind === 173 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172 /* PropertyAccessExpression */) { + while (source.kind === 173 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30080,15 +30240,15 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 /* PropertyAccessExpression */ && + return target.kind === 173 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69 /* Identifier */) { + if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -30118,7 +30278,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30249,7 +30409,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? + return node.parent.kind === 171 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -30268,17 +30428,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return stringType; - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return undefinedType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return getAssignedTypeOfSpreadElement(parent); case 253 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); @@ -30290,7 +30450,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 /* ObjectBindingPattern */ ? + var type = pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -30308,38 +30468,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207 /* ForInStatement */) { + if (node.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.parent.kind === 209 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 /* VariableDeclaration */ ? + return node.kind === 219 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */ ? + return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 /* VariableDeclaration */ && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return getReferenceCandidate(node.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 /* ParenthesizedExpression */ || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -30415,24 +30588,105 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + // An evolving array type tracks the element types that have so far been seen in an + // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving + // array types are ultimately converted into manifest array types (using getFinalArrayType) + // and never escape the getFlowTypeOfReference function. + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152 /* Anonymous */); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + // When adding evolving array element types we do not perform subtype reduction. Instead, + // we defer subtype reduction until the evolving array type is finalized into a manifest + // array type. + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 /* Anonymous */ && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 /* Never */ ? + autoArrayType : + createArrayType(elementType.flags & 524288 /* Union */ ? + getUnionType(elementType.types, /*subtypeReduction*/ true) : + elementType); + } + // We perform subtype reduction upon obtaining the final array type from an evolving array type. + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192 /* Never */)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + // At flow control branch or loop junctions, if the type along every antecedent code path + // is an evolving array type, we construct a combined evolving array type. Otherwise we + // finalize all evolving array types. + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + // Return true if the given node is 'x' in an 'x.length', x.push(value)', 'x.unshift(value)' or + // 'x[n] = value' operation, where 'n' is an expression of type any, undefined, or a number-like type. + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 175 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 /* ElementAccessExpression */ && + parent.expression === root && + parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 57 /* EqualsToken */ && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 /* NonNullExpression */ && getTypeWithFacts(result, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, + // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations + // on empty arrays are possible without implicit any errors and new element types can be inferred without + // type mismatch errors. + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -30465,10 +30719,17 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256 /* ArrayMutation */) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 173 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30477,10 +30738,10 @@ var ts; } else { // Unreachable code errors are reported in the binding phase. Here we - // simply return the declared type to reduce follow-on errors. - type = declaredType; + // simply return the non-auto declared type to reduce follow-on errors. + type = convertAutoToAny(declaredType); } - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // Record visited node and the associated type in the cache. visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; @@ -30494,13 +30755,21 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */) { + if (node.parent.kind === 186 /* PrefixUnaryExpression */ || node.parent.kind === 187 /* PostfixUnaryExpression */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 /* Union */ ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288 /* Union */) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } // We didn't have a direct match. However, if the reference is a dotted name, this // may be an assignment to a left hand part of the reference. For example, for a @@ -30512,24 +30781,56 @@ var ts; // Assignment doesn't affect reference return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 /* CallExpression */ ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175 /* CallExpression */) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */ | 2048 /* Undefined */)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192 /* Never */)) { - // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the never type, and if - // the antecedent type is incomplete (i.e. a transient type in a loop), then we - // take the type guard as an indication that control *could* reach here once we - // have the complete type. We proceed by switching to the silent never type which - // doesn't report errors when operators are applied to it. Note that this is the - // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 /* Never */ && isIncomplete(flowType)) { - type = silentNeverType; - } - } - return createFlowType(type, isIncomplete(flowType)); + if (type.flags & 8192 /* Never */) { + return flowType; + } + // If we have an antecedent type (meaning we're reachable in some way), we first + // attempt to narrow the antecedent type. If that produces the never type, and if + // the antecedent type is incomplete (i.e. a transient type in a loop), then we + // take the type guard as an indication that control *could* reach here once we + // have the complete type. We proceed by switching to the silent never type which + // doesn't report errors when operators are applied to it. Note that this is the + // *only* place a silent never type is ever generated. + var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 /* Never */ ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -30571,7 +30872,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -30586,11 +30887,15 @@ var ts; } // 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. - // We should never see an empty array here because the first antecedent of a loop - // junction is always the non-looping control flow path that leads to the top. + // It is possible to see an empty array in cases where loops are nested and the + // back edge of the outer loop reaches an inner loop that is already being analyzed. + // In such cases we restart the analysis of the inner loop, which will then see + // a non-empty in-process array for the outer loop and eventually terminate because + // the first antecedent of a loop junction is always the non-looping control flow + // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], /*subtypeReduction*/ false), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -30634,14 +30939,14 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 /* PropertyAccessExpression */ && + return expr.kind === 173 /* PropertyAccessExpression */ && declaredType.flags & 524288 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -30666,19 +30971,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 183 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 183 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -30697,9 +31002,9 @@ var ts; return declaredType; } break; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -30708,7 +31013,7 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -30716,10 +31021,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 /* EqualsEqualsToken */ || operator === 31 /* ExclamationEqualsToken */; + var doubleEquals = operator === 31 /* EqualsEqualsToken */ || operator === 32 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - value.kind === 93 /* NullKeyword */ ? + value.kind === 94 /* NullKeyword */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); @@ -30748,7 +31053,7 @@ var ts; } return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288 /* Union */)) { @@ -30877,7 +31182,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 /* ElementAccessExpression */ || invokedExpression.kind === 172 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 174 /* ElementAccessExpression */ || invokedExpression.kind === 173 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -30894,18 +31199,18 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185 /* PrefixUnaryExpression */: - if (expr.operator === 49 /* ExclamationToken */) { + case 186 /* PrefixUnaryExpression */: + if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -30918,7 +31223,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 69 /* Identifier */) { + if (location.kind === 70 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -30937,7 +31242,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178 /* ParenthesizedExpression */) { + while (expression.kind === 179 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -30946,9 +31251,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 /* ModuleBlock */ || + node.kind === 227 /* ModuleBlock */ || node.kind === 256 /* SourceFile */ || - node.kind === 145 /* PropertyDeclaration */) { + node.kind === 146 /* PropertyDeclaration */) { return node; } } @@ -30977,10 +31282,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143 /* Parameter */) { symbol.isAssigned = true; } } @@ -30989,6 +31294,9 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. @@ -30999,8 +31307,8 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES6 */) { - if (container.kind === 180 /* ArrowFunction */) { + if (languageVersion < 2 /* ES2015 */) { + if (container.kind === 181 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -31020,8 +31328,8 @@ 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 (languageVersion === 2 /* ES6 */ - && declaration_1.kind === 221 /* ClassDeclaration */ + if (languageVersion === 2 /* ES2015 */ + && declaration_1.kind === 222 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31033,14 +31341,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192 /* ClassExpression */) { + else if (declaration_1.kind === 193 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 146 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -31063,37 +31371,35 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 142 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 143 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 /* FunctionExpression */ || - flowContainer.kind === 180 /* ArrowFunction */ || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 /* FunctionExpression */ || + flowContainer.kind === 181 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // 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 && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || 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 // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { @@ -31114,7 +31420,7 @@ var ts; return false; } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES6 */ || + if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || symbol.valueDeclaration.parent.kind === 252 /* CatchClause */) { return; @@ -31141,8 +31447,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 === 206 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 219 /* VariableDeclarationList */).parent === container && + if (container.kind === 207 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 220 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31156,7 +31462,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 178 /* ParenthesizedExpression */) { + while (current.parent.kind === 179 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31164,9 +31470,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 /* PrefixUnaryExpression */ || current.parent.kind === 186 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 186 /* PrefixUnaryExpression */ || current.parent.kind === 187 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 41 /* PlusPlusToken */ || expr.operator === 42 /* MinusMinusToken */; + isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -31185,7 +31491,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 145 /* PropertyDeclaration */ || container.kind === 148 /* Constructor */) { + if (container.kind === 146 /* PropertyDeclaration */ || container.kind === 149 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -31233,7 +31539,7 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 148 /* Constructor */) { + if (container.kind === 149 /* Constructor */) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); // If a containing class does not have extends clause or the class extends null @@ -31254,32 +31560,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 180 /* ArrowFunction */) { + if (container.kind === 181 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code - needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); + needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* 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 224 /* EnumDeclaration */: + case 225 /* 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; - case 148 /* Constructor */: + case 149 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -31291,7 +31597,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 179 /* FunctionExpression */ && + if (container.kind === 180 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31304,7 +31610,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -31337,21 +31643,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142 /* Parameter */) { + if (n.kind === 143 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 180 /* ArrowFunction */) { + while (container && container.kind === 181 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -31363,16 +31669,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 140 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 141 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 140 /* ComputedPropertyName */) { + if (current && current.kind === 141 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31443,7 +31749,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 147 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 148 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -31457,8 +31763,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES6 */) { + if (container.parent.kind === 172 /* ObjectLiteralExpression */) { + if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; } @@ -31477,7 +31783,7 @@ var ts; } return unknownType; } - if (container.kind === 148 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; @@ -31492,7 +31798,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 148 /* Constructor */; + return container.kind === 149 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -31500,32 +31806,35 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */; } else { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */ || - container.kind === 145 /* PropertyDeclaration */ || - container.kind === 144 /* PropertySignature */ || - container.kind === 148 /* Constructor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */ || + container.kind === 146 /* PropertyDeclaration */ || + container.kind === 145 /* PropertySignature */ || + container.kind === 149 /* Constructor */; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180 /* ArrowFunction */) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -31585,7 +31894,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -31637,7 +31946,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 143 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -31648,8 +31957,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 148 /* Constructor */ || - functionDecl.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150 /* SetAccessor */))) { + functionDecl.kind === 149 /* Constructor */ || + functionDecl.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -31671,7 +31980,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176 /* TaggedTemplateExpression */) { + if (template.parent.kind === 177 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -31679,7 +31988,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // Don't do this for special property assignments to avoid circularity if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0 /* None */) { return undefined; @@ -31689,7 +31998,7 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52 /* BarBarToken */) { + else if (operator === 53 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -31698,7 +32007,7 @@ var ts; } return type; } - else if (operator === 51 /* AmpersandAmpersandToken */ || operator === 24 /* CommaToken */) { + else if (operator === 52 /* AmpersandAmpersandToken */ || operator === 25 /* CommaToken */) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -31715,8 +32024,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -31786,7 +32095,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -31843,36 +32152,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 170 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 180 /* ArrowFunction */: - case 211 /* ReturnStatement */: + case 181 /* ArrowFunction */: + case 212 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 197 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 189 /* TemplateExpression */); + case 198 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getContextualType(parent); case 248 /* JsxExpression */: return getContextualType(parent); @@ -31894,7 +32203,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -31913,7 +32222,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -31923,8 +32232,8 @@ var ts; } var signatureList; var types = type.types; - 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 signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -31980,8 +32289,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 169 /* BindingElement */ && !!node.initializer) || - (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 170 /* BindingElement */ && !!node.initializer) || + (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -31990,7 +32299,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 192 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32005,7 +32314,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -32014,7 +32323,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32029,7 +32338,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 168 /* ArrayBindingPattern */ || pattern.kind === 170 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 169 /* ArrayBindingPattern */ || pattern.kind === 171 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32037,7 +32346,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193 /* OmittedExpression */) { + if (patternElement.kind !== 194 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32054,7 +32363,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -32124,7 +32433,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 /* ObjectBindingPattern */ || contextualType.pattern.kind === 171 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 168 /* ObjectBindingPattern */ || contextualType.pattern.kind === 172 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32139,7 +32448,7 @@ var ts; if (memberDecl.kind === 253 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147 /* MethodDeclaration */) { + else if (memberDecl.kind === 148 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -32187,7 +32496,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 149 /* GetAccessor */ || memberDecl.kind === 150 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 150 /* GetAccessor */ || memberDecl.kind === 151 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -32251,10 +32560,10 @@ var ts; case 248 /* JsxExpression */: checkJsxExpression(child); break; - case 241 /* JsxElement */: + case 242 /* JsxElement */: checkJsxElement(child); break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32273,7 +32582,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 172 /* PropertyAccessExpression */ || tagName.kind === 97 /* ThisKeyword */) { + if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32400,7 +32709,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), /*subtypeReduction*/ true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -32444,7 +32753,7 @@ var ts; } if (elemType.flags & 524288 /* Union */) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), /*subtypeReduction*/ true); } @@ -32654,7 +32963,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 146 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; @@ -32673,10 +32982,10 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 /* PropertyAccessExpression */ || node.kind === 218 /* VariableDeclaration */ ? + var errorNode = node.kind === 173 /* PropertyAccessExpression */ || node.kind === 219 /* VariableDeclaration */ ? node.name : node.right; - if (left.kind === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or // instance member variable initializer where this references a derived class instance, @@ -32684,7 +32993,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 147 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 148 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -32715,7 +33024,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { return true; } // Get the enclosing class that has the declaring class as its base type @@ -32799,7 +33108,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 172 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || + if (node.kind !== 173 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 524288 /* Union */)) { return propType; @@ -32821,7 +33130,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 /* PropertyAccessExpression */ + var left = node.kind === 173 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -32838,13 +33147,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219 /* VariableDeclarationList */) { + if (initializer.kind === 220 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69 /* Identifier */) { + else if (initializer.kind === 70 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -32861,13 +33170,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 /* ForInStatement */ && + if (node.kind === 208 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -32884,7 +33193,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 176 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -32970,7 +33279,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 /* ElementAccessExpression */ || indexArgumentExpression.kind === 172 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 174 /* ElementAccessExpression */ || indexArgumentExpression.kind === 173 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -33025,10 +33334,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 143 /* Decorator */) { + else if (node.kind !== 144 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33094,7 +33403,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191 /* SpreadElementExpression */) { + if (arg && arg.kind === 192 /* SpreadElementExpression */) { return i; } } @@ -33107,13 +33416,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189 /* TemplateExpression */) { + if (tagExpression.template.kind === 190 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -33126,11 +33435,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 12 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -33139,7 +33448,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 175 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 176 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33223,9 +33532,9 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33280,7 +33589,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 176 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -33297,10 +33606,10 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33319,12 +33628,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 174 /* CallExpression */) { + if (node.kind === 175 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 172 /* PropertyAccessExpression */) { + if (callee.kind === 173 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 173 /* ElementAccessExpression */) { + else if (callee.kind === 174 /* ElementAccessExpression */) { return callee.expression; } } @@ -33340,16 +33649,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -33374,19 +33683,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If we are emitting decorators for ES3, we will only pass two arguments. @@ -33396,7 +33705,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 142 /* Parameter */: + case 143 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -33420,25 +33729,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* 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); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -33465,32 +33774,32 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -33516,21 +33825,21 @@ 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 === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 145 /* PropertyDeclaration */) { + if (node.kind === 146 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -33558,14 +33867,14 @@ var ts; /** * Gets the effective argument type for an argument in a call expression. */ - function getEffectiveArgumentType(node, argIndex, arg) { + function getEffectiveArgumentType(node, argIndex) { // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -33577,8 +33886,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 143 /* Decorator */ || - (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */)) { + if (node.kind === 144 /* Decorator */ || + (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -33587,11 +33896,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -33600,13 +33909,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 143 /* Decorator */; + var isTaggedTemplate = node.kind === 177 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 144 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 95 /* SuperKeyword */) { + if (node.expression.kind !== 96 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -33672,7 +33981,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -33818,7 +34127,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -34020,16 +34329,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -34059,13 +34368,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143 /* Decorator */: + case 144 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34111,22 +34420,22 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 175 /* NewExpression */) { + if (node.kind === 176 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 /* Constructor */ && - declaration.kind !== 152 /* ConstructSignature */ && - declaration.kind !== 157 /* ConstructorType */ && + declaration.kind !== 149 /* Constructor */ && + declaration.kind !== 153 /* ConstructSignature */ && + declaration.kind !== 158 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations // in a JS file // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - var funcSymbol = node.expression.kind === 69 /* Identifier */ ? + var funcSymbol = node.expression.kind === 70 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -34139,7 +34448,10 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && + // Make sure require is not a local function + !resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -34179,21 +34491,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push @@ -34203,7 +34530,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69 /* Identifier */) { + if (element.name.kind === 70 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -34217,8 +34544,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 168 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 168 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 169 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34288,7 +34615,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199 /* Block */) { + if (func.body.kind !== 200 /* 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 @@ -34378,7 +34705,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -34411,7 +34738,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */)) { + func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -34440,7 +34767,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 !== 199 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -34473,10 +34800,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 180 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -34517,14 +34844,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 148 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -34540,7 +34867,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199 /* Block */) { + if (node.body.kind === 200 /* Block */) { checkSourceElement(node.body); } else { @@ -34587,11 +34914,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) && - expr.expression.kind === 97 /* ThisKeyword */) { + (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) && + expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148 /* Constructor */)) + if (!(func && func.kind === 149 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -34603,13 +34930,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232 /* NamespaceImport */; + return declaration && declaration.kind === 233 /* NamespaceImport */; } } } @@ -34618,7 +34945,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 /* Identifier */ && node.kind !== 172 /* PropertyAccessExpression */ && node.kind !== 173 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 173 /* PropertyAccessExpression */ && node.kind !== 174 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -34631,7 +34958,7 @@ var ts; if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { // Only variables (and not functions, classes, namespaces, enum objects, or enum members) // are considered references when referenced using a simple identifier. - if (node.kind === 69 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { + if (node.kind === 70 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { error(expr, invalidReferenceMessage); return false; } @@ -34641,7 +34968,7 @@ var ts; } } } - else if (node.kind === 173 /* ElementAccessExpression */) { + else if (node.kind === 174 /* ElementAccessExpression */) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -34679,24 +35006,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 37 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, "" + -node.operand.text)); } switch (node.operator) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); return facts === 1048576 /* Truthy */ ? falseType : facts === 2097152 /* Falsy */ ? trueType : booleanType; - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.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 @@ -34726,8 +35053,8 @@ var ts; } if (type.flags & 1572864 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -34744,8 +35071,8 @@ var ts; } if (type.flags & 524288 /* Union */) { 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 (!isTypeOfKind(t, kind)) { return false; } @@ -34754,8 +35081,8 @@ var ts; } if (type.flags & 1048576 /* Intersection */) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -34803,18 +35130,18 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 /* PropertyAssignment */ || property.kind === 254 /* ShorthandPropertyAssignment */) { var name_17 = property.name; - if (name_17.kind === 140 /* ComputedPropertyName */) { + if (name_17.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(name_17); } if (isComputedNonLiteralName(name_17)) { @@ -34857,8 +35184,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193 /* OmittedExpression */) { - if (element.kind !== 191 /* SpreadElementExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { + if (element.kind !== 192 /* SpreadElementExpression */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -34886,7 +35213,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 188 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -34915,14 +35242,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171 /* ObjectLiteralExpression */) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170 /* ArrayLiteralExpression */) { + if (target.kind === 171 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -34945,52 +35272,52 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 176 /* TaggedTemplateExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 177 /* TaggedTemplateExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 182 /* TypeOfExpression */: - case 196 /* NonNullExpression */: - case 242 /* JsxSelfClosingElement */: - case 241 /* JsxElement */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 183 /* TypeOfExpression */: + case 197 /* NonNullExpression */: + case 243 /* JsxSelfClosingElement */: + case 242 /* JsxElement */: return true; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 49 /* ExclamationToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 183 /* VoidExpression */: // Explicit opt-out - case 177 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 195 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 184 /* VoidExpression */: // Explicit opt-out + case 178 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 196 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35010,34 +35337,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 171 /* ObjectLiteralExpression */ || left.kind === 170 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 172 /* ObjectLiteralExpression */ || left.kind === 171 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37 /* AsteriskToken */: - case 38 /* AsteriskAsteriskToken */: - case 59 /* AsteriskEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - case 40 /* PercentToken */: - case 62 /* PercentEqualsToken */: - case 36 /* MinusToken */: - case 58 /* MinusEqualsToken */: - case 43 /* LessThanLessThanToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* BarToken */: - case 67 /* BarEqualsToken */: - case 48 /* CaretToken */: - case 68 /* CaretEqualsToken */: - case 46 /* AmpersandToken */: - case 66 /* AmpersandEqualsToken */: + case 38 /* AsteriskToken */: + case 39 /* AsteriskAsteriskToken */: + case 60 /* AsteriskEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 41 /* PercentToken */: + case 63 /* PercentEqualsToken */: + case 37 /* MinusToken */: + case 59 /* MinusEqualsToken */: + case 44 /* LessThanLessThanToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35070,8 +35397,8 @@ var ts; } } return numberType; - case 35 /* PlusToken */: - case 57 /* PlusEqualsToken */: + case 36 /* PlusToken */: + case 58 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35110,24 +35437,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57 /* PlusEqualsToken */) { + if (operator === 58 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -35138,22 +35465,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90 /* InKeyword */: + case 91 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 1048576 /* Truthy */ ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return getTypeFacts(leftType) & 2097152 /* Falsy */ ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24 /* CommaToken */: + case 25 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -35172,21 +35499,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 47 /* BarToken */: - case 67 /* BarEqualsToken */: - return 52 /* BarBarToken */; - case 48 /* CaretToken */: - case 68 /* CaretEqualsToken */: - return 33 /* ExclamationEqualsEqualsToken */; - case 46 /* AmpersandToken */: - case 66 /* AmpersandEqualsToken */: - return 51 /* AmpersandAmpersandToken */; + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + return 53 /* BarBarToken */; + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + return 34 /* ExclamationEqualsEqualsToken */; + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: + return 52 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (produceDiagnostics && operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -35273,9 +35600,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32 /* StringLiteral */, node.text)); case 8 /* NumericLiteral */: return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, node.text)); - case 99 /* TrueKeyword */: + case 100 /* TrueKeyword */: return trueType; - case 84 /* FalseKeyword */: + case 85 /* FalseKeyword */: return falseType; } } @@ -35312,7 +35639,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 /* TypeAssertionExpression */ || node.kind === 195 /* AsExpression */; + return node.kind === 178 /* TypeAssertionExpression */ || node.kind === 196 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35344,7 +35671,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -35355,7 +35682,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -35385,7 +35712,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139 /* QualifiedName */) { + if (node.kind === 140 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -35397,9 +35724,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -35408,79 +35735,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return checkIdentifier(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return checkThisExpression(node); - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return checkSuperExpression(node); - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullWideningType; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return checkTemplateExpression(node); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return stringType; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return checkCallExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return checkClassExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return checkAssertion(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return checkNonNullAssertion(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkDeleteExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return checkVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return checkAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return undefinedWideningType; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return checkYieldExpression(node); case 248 /* JsxExpression */: return checkJsxExpression(node); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return checkJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -35508,7 +35835,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -35519,7 +35846,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 /* Constructor */ || func.kind === 152 /* ConstructSignature */ || func.kind === 157 /* ConstructorType */) { + if (func.kind === 149 /* Constructor */ || func.kind === 153 /* ConstructSignature */ || func.kind === 158 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -35533,15 +35860,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 /* MethodDeclaration */ || - node.kind === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */; + return node.kind === 148 /* MethodDeclaration */ || + node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 /* Identifier */ && + if (param.name.kind === 70 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -35593,13 +35920,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 180 /* ArrowFunction */: - case 151 /* CallSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 156 /* FunctionType */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 181 /* ArrowFunction */: + case 152 /* CallSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 157 /* FunctionType */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -35613,13 +35940,13 @@ var ts; continue; } var name_19 = element.name; - if (name_19.kind === 69 /* Identifier */ && + if (name_19.kind === 70 /* Identifier */ && name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 168 /* ArrayBindingPattern */ || - name_19.kind === 167 /* ObjectBindingPattern */) { + else if (name_19.kind === 169 /* ArrayBindingPattern */ || + name_19.kind === 168 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } @@ -35628,12 +35955,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 /* FunctionType */ || node.kind === 220 /* FunctionDeclaration */ || node.kind === 157 /* ConstructorType */ || - node.kind === 151 /* CallSignature */ || node.kind === 148 /* Constructor */ || - node.kind === 152 /* ConstructSignature */) { + else if (node.kind === 157 /* FunctionType */ || node.kind === 221 /* FunctionDeclaration */ || node.kind === 158 /* ConstructorType */ || + node.kind === 152 /* CallSignature */ || node.kind === 149 /* Constructor */ || + node.kind === 153 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -35645,16 +35972,16 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 /* ES6 */ && isSyntacticallyValidGenerator(node)) { + if (languageVersion >= 2 /* ES2015 */ && isSyntacticallyValidGenerator(node)) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -35691,7 +36018,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -35700,18 +36027,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113 /* StaticKeyword */; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; } @@ -35737,12 +36064,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144 /* PropertySignature */) { + if (member.kind == 145 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: memberName = member.name.text; break; default: @@ -35759,7 +36086,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222 /* InterfaceDeclaration */) { + if (node.kind === 223 /* 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 @@ -35779,7 +36106,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -35787,7 +36114,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -35852,15 +36179,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97 /* ThisKeyword */) { + if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 /* FunctionExpression */ && n.kind !== 220 /* FunctionDeclaration */) { + else if (n.kind !== 180 /* FunctionExpression */ && n.kind !== 221 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 /* PropertyDeclaration */ && + return n.kind === 146 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -35890,7 +36217,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -35914,7 +36241,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -35924,13 +36251,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = node.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -35946,11 +36273,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 172 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36040,9 +36367,9 @@ 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 !== 222 /* InterfaceDeclaration */ && - n.parent.kind !== 221 /* ClassDeclaration */ && - n.parent.kind !== 192 /* ClassExpression */ && + if (n.parent.kind !== 223 /* InterfaceDeclaration */ && + n.parent.kind !== 222 /* ClassDeclaration */ && + n.parent.kind !== 193 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36130,7 +36457,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */) && + var reportError = (node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -36169,7 +36496,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 /* InterfaceDeclaration */ || node.parent.kind === 159 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 /* InterfaceDeclaration */ || node.parent.kind === 160 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -36180,7 +36507,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 === 220 /* FunctionDeclaration */ || node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */ || node.kind === 148 /* Constructor */) { + if (node.kind === 221 /* FunctionDeclaration */ || node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */ || node.kind === 149 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36302,16 +36629,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -36515,7 +36842,7 @@ var ts; * callable `then` signature. */ function checkAsyncFunctionReturnType(node) { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { var returnType = getTypeFromTypeNode(node.type); return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); } @@ -36594,22 +36921,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142 /* Parameter */: + case 143 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -36622,9 +36949,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 155 /* TypeReference */) { + if (node && node.kind === 156 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = root.parent.kind === 156 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; // Resolve type so we know which symbol is referenced var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); // Resolved symbol is alias @@ -36671,20 +36998,20 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } @@ -36707,7 +37034,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 141 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -36768,42 +37095,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256 /* SourceFile */: - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -36812,11 +37139,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142 /* Parameter */) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143 /* Parameter */) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -36836,19 +37163,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; + return parameter.name && parameter.name.kind === 70 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 /* MethodDeclaration */ || member.kind === 145 /* PropertyDeclaration */) { + if (member.kind === 148 /* MethodDeclaration */ || member.kind === 146 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148 /* Constructor */) { + else if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -36896,7 +37223,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 199 /* Block */) { + if (node.kind === 200 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -36919,12 +37246,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 144 /* PropertySignature */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 146 /* MethodSignature */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 145 /* PropertySignature */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 147 /* MethodSignature */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -36933,7 +37260,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -36949,7 +37276,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 69 /* Identifier */; + var isDeclaration_1 = node.kind !== 70 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -36972,7 +37299,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69 /* Identifier */; + var isDeclaration_2 = node.kind !== 70 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -36983,14 +37310,14 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37005,7 +37332,7 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37045,7 +37372,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 === 218 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 219 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37055,16 +37382,16 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 200 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 201 /* 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 === 199 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 226 /* ModuleBlock */ || - container.kind === 225 /* ModuleDeclaration */ || + (container.kind === 200 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 227 /* ModuleBlock */ || + container.kind === 226 /* ModuleDeclaration */ || container.kind === 256 /* 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 @@ -37080,7 +37407,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 143 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -37091,11 +37418,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 172 /* PropertyAccessExpression */) { + if (n.kind === 173 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 69 /* Identifier */) { + else if (n.kind === 70 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -37110,7 +37437,7 @@ 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 === 142 /* Parameter */) { + if (symbol.valueDeclaration.kind === 143 /* Parameter */) { // 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) { @@ -37124,7 +37451,7 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 145 /* PropertyDeclaration */ && + if (current.parent.kind === 146 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; @@ -37141,7 +37468,7 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { @@ -37151,15 +37478,15 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169 /* BindingElement */) { + if (node.kind === 170 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 140 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -37176,14 +37503,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 142 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // 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 !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37194,7 +37521,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 !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37214,10 +37541,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */) { + if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */) { + if (node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37227,8 +37554,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 /* Parameter */ && right.kind === 218 /* VariableDeclaration */) || - (left.kind === 218 /* VariableDeclaration */ && right.kind === 142 /* Parameter */)) { + if ((left.kind === 143 /* Parameter */ && right.kind === 219 /* VariableDeclaration */) || + (left.kind === 219 /* VariableDeclaration */ && right.kind === 143 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37258,7 +37585,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 171 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37279,7 +37606,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201 /* EmptyStatement */) { + if (node.thenStatement.kind === 202 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37299,12 +37626,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 220 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37327,14 +37654,14 @@ 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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -37366,7 +37693,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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* 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); @@ -37380,7 +37707,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */)) { @@ -37418,7 +37745,7 @@ var ts; if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { return checkElementTypeOfIterable(inputType, errorNode); } if (allowStringInput) { @@ -37578,7 +37905,7 @@ var ts; * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). */ function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2 /* ES6 */); + ts.Debug.assert(languageVersion < 2 /* ES2015 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. var arrayType = arrayOrStringType; @@ -37630,7 +37957,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150 /* SetAccessor */))); + return !!(node.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -37657,12 +37984,12 @@ var ts; // for generators. return; } - if (func.kind === 150 /* SetAccessor */) { + if (func.kind === 151 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148 /* Constructor */) { + else if (func.kind === 149 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -37683,7 +38010,7 @@ var ts; } } } - else if (func.kind !== 148 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -37749,7 +38076,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 215 /* 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; @@ -37779,7 +38106,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 70 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -37854,7 +38181,7 @@ var ts; // 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 var errorNode; - if (prop.valueDeclaration.name.kind === 140 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -37912,7 +38239,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 /* ClassDeclaration */ || declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 222 /* ClassDeclaration */ || declaration.kind === 223 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38076,7 +38403,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 192 /* ClassExpression */) { + if (derivedClassDecl.kind === 193 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38124,7 +38451,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 /* GetAccessor */ || kind === 150 /* SetAccessor */; + return kind === 150 /* GetAccessor */ || kind === 151 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -38196,7 +38523,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38302,18 +38629,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35 /* PlusToken */: return value_1; - case 36 /* MinusToken */: return -value_1; - case 50 /* TildeToken */: return ~value_1; + case 36 /* PlusToken */: return value_1; + case 37 /* MinusToken */: return -value_1; + case 51 /* TildeToken */: return ~value_1; } return undefined; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38323,31 +38650,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 47 /* BarToken */: return left | right; - case 46 /* AmpersandToken */: return left & right; - case 44 /* GreaterThanGreaterThanToken */: return left >> right; - case 45 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 43 /* LessThanLessThanToken */: return left << right; - case 48 /* CaretToken */: return left ^ right; - case 37 /* AsteriskToken */: return left * right; - case 39 /* SlashToken */: return left / right; - case 35 /* PlusToken */: return left + right; - case 36 /* MinusToken */: return left - right; - case 40 /* PercentToken */: return left % right; + case 48 /* BarToken */: return left | right; + case 47 /* AmpersandToken */: return left & right; + case 45 /* GreaterThanGreaterThanToken */: return left >> right; + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 44 /* LessThanLessThanToken */: return left << right; + case 49 /* CaretToken */: return left ^ right; + case 38 /* AsteriskToken */: return left * right; + case 40 /* SlashToken */: return left / right; + case 36 /* PlusToken */: return left + right; + case 37 /* MinusToken */: return left - right; + case 41 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 69 /* Identifier */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -38355,7 +38682,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 173 /* ElementAccessExpression */) { + if (e.kind === 174 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38370,10 +38697,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 69 /* Identifier */) { + if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 172 /* PropertyAccessExpression */) { + else if (current.kind === 173 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -38445,7 +38772,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 !== 224 /* EnumDeclaration */) { + if (declaration.kind !== 225 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -38468,8 +38795,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 === 221 /* ClassDeclaration */ || - (declaration.kind === 220 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 /* ClassDeclaration */ || + (declaration.kind === 221 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -38533,7 +38860,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, 221 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 222 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -38584,23 +38911,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* 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 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var name_22 = node.name; if (ts.isBindingPattern(name_22)) { for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { @@ -38611,12 +38938,12 @@ var ts; break; } // fallthrough - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 220 /* FunctionDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -38637,17 +38964,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; } } @@ -38657,9 +38984,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 /* ExportDeclaration */ ? + error(moduleName, node.kind === 237 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -38692,7 +39019,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 === 238 /* ExportSpecifier */ ? + var message = node.kind === 239 /* 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)); @@ -38720,7 +39047,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -38757,7 +39084,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.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); } @@ -38777,7 +39104,7 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -38792,7 +39119,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 225 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 226 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -38819,7 +39146,7 @@ var ts; return; } var container = node.parent.kind === 256 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 225 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (container.kind === 226 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -38827,7 +39154,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { markExportAsReferenced(node); } else { @@ -38835,7 +39162,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -38894,7 +39221,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 /* FunctionDeclaration */ && declaration.kind !== 147 /* MethodDeclaration */) || + return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || !!declaration.body; } } @@ -38907,118 +39234,118 @@ 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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return checkTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return checkParameter(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return checkPropertyDeclaration(node); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return checkSignatureDeclaration(node); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return checkMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return checkConstructorDeclaration(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return checkAccessorDeclaration(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return checkTypeReferenceNode(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return checkTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return checkTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return checkArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return checkTupleType(node); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return checkSourceElement(node.type); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return checkBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return checkVariableStatement(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return checkExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return checkIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return checkDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return checkWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return checkForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return checkForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkForOfStatement(node); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return checkReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return checkSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return checkLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return checkThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return checkTryStatement(node); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return checkBindingElement(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return checkClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return checkImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return checkExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return checkExportAssignment(node); - case 201 /* EmptyStatement */: + case 202 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39040,17 +39367,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkAccessorDeferred(node); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39131,7 +39458,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 213 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39158,21 +39485,21 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* 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. @@ -39181,7 +39508,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39224,34 +39551,34 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 /* Identifier */ && + return name.kind === 70 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141 /* TypeParameter */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 142 /* TypeParameter */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139 /* QualifiedName */) { + while (node.parent && node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 155 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 156 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 194 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39268,13 +39595,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 140 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 230 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39286,7 +39613,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39298,15 +39625,15 @@ var ts; default: } } - if (entityName.parent.kind === 235 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 172 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 173 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 229 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 230 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; @@ -39314,7 +39641,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 194 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 195 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39332,20 +39659,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 172 /* PropertyAccessExpression */) { + else if (entityName.kind === 173 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139 /* QualifiedName */) { + else if (entityName.kind === 140 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -39354,13 +39681,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 156 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } else if (entityName.parent.kind === 246 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154 /* TypePredicate */) { + if (entityName.parent.kind === 155 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -39381,12 +39708,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 /* BindingElement */ && - node.parent.parent.kind === 167 /* ObjectBindingPattern */ && + else if (node.parent.kind === 170 /* BindingElement */ && + node.parent.parent.kind === 168 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -39396,11 +39723,11 @@ var ts; } } switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -39409,15 +39736,15 @@ var ts; } } // fallthrough - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165 /* ThisType */: + case 166 /* ThisType */: return getTypeFromTypeNode(node).symbol; - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 149 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -39425,7 +39752,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 === 230 /* ImportDeclaration */ || node.parent.kind === 236 /* ExportDeclaration */) && + ((node.parent.kind === 231 /* ImportDeclaration */ || node.parent.kind === 237 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -39435,7 +39762,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -39514,17 +39841,17 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 /* ObjectLiteralExpression */ || expr.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 172 /* ObjectLiteralExpression */ || expr.kind === 171 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 208 /* ForOfStatement */) { + if (expr.parent.kind === 209 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 187 /* BinaryExpression */) { + if (expr.parent.kind === 188 /* BinaryExpression */) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -39535,7 +39862,7 @@ var ts; return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 171 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -39724,7 +40051,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 === 199 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 200 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -39770,18 +40097,18 @@ var ts; return true; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.expression - && node.expression.kind === 69 /* Identifier */ + && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -40043,7 +40370,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 172 /* PropertyAccessExpression */) || (node.kind === 69 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 173 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40192,7 +40519,7 @@ var ts; getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", /*arity*/ 1); }); getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", /*arity*/ 1); }); @@ -40205,6 +40532,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -40218,7 +40546,7 @@ var ts; // If we found the module, report errors if it does not have the necessary exports. if (helpersModule) { var exports = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES6 */) { + if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__extends", 107455 /* Value */); } if (requestedExternalEmitHelpers & 16384 /* HasJsxSpreadAttributes */ && compilerOptions.jsx !== 1 /* Preserve */) { @@ -40235,7 +40563,7 @@ var ts; } if (requestedExternalEmitHelpers & 8192 /* HasAsyncFunctions */) { verifyHelperSymbol(exports, "__awaiter", 107455 /* Value */); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__generator", 107455 /* Value */); } } @@ -40272,14 +40600,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */) { + else if (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -40296,28 +40624,28 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128 /* ReadonlyKeyword */) { - if (node.kind === 144 /* PropertySignature */ || node.kind === 146 /* MethodSignature */) { + if (modifier.kind !== 129 /* ReadonlyKeyword */) { + if (node.kind === 145 /* PropertySignature */ || node.kind === 147 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74 /* ConstKeyword */: - if (node.kind !== 224 /* EnumDeclaration */ && node.parent.kind === 221 /* ClassDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); + case 75 /* ConstKeyword */: + if (node.kind !== 225 /* EnumDeclaration */ && node.parent.kind === 222 /* ClassDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; - case 112 /* PublicKeyword */: - case 111 /* ProtectedKeyword */: - case 110 /* PrivateKeyword */: + case 113 /* PublicKeyword */: + case 112 /* ProtectedKeyword */: + case 111 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111 /* ProtectedKeyword */) { + if (modifier.kind === 112 /* ProtectedKeyword */) { lastProtected = modifier; } - else if (modifier.kind === 110 /* PrivateKeyword */) { + else if (modifier.kind === 111 /* PrivateKeyword */) { lastPrivate = modifier; } if (flags & 28 /* AccessibilityModifier */) { @@ -40332,11 +40660,11 @@ 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 === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 110 /* PrivateKeyword */) { + if (modifier.kind === 111 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -40345,7 +40673,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -40355,10 +40683,10 @@ 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 === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -40367,18 +40695,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 128 /* ReadonlyKeyword */: + case 129 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */ && node.kind !== 153 /* IndexSignature */ && node.kind !== 142 /* Parameter */) { + else if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */ && node.kind !== 154 /* IndexSignature */ && node.kind !== 143 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -40391,45 +40719,45 @@ 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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } 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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221 /* ClassDeclaration */) { - if (node.kind !== 147 /* MethodDeclaration */ && - node.kind !== 145 /* PropertyDeclaration */ && - node.kind !== 149 /* GetAccessor */ && - node.kind !== 150 /* SetAccessor */) { + if (node.kind !== 222 /* ClassDeclaration */) { + if (node.kind !== 148 /* MethodDeclaration */ && + node.kind !== 146 /* PropertyDeclaration */ && + node.kind !== 150 /* GetAccessor */ && + node.kind !== 151 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 222 /* 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 */) { @@ -40441,14 +40769,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 118 /* AsyncKeyword */: + case 119 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -40456,7 +40784,7 @@ var ts; break; } } - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -40471,13 +40799,13 @@ var ts; } return; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -40497,38 +40825,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 225 /* ModuleDeclaration */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 142 /* Parameter */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 226 /* ModuleDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 143 /* Parameter */: return false; default: - if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return false; } switch (node.kind) { - case 220 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 118 /* AsyncKeyword */); - case 221 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 115 /* AbstractKeyword */); - case 222 /* InterfaceDeclaration */: - case 200 /* VariableStatement */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); + case 222 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); + case 223 /* InterfaceDeclaration */: + case 201 /* VariableStatement */: + case 224 /* TypeAliasDeclaration */: return true; - case 224 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 74 /* ConstKeyword */); + case 225 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -40540,10 +40868,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -40559,7 +40887,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -40602,11 +40930,11 @@ var ts; function checkGrammarFunctionLikeDeclaration(node) { // Prevent cascading error by short-circuit var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180 /* ArrowFunction */) { + if (node.kind === 181 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -40641,7 +40969,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 132 /* StringKeyword */ && parameter.type.kind !== 130 /* NumberKeyword */) { + if (parameter.type.kind !== 133 /* StringKeyword */ && parameter.type.kind !== 131 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -40669,7 +40997,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193 /* OmittedExpression */) { + if (arg.kind === 194 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -40695,7 +41023,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -40708,7 +41036,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -40724,14 +41052,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -40742,31 +41070,31 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 140 /* ComputedPropertyName */) { + if (node.kind !== 141 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 188 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -40780,7 +41108,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (name_24.kind === 140 /* ComputedPropertyName */) { + if (name_24.kind === 141 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_24); } @@ -40793,7 +41121,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 147 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 148 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -40809,19 +41137,19 @@ var ts; var currentKind = void 0; if (prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_24.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147 /* MethodDeclaration */) { + else if (prop.kind === 148 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 149 /* GetAccessor */) { + else if (prop.kind === 150 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 150 /* SetAccessor */) { + else if (prop.kind === 151 /* SetAccessor */) { currentKind = SetAccessor; } else { @@ -40878,7 +41206,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -40893,20 +41221,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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); @@ -40930,11 +41258,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 150 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150 /* SetAccessor */) { + else if (kind === 151 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -40957,10 +41285,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -40975,8 +41303,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171 /* ObjectLiteralExpression */) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -40996,10 +41324,10 @@ 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 === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* 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 === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -41010,11 +41338,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214 /* LabeledStatement */: + case 215 /* 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 === 209 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 210 /* 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); @@ -41022,8 +41350,8 @@ var ts; return false; } break; - case 213 /* SwitchStatement */: - if (node.kind === 210 /* BreakStatement */ && !node.label) { + case 214 /* SwitchStatement */: + if (node.kind === 211 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41038,13 +41366,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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 === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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); @@ -41056,7 +41384,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 168 /* ArrayBindingPattern */ || node.name.kind === 167 /* ObjectBindingPattern */) { + if (node.name.kind === 169 /* ArrayBindingPattern */ || node.name.kind === 168 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -41067,11 +41395,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 /* ForInStatement */ && node.parent.parent.kind !== 208 /* ForOfStatement */) { + if (node.parent.parent.kind !== 208 /* ForInStatement */ && node.parent.parent.kind !== 209 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41110,8 +41438,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69 /* Identifier */) { - if (name.originalKeywordKind === 108 /* LetKeyword */) { + if (name.kind === 70 /* Identifier */) { + if (name.originalKeywordKind === 109 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -41136,15 +41464,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return false; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41199,7 +41527,7 @@ var ts; return true; } } - else if (node.parent.kind === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41207,7 +41535,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41232,13 +41560,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 222 /* InterfaceDeclaration */ || - node.kind === 223 /* TypeAliasDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 236 /* ExportDeclaration */ || - node.kind === 235 /* ExportAssignment */ || - node.kind === 228 /* NamespaceExportDeclaration */ || + if (node.kind === 223 /* InterfaceDeclaration */ || + node.kind === 224 /* TypeAliasDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 237 /* ExportDeclaration */ || + node.kind === 236 /* ExportAssignment */ || + node.kind === 229 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41247,7 +41575,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 === 200 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 201 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41273,7 +41601,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 === 199 /* Block */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 200 /* Block */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41333,46 +41661,46 @@ var ts; * significantly impacted. */ var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139 /* QualifiedName */] = [ + _a[140 /* QualifiedName */] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143 /* Decorator */] = [ + _a[144 /* Decorator */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177 /* TypeAssertionExpression */] = [ + _a[178 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195 /* AsExpression */] = [ + _a[196 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196 /* NonNullExpression */] = [ + _a[197 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224 /* EnumDeclaration */] = [ + _a[225 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225 /* ModuleDeclaration */] = [ + _a[226 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226 /* ModuleBlock */] = [ + _a[227 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[229 /* ImportEqualsDeclaration */] = [ + _a[230 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240 /* ExternalModuleReference */] = [ + _a[241 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255 /* EnumMember */] = [ @@ -41398,47 +41726,47 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: case 287 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: result = reduceNode(node.expression, f, result); break; // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 143 /* Decorator */: + case 144 /* Decorator */: result = reduceNode(node.expression, f, result); break; // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41447,12 +41775,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148 /* Constructor */: + case 149 /* Constructor */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41460,7 +41788,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41468,45 +41796,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 169 /* BindingElement */: + case 170 /* BindingElement */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 175 /* NewExpression */: + case 176 /* NewExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -41514,119 +41842,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178 /* ParenthesizedExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 184 /* AwaitExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: - case 196 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 185 /* AwaitExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: + case 197 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 199 /* Block */: + case 200 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 205 /* WhileStatement */: - case 212 /* WithStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41635,7 +41963,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41643,50 +41971,50 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -41841,163 +42169,163 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return node; } switch (node.kind) { - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 148 /* Constructor */: + case 149 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 179 /* FunctionExpression */: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); + case 181 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, /*optional*/ true), context.endLexicalEnvironment())); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return ts.updateClassExpression(node, 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 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 199 /* Block */: + case 200 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* IfStatement */: + case 204 /* 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 204 /* DoStatement */: + case 205 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 206 /* ForStatement */: + case 207 /* 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 207 /* ForInStatement */: + case 208 /* 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 208 /* ForOfStatement */: + case 209 /* 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 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216 /* TryStatement */: + case 217 /* 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 218 /* VariableDeclaration */: + case 219 /* 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 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 220 /* FunctionDeclaration */: + case 221 /* 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 221 /* ClassDeclaration */: + case 222 /* 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 227 /* CaseBlock */: + case 228 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230 /* ImportDeclaration */: + case 231 /* 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 231 /* ImportClause */: + case 232 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* ExportDeclaration */: + case 237 /* 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 237 /* NamedExports */: + case 238 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -42142,67 +42470,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) { + if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 170 /* ArrayLiteralExpression */: - return 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - case 225 /* ModuleDeclaration */: - return 546335573 /* ModuleExcludes */; - case 142 /* Parameter */: - return 538968917 /* ParameterExcludes */; - case 180 /* ArrowFunction */: - return 550710101 /* ArrowFunctionExcludes */; - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - return 550726485 /* FunctionExcludes */; - case 219 /* VariableDeclarationList */: - return 538968917 /* VariableDeclarationListExcludes */; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - return 537590613 /* ClassExcludes */; - case 148 /* Constructor */: - return 550593365 /* ConstructorExcludes */; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return 550593365 /* MethodOrAccessorExcludes */; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 171 /* ArrayLiteralExpression */: + return 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + case 226 /* ModuleDeclaration */: + return 574729557 /* ModuleExcludes */; + case 143 /* Parameter */: + return 545262933 /* ParameterExcludes */; + case 181 /* ArrowFunction */: + return 592227669 /* ArrowFunctionExcludes */; + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + return 592293205 /* FunctionExcludes */; + case 220 /* VariableDeclarationList */: + return 545262933 /* VariableDeclarationListExcludes */; + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + return 539749717 /* ClassExcludes */; + case 149 /* Constructor */: + return 591760725 /* ConstructorExcludes */; + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return 591760725 /* MethodOrAccessorExcludes */; + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 171 /* ObjectLiteralExpression */: - return 537430869 /* ObjectLiteralExcludes */; + case 172 /* ObjectLiteralExpression */: + return 539110741 /* ObjectLiteralExcludes */; default: - return 536871765 /* NodeExcludes */; + return 536874325 /* NodeExcludes */; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1 /* Normal */) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -42264,7 +42592,7 @@ var ts; // location should point to the right-hand value of the expression. location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -42293,9 +42621,9 @@ var ts; * @param value The rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); @@ -42319,10 +42647,10 @@ var ts; * @param value An optional rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -42364,9 +42692,9 @@ var ts; * @param nameSubstitution An optional callback used to substitute binding names. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -42390,7 +42718,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -42412,7 +42740,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56 /* EqualsToken */) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57 /* EqualsToken */) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -42422,10 +42750,10 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171 /* ObjectLiteralExpression */) { + if (target.kind === 172 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170 /* ArrayLiteralExpression */) { + else if (target.kind === 171 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, location); } else { @@ -42464,9 +42792,9 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193 /* OmittedExpression */) { + if (e.kind !== 194 /* OmittedExpression */) { // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 191 /* SpreadElementExpression */) { + if (e.kind !== 192 /* SpreadElementExpression */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -42502,7 +42830,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167 /* ObjectBindingPattern */) { + else if (name.kind === 168 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); @@ -42524,7 +42852,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53 /* QuestionToken */), defaultValue, ts.createToken(54 /* ColonToken */), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54 /* QuestionToken */), defaultValue, ts.createToken(55 /* ColonToken */), value); } /** * Creates either a PropertyAccessExpression or an ElementAccessExpression for the @@ -42594,8 +42922,6 @@ var ts; TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; /** Enables substitutions for namespace exports. */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; - /** Enables substitutions for async methods with `super` calls. */ - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["AsyncMethodsWithSuper"] = 4] = "AsyncMethodsWithSuper"; /* Enables substitutions for unqualified enum members */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); @@ -42612,8 +42938,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -42636,11 +42962,6 @@ var ts; * just-in-time substitution while printing an expression identifier. */ var applicableSubstitutions; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - var currentSuperContainer; return transformSourceFile; /** * Transform TypeScript-specific syntax in a SourceFile. @@ -42699,6 +43020,33 @@ var ts; } return node; } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } /** * Specialized visitor that visits the immediate children of a namespace. * @@ -42713,11 +43061,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 236 /* ExportDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 231 /* ImportClause */ || - (node.kind === 229 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 240 /* ExternalModuleReference */)) { + if (node.kind === 237 /* ExportDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 232 /* ImportClause */ || + (node.kind === 230 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 241 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -42747,19 +43095,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 145 /* PropertyDeclaration */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + case 146 /* PropertyDeclaration */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 198 /* SemicolonClassElement */: + case 199 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -42778,57 +43126,55 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82 /* ExportKeyword */: - case 77 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 122 /* DeclareKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 129 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 159 /* TypeLiteral */: - case 154 /* TypePredicate */: - case 141 /* TypeParameter */: - case 117 /* AnyKeyword */: - case 120 /* BooleanKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 103 /* VoidKeyword */: - case 133 /* SymbolKeyword */: - case 157 /* ConstructorType */: - case 156 /* FunctionType */: - case 158 /* TypeQuery */: - case 155 /* TypeReference */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 160 /* TypeLiteral */: + case 155 /* TypePredicate */: + case 142 /* TypeParameter */: + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 104 /* VoidKeyword */: + case 134 /* SymbolKeyword */: + case 158 /* ConstructorType */: + case 157 /* FunctionType */: + case 159 /* TypeQuery */: + case 156 /* TypeReference */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // TypeScript type nodes are elided. - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: // TypeScript index signatures are elided. - case 143 /* Decorator */: + case 144 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // TypeScript property declarations are elided. - case 148 /* Constructor */: - // TypeScript constructors are transformed in `visitClassDeclaration`. - return undefined; - case 222 /* InterfaceDeclaration */: + case 149 /* Constructor */: + return visitConstructor(node); + case 223 /* 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 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42838,9 +43184,8 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassDeclaration(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42850,7 +43195,6 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassExpression(node); case 251 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. @@ -42858,29 +43202,29 @@ var ts; // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 147 /* MethodDeclaration */: - // TypeScript method declarations may be 'async', and may have decorators, modifiers + case 148 /* MethodDeclaration */: + // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 150 /* SetAccessor */: - // Set Accessors can have TypeScript modifiers, decorators, and type annotations. + case 151 /* SetAccessor */: + // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 220 /* FunctionDeclaration */: - // TypeScript function declarations may be 'async' + case 221 /* FunctionDeclaration */: + // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: - // TypeScript function expressions may be 'async' + case 180 /* FunctionExpression */: + // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 180 /* ArrowFunction */: - // TypeScript arrow functions may be 'async' + case 181 /* ArrowFunction */: + // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 142 /* Parameter */: + case 143 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -42890,30 +43234,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 196 /* NonNullExpression */: + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 197 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 184 /* AwaitExpression */: - // TypeScript 'await' expressions must be transformed. - return visitAwaitExpression(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 225 /* ModuleDeclaration */: + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 226 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -42929,14 +43276,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: - case 226 /* ModuleBlock */: - case 199 /* Block */: + case 228 /* CaseBlock */: + case 227 /* ModuleBlock */: + case 200 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 221 /* ClassDeclaration */: - case 220 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -42967,14 +43314,14 @@ var ts; externalHelpersModuleImport.flags &= ~8 /* Synthesized */; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 /* EmitEmitHelpers */ | ts.getEmitFlags(node)); return node; @@ -43048,7 +43395,7 @@ var ts; // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); } // Write any decorators of the node. addClassElementDecorationStatements(statements, node, /*isStatic*/ false); @@ -43224,7 +43571,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); var classExpression = ts.setOriginalNode(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members, @@ -43241,7 +43588,7 @@ var ts; // the body of a class with static initializers. ts.setEmitFlags(classExpression, 524288 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -43273,7 +43620,7 @@ var ts; // If there is a property assignment, we need to emit constructor whether users define it or not // If there is no property assignment, we can omit constructor if users do not define it var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072 /* ContainsParameterPropertyAssignments */; + var hasParameterPropertyAssignments = node.transformFlags & 524288 /* ContainsParameterPropertyAssignments */; var constructor = ts.getFirstConstructorWithBody(node); // If the class does not contain nodes that require a synthesized constructor, // accept the current constructor if it exists. @@ -43281,7 +43628,7 @@ var ts; return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); // constructor(${parameters}) { // ${body} // } @@ -43324,9 +43671,8 @@ var ts; * @param node The current class. * @param constructor The current class constructor. * @param hasExtendsClause A value indicating whether the class has an extends clause. - * @param parameters The transformed parameters for the constructor. */ - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; // The body of a constructor is a new lexical environment @@ -43367,7 +43713,7 @@ var ts; // } // var properties = getInitializedProperties(node, /*isStatic*/ false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { // The class already had a constructor, so we should add the existing statements, skipping the initial super call. ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -43394,7 +43740,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -43467,21 +43813,20 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 145 /* PropertyDeclaration */ + return member.kind === 146 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } /** * Generates assignment statements for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -43490,15 +43835,14 @@ var ts; /** * Generates assignment expressions for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -43509,11 +43853,10 @@ var ts; /** * Transforms a property initializer into an assignment statement. * - * @param node The class containing the property. * @param property The property declaration. * @param receiver The object receiving the property assignment. */ - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); @@ -43605,12 +43948,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -43762,7 +44105,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 145 /* PropertyDeclaration */ + ? member.kind === 146 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -43895,10 +44238,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 145 /* PropertyDeclaration */; + return kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -43908,7 +44251,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -43919,11 +44262,11 @@ var ts; */ function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; + return kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -43932,15 +44275,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: - case 149 /* GetAccessor */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: + case 150 /* GetAccessor */: return serializeTypeNode(node.type); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 148 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -43953,10 +44296,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 160 /* ArrayType */) { + if (node && node.kind === 161 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 155 /* TypeReference */) { + else if (node && node.kind === 156 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -44030,45 +44373,45 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return ts.createVoidZero(); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return ts.createIdentifier("Function"); - case 160 /* ArrayType */: - case 161 /* TupleType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: return ts.createIdentifier("Array"); - case 154 /* TypePredicate */: - case 120 /* BooleanKeyword */: + case 155 /* TypePredicate */: + case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return ts.createIdentifier("String"); - case 166 /* LiteralType */: + case 167 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 133 /* SymbolKeyword */: - return languageVersion < 2 /* ES6 */ + case 134 /* SymbolKeyword */: + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return serializeTypeReferenceNode(node); - case 163 /* IntersectionType */: - case 162 /* UnionType */: + case 164 /* IntersectionType */: + case 163 /* UnionType */: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -44076,7 +44419,7 @@ var ts; var typeNode = _a[_i]; var serializedIndividual = serializeTypeNode(typeNode); // Non identifier - if (serializedIndividual.kind !== 69 /* Identifier */) { + if (serializedIndividual.kind !== 70 /* Identifier */) { serializedUnion = undefined; break; } @@ -44097,10 +44440,10 @@ var ts; } } // Fallthrough - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 117 /* AnyKeyword */: - case 165 /* ThisType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 118 /* AnyKeyword */: + case 166 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44133,7 +44476,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES6 */ + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -44154,7 +44497,7 @@ var ts; */ function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name_27 = ts.getMutableClone(node); @@ -44165,7 +44508,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } return name_27; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -44178,7 +44521,7 @@ var ts; */ function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69 /* Identifier */) { + if (node.left.kind === 70 /* Identifier */) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -44195,7 +44538,7 @@ var ts; * available. */ function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(54 /* ColonToken */), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(55 /* ColonToken */), ts.createIdentifier("Object")); } /** * Gets an expression that represents a property name. For a computed property, a @@ -44249,9 +44592,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 83 /* ExtendsKeyword */) { + if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83 /* ExtendsKeyword */, types, node); + return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); } return undefined; } @@ -44277,12 +44620,18 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a method declaration of a class. * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked as abstract, async, public, private, protected, or readonly + * - The node is marked as abstract, public, private, protected, or readonly * - The node has both a decorator and a computed property name * * @param node The method node. @@ -44364,8 +44713,8 @@ var ts; * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked async * - The node is exported from a TypeScript namespace + * - The node has decorators * * @param node The function node. */ @@ -44390,7 +44739,7 @@ var ts; * Visits a function expression node. * * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations * * @param node The function expression node. */ @@ -44398,7 +44747,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44408,11 +44757,10 @@ var ts; /** * @remarks * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations */ function visitArrowFunction(node) { - var func = ts.createArrowFunction( - /*modifiers*/ undefined, + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), /*location*/ node); @@ -44420,26 +44768,23 @@ var ts; return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -44461,49 +44806,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 /* ES6 */ ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; - // An async function is emit as an outer function that calls an inner - // generator function. To preserve lexical bindings, we pass the current - // `this` and `arguments` objects to `__awaiter`. The generator function - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= 2 /* ES6 */) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); - } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4 /* EmitSuperHelper */); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); - } - } /** * Visits a parameter declaration node. * @@ -44555,24 +44857,16 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), /*location*/ node); } } - /** - * Visits an await expression. - * - * This function will be called any time a TypeScript await expression is encountered. - * - * @param node The await expression node. - */ - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } /** * Visits a parenthesized expression that contains either a type assertion or an `as` @@ -44611,6 +44905,14 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } /** * Determines whether to emit an enum declaration. * @@ -44673,6 +44975,7 @@ var ts; // ... // })(x || (x = {})); var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44748,7 +45051,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } /** * Records that a declaration was emitted in the current scope, if it was the first @@ -44796,7 +45099,7 @@ var ts; ]); ts.setOriginalNode(statement, /*original*/ node); // Adjust the source map emit to match the old emitter. - if (node.kind === 224 /* EnumDeclaration */) { + if (node.kind === 225 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -44871,6 +45174,7 @@ var ts; // x_1.y = ...; // })(x || (x = {})); var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44899,7 +45203,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226 /* ModuleBlock */) { + if (body.kind === 227 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -44945,17 +45249,127 @@ 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 !== 226 /* ModuleBlock */) { + if (body.kind !== 227 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + /** + * Visits an import declaration, eliding it if it is not referenced. + * + * @param node The import declaration node. + */ + function visitImportDeclaration(node) { + if (!node.importClause) { + // Do not elide a side-effect only import declaration. + // import "foo"; + return node; + } + // Elide the declaration if the import clause was elided. + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, /*optional*/ true); + return importClause + ? ts.updateImportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, importClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits an import clause, eliding it if it is not referenced. + * + * @param node The import clause node. + */ + function visitImportClause(node) { + // Elide the import clause if we elide both its name and its named bindings. + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, /*optional*/ true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + /** + * Visits named import bindings, eliding it if it is not referenced. + * + * @param node The named import bindings node. + */ + function visitNamedImportBindings(node) { + if (node.kind === 233 /* NamespaceImport */) { + // Elide a namespace import if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + // Elide named imports if all of its import specifiers are elided. + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + /** + * Visits an import specifier, eliding it if it is not referenced. + * + * @param node The import specifier node. + */ + function visitImportSpecifier(node) { + // Elide an import specifier if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + /** + * Visits an export assignment, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export assignment node. + */ + function visitExportAssignment(node) { + // Elide the export assignment if it does not reference a value. + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + /** + * Visits an export declaration, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export declaration node. + */ + function visitExportDeclaration(node) { + if (!node.exportClause) { + // Elide a star export if the module it references does not export a value. + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + // Elide the export declaration if it does not export a value. + return undefined; + } + // Elide the export declaration if all of its named exports are elided. + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, /*optional*/ true); + return exportClause + ? ts.updateExportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, exportClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits named exports, eliding it if it does not contain an export specifier that + * resolves to a value. + * + * @param node The named exports node. + */ + function visitNamedExports(node) { + // Elide the named exports if all of its export specifiers were elided. + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + /** + * Visits an export specifier, eliding it if it does not resolve to a value. + * + * @param node The export specifier node. + */ + function visitExportSpecifier(node) { + // Elide an export specifier if it does not reference a value. + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } /** * Determines whether to emit an import equals declaration. * @@ -44976,7 +45390,10 @@ var ts; */ function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + // Elide external module `import=` if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -45152,23 +45569,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(69 /* Identifier */); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 4 /* AsyncMethodsWithSuper */; - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(174 /* CallExpression */); - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(221 /* ClassDeclaration */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(148 /* Constructor */); + context.enableSubstitution(70 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -45176,7 +45577,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. classAliases = ts.createMap(); } @@ -45186,25 +45587,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // 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(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); context.enableSubstitution(254 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(225 /* ModuleDeclaration */); + context.enableEmitNotification(226 /* ModuleDeclaration */); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 148 /* Constructor */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; } /** * Hook for node emit. @@ -45214,12 +45607,6 @@ var ts; */ function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; } @@ -45228,7 +45615,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } /** * Hooks node substitutions. @@ -45265,17 +45651,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 174 /* CallExpression */: - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { - return substituteCallExpression(node); - } - break; } return node; } @@ -45313,8 +45694,8 @@ var ts; // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); if (container) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 225 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 224 /* EnumDeclaration */); + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 226 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 225 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45322,38 +45703,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -45381,2605 +45734,3416 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); -/// -/// +/// +/// /*@internal*/ var ts; (function (ts) { - function transformES6Module(context) { + var entities = createEntitiesMap(); + function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); var currentSourceFile; return transformSourceFile; + /** + * Transform JSX-specific syntax in a SourceFile. + * + * @param node A SourceFile node. + */ function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - return ts.visitEachChild(node, visitor, context); - } + currentSourceFile = node; + node = ts.visitEachChild(node, visitor, context); + currentSourceFile = undefined; return node; } function visitor(node) { + if (node.transformFlags & 4 /* Jsx */) { + return visitorWorker(node); + } + else if (node.transformFlags & 8 /* ContainsJsx */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 231 /* ImportClause */: - return visitImportClause(node); - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - return visitNamedBindings(node); - case 234 /* ImportSpecifier */: - return visitImportSpecifier(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 237 /* NamedExports */: - return visitNamedExports(node); - case 238 /* ExportSpecifier */: - return visitExportSpecifier(node); + case 242 /* JsxElement */: + return visitJsxElement(node, /*isChild*/ false); + case 243 /* JsxSelfClosingElement */: + return visitJsxSelfClosingElement(node, /*isChild*/ false); + case 248 /* JsxExpression */: + return visitJsxExpression(node); + default: + ts.Debug.failBadSyntaxKind(node); + return undefined; } - return node; } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; // do not emit export equals for ES6 + function transformJsxChildToExpression(node) { + switch (node.kind) { + case 10 /* JsxText */: + return visitJsxText(node); + case 248 /* JsxExpression */: + return visitJsxExpression(node); + case 242 /* JsxElement */: + return visitJsxElement(node, /*isChild*/ true); + case 243 /* JsxSelfClosingElement */: + return visitJsxSelfClosingElement(node, /*isChild*/ true); + default: + ts.Debug.failBadSyntaxKind(node); + return undefined; } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + function visitJsxElement(node, isChild) { + return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, /*location*/ node); + } + function visitJsxSelfClosingElement(node, isChild) { + return visitJsxOpeningLikeElement(node, /*children*/ undefined, isChild, /*location*/ node); + } + function visitJsxOpeningLikeElement(node, children, isChild, location) { + var tagName = getTagName(node); + var objectProperties; + var attrs = node.attributes; + if (attrs.length === 0) { + // When there are no attributes, React wants "null" + objectProperties = ts.createNull(); } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; + else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument. + segments.unshift(ts.createObjectLiteral()); + } + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments) + || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true); - if (node.exportClause === newExportClause) { - return node; + var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + if (isChild) { + ts.startOnNewLine(element); } - return newExportClause - ? ts.createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newExportClause, node.moduleSpecifier) - : undefined; + return element; } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; + function transformJsxSpreadAttributeToExpression(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; + function transformJsxAttributeToObjectLiteralElement(node) { + var name = getAttributeName(node); + var expression = transformJsxAttributeInitializer(node.initializer); + return ts.createPropertyAssignment(name, expression); } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; + function transformJsxAttributeInitializer(node) { + if (node === undefined) { + return ts.createLiteral(true); + } + else if (node.kind === 9 /* StringLiteral */) { + var decoded = tryDecodeEntities(node.text); + return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + } + else if (node.kind === 248 /* JsxExpression */) { + return visitJsxExpression(node); + } + else { + ts.Debug.failBadSyntaxKind(node); + } } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; + function visitJsxText(node) { + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); + var parts; + var firstNonWhitespace = 0; + var 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 (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var 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(ts.createLiteral(decodeEntities(part))); + } + firstNonWhitespace = -1; } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newImportClause, node.moduleSpecifier); + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } } } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; + if (firstNonWhitespace !== -1) { + var 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(ts.createLiteral(decodeEntities(part))); + } + if (parts) { + return ts.reduceLeft(parts, aggregateJsxTextParts); } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; + return undefined; } - function visitNamedBindings(node) { - if (node.kind === 232 /* NamespaceImport */) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + /** + * Aggregates two expressions by interpolating them with a whitespace literal. + */ + function aggregateJsxTextParts(left, right) { + return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + } + /** + * Replace entities like " ", "{", and "�" with the characters they encode. + * See https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references + */ + function decodeEntities(text) { + return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { + if (decimal) { + return String.fromCharCode(parseInt(decimal, 10)); + } + else if (hex) { + return String.fromCharCode(parseInt(hex, 16)); + } + else { + var ch = entities[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; + } + }); + } + /** Like `decodeEntities` but returns `undefined` if there were no entities to decode. */ + function tryDecodeEntities(text) { + var decoded = decodeEntities(text); + return decoded === text ? undefined : decoded; + } + function getTagName(node) { + if (node.kind === 242 /* JsxElement */) { + return getTagName(node.openingElement); } else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } - if (newNamedImportElements === node.elements) { - return node; + else { + return ts.createExpressionFromEntityName(name_31); } - return ts.createNamedImports(newNamedImportElements); } } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - } - ts.transformES6Module = transformES6Module; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableEmitNotification(256 /* SourceFile */); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; + /** + * Emit an attribute name, which is quoted if it needs to be quoted. Because + * these emit into an object literal property name, we don't need to be worried + * about keywords, just non-identifier characters + */ + function getAttributeName(node) { + var name = node.name; + if (/^[A-Za-z_]\w*$/.test(name.text)) { + return name; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - // Perform the transformation. - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; + else { + return ts.createLiteral(name.text); } - return node; } - function transformSystemModuleWorker(node) { - // System modules have the following shape: - // - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // - // The parameter 'exports' here is a callback '(name: string, value: T) => T' that - // is used to publish exported values. 'exports' returns its 'value' argument so in - // most cases expressions that mutate exported values can be rewritten as: - // - // expr -> exports('name', expr) - // - // The only exception in this rule is postfix unary operators, - // see comment to 'substitutePostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // Collect information about the external module and dependency groups. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Make sure that the name of the 'exports' function does not conflict with - // existing identifiers. - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - // Add the body of the module. - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], - /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); - // Write the call to `System.register` - // Clear the emit-helpers flag for later passes since we'll have already used it in the module body - // So the helper will be emit at the correct position instead of at the top of the source-file - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), - /*typeArguments*/ undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); - var _a; + function visitJsxExpression(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); } - /** - * Adds the statements for the module body function for the source file. - * - * @param statements The output statements for the module body. - * @param node The source file for the module. - * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. - */ - function addSystemModuleBody(statements, node, dependencyGroups) { - // Shape of the body in system modules: - // - // function (exports) { - // - // - // - // return { - // setters: [ - // - // ], - // execute: function() { - // - // } - // } - // - // } - // - // i.e: - // - // import {x} from 'file1' - // var y = 1; - // export function foo() { return y + x(); } - // console.log(y); - // - // Will be transformed to: - // - // function(exports) { - // var file_1; // local alias - // var y; - // function foo() { return y + file_1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file_1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - // We start a new lexical environment in this function body, but *not* in the - // body of the execute function. This allows us to emit temporary declarations - // only in the outer module body and not in the inner one. - startLexicalEnvironment(); - // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); - // var __moduleName = context_1 && context_1.id; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", - /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - // Visit the statements of the source file, emitting any transformations into - // the `executeStatements` array. We do this *before* we fill the `setters` array - // as we both emit transformations as well as aggregate some data used when creating - // setters. This allows us to reduce the number of times we need to loop through the - // statements of the source file. - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - // We emit the lexical environment (hoisted variables and function declarations) - // early to align roughly with our previous emit output. - // Two key differences in this approach are: - // - Temporary variables will appear at the top rather than at the bottom of the file - // - Calls to the exporter for exported function declarations are grouped after - // the declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Emit early exports for function declarations. - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); + } + ts.transformJsx = transformJsx; + function createEntitiesMap() { + return ts.createMap({ + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }); + } +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + // These variables contain state that changes as we descend into the tree. + var currentSourceFileExternalHelpersModuleName; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + var enabledSubstitutions; + /** + * Keeps track of whether we are within any containing namespaces when performing + * just-in-time substitution while printing an expression identifier. + */ + var applicableSubstitutions; + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + var currentSuperContainer; + // Save the previous transformation hooks. + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; + return ts.visitEachChild(node, visitor, context); } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; + function visitor(node) { + if (node.transformFlags & 16 /* ES2017 */) { + return visitorWorker(node); } - // when resolving exports local exported entries/indirect exported entries in the module - // should always win over entries with similar names that were added via star exports - // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. - // local names set should only be added if we have anything exported - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - // no exported declarations (export var ...) or export specifiers (export {x}) - // check if we have any non star export declarations. - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 236 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; + else if (node.transformFlags & 32 /* ContainsES2017 */) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119 /* AsyncKeyword */: + // ES2017 async modifier should be elided for targets < ES2017 + return undefined; + case 185 /* AwaitExpression */: + // ES2017 'await' expressions must be transformed for targets < ES2017. + return visitAwaitExpression(node); + case 148 /* MethodDeclaration */: + // ES2017 method declarations may be 'async' + return visitMethodDeclaration(node); + case 221 /* FunctionDeclaration */: + // ES2017 function declarations may be 'async' + return visitFunctionDeclaration(node); + case 180 /* FunctionExpression */: + // ES2017 function expressions may be 'async' + return visitFunctionExpression(node); + case 181 /* ArrowFunction */: + // ES2017 arrow functions may be 'async' + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + /** + * Visits an await expression. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The await expression node. + */ + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), + /*location*/ node), node); + } + /** + * Visits a method declaration of a class. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The method node. + */ + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + // While we emit the source map for the node after skipping decorators and modifiers, + // we need to emit the comments for the original range. + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + /** + * Visits a function declaration. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function node. + */ + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * Visits a function expression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function expression node. + */ + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * @remarks + * This function will be called when one of the following conditions are met: + * - The node is marked async + */ + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4 /* EmitSuperHelper */); } } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return addExportStarFunction(statements, /*localNames*/ undefined); + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; } } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; } } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 236 /* ExportDeclaration */) { - continue; + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(175 /* CallExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(222 /* ClassDeclaration */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(149 /* Constructor */); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 174 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 175 /* CallExpression */: + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); } } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 /* ClassDeclaration */ + || kind === 149 /* Constructor */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; } /** - * Emits a setter callback for each dependency group. - * @param write The callback used to write each callback. + * Hook for node emit. + * + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. */ - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 230 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 229 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 236 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // - // emit as: - // - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); - } - else { - // export * from 'foo' - // - // emit as: - // - // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, - /*typeArguments*/ undefined, [parameterName]))); - } - break; - } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64 /* ES2016 */) { + return visitorWorker(node); + } + else if (node.transformFlags & 128 /* ContainsES2016 */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 188 /* BinaryExpression */: + return visitBinaryExpression(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function visitBinaryExpression(node) { + // We are here because ES2016 adds support for the exponentiation operator. + var left = ts.visitNode(node.left, visitor, ts.isExpression); + var right = ts.visitNode(node.right, visitor, ts.isExpression); + if (node.operatorToken.kind === 61 /* AsteriskAsteriskEqualsToken */) { + var target = void 0; + var value = void 0; + if (ts.isElementAccessExpression(left)) { + // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), + /*location*/ left); + value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, + /*location*/ left); } - setters.push(ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + else if (ts.isPropertyAccessExpression(left)) { + // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, + /*location*/ left); + value = ts.createPropertyAccess(expressionTemp, left.name, + /*location*/ left); + } + else { + // Transforms `a **= b` into `a = Math.pow(a, b)` + target = left; + value = left; + } + return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + } + else if (node.operatorToken.kind === 39 /* AsteriskAsteriskToken */) { + // Transforms `a ** b` into `Math.pow(a, b)` + return ts.createMathPow(left, right, /*location*/ node); + } + else { + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + } + ts.transformES2016 = transformES2016; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + /** Enables substitutions for captured `this` */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + /** Enables substitutions for block-scoped bindings. */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + /** + * A capture may have been added for calls to 'super', but + * the caller should emit subsequent statements normally. + */ + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * var _this = _super.call(...) || this; + * + * Callers should skip the current statement. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * return _super.call(...) || this; + * + * Callers should skip the current statement and avoid any returns of '_this'. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentSourceFile; + var currentText; + var currentParent; + var currentNode; + var enclosingVariableStatement; + var enclosingBlockScopeContainer; + var enclosingBlockScopeContainerParent; + var enclosingFunction; + var enclosingNonArrowFunction; + var enclosingNonAsyncFunctionBody; + /** + * Used to track if we are emitting body of the converted loop + */ + var convertedLoopState; + /** + * Keeps track of whether substitutions have been enabled for specific cases. + * They are persisted between each SourceFile transformation and should not + * be reset. + */ + var enabledSubstitutions; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + currentSourceFile = node; + currentText = node.text; + return ts.visitNode(node, visitor, ts.isSourceFile); } - function visitSourceElement(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } + function visitor(node) { + return saveStateAndInvoke(node, dispatcher); } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + 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 currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; + var savedConvertedLoopState = convertedLoopState; + if (ts.nodeStartsNewLexicalEnvironment(node)) { + // don't treat content of nodes that start new lexical environment as part of converted loop copy + convertedLoopState = undefined; } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + onBeforeVisitNode(node); + var visited = f(node); + convertedLoopState = savedConvertedLoopState; + enclosingFunction = savedEnclosingFunction; + enclosingNonArrowFunction = savedEnclosingNonArrowFunction; + enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; + enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; + enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; + enclosingVariableStatement = savedEnclosingVariableStatement; currentParent = savedCurrentParent; currentNode = savedCurrentNode; + return visited; + } + function shouldCheckNode(node) { + return (node.transformFlags & 256 /* ES2015 */) !== 0 || + node.kind === 215 /* LabeledStatement */ || + (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + } + function visitorWorker(node) { + if (shouldCheckNode(node)) { + return visitJavaScript(node); + } + else if (node.transformFlags & 512 /* ContainsES2015 */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorForConvertedLoopWorker(node) { + var result; + if (shouldCheckNode(node)) { + result = visitJavaScript(node); + } + else { + result = visitNodesInConvertedLoop(node); + } return result; } - function visitNestedNodeWorker(node) { + function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 200 /* VariableStatement */: + case 212 /* ReturnStatement */: + return visitReturnStatement(node); + case 201 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 70 /* Identifier */: + return visitIdentifier(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitJavaScript(node) { + switch (node.kind) { + case 83 /* ExportKeyword */: + return node; + case 222 /* ClassDeclaration */: return visitClassDeclaration(node); - case 206 /* ForStatement */: + case 193 /* ClassExpression */: + return visitClassExpression(node); + case 143 /* Parameter */: + return visitParameter(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 181 /* ArrowFunction */: + return visitArrowFunction(node); + case 180 /* FunctionExpression */: + return visitFunctionExpression(node); + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 70 /* Identifier */: + return visitIdentifier(node); + case 220 /* VariableDeclarationList */: + return visitVariableDeclarationList(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 207 /* ForStatement */: return visitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return visitForOfStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 212 /* WithStatement */: - return visitWithStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 227 /* CaseBlock */: - return visitCaseBlock(node); - case 249 /* CaseClause */: - return visitCaseClause(node); - case 250 /* DefaultClause */: - return visitDefaultClause(node); - case 216 /* TryStatement */: - return visitTryStatement(node); - case 252 /* CatchClause */: - return visitCatchClause(node); - case 199 /* Block */: - return visitBlock(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return visitExpressionStatement(node); + case 172 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 254 /* ShorthandPropertyAssignment */: + return visitShorthandPropertyAssignment(node); + case 171 /* ArrayLiteralExpression */: + return visitArrayLiteralExpression(node); + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 179 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); + case 188 /* BinaryExpression */: + return visitBinaryExpression(node, /*needsDestructuringValue*/ true); + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + return visitTemplateLiteral(node); + case 177 /* TaggedTemplateExpression */: + return visitTaggedTemplateExpression(node); + case 190 /* TemplateExpression */: + return visitTemplateExpression(node); + case 191 /* YieldExpression */: + return visitYieldExpression(node); + case 96 /* SuperKeyword */: + return visitSuperKeyword(); + case 191 /* YieldExpression */: + // `yield` will be handled by a generators transform. + return ts.visitEachChild(node, visitor, context); + case 148 /* MethodDeclaration */: + return visitMethodDeclaration(node); + case 256 /* SourceFile */: + return visitSourceFileNode(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); default: - return node; + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); } } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + function onBeforeVisitNode(node) { + if (currentNode) { + if (ts.isBlockScope(currentNode, currentParent)) { + enclosingBlockScopeContainer = currentNode; + enclosingBlockScopeContainerParent = currentParent; + } + if (ts.isFunctionLike(currentNode)) { + enclosingFunction = currentNode; + if (currentNode.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = currentNode; + if (!(ts.getEmitFlags(currentNode) & 2097152 /* 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 201 /* VariableStatement */: + enclosingVariableStatement = currentNode; + break; + case 220 /* VariableDeclarationList */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: + break; + default: + enclosingVariableStatement = undefined; + } } - return undefined; + currentParent = currentNode; + currentNode = node; } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - // NOTE(rbuckton): Do we support export import = require('') in System? - return undefined; + 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; } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; + 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()) + ])); + } + function visitThisKeyword(node) { + ts.Debug.assert(convertedLoopState !== undefined); + if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; } - return undefined; + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + function visitIdentifier(node) { + if (!convertedLoopState) { + return node; } - return undefined; + if (ts.isGeneratedIdentifier(node)) { + return node; + } + if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + return node; + } + return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); + function visitBreakOrContinueStatement(node) { + if (convertedLoopState) { + // check if we can emit break/continue as is + // 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 === 211 /* 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 === 211 /* BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Break */; + labelMarker = "break"; + } + else { + convertedLoopState.nonLocalJumps |= 4 /* Continue */; + // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. + labelMarker = "continue"; + } + } + else { + if (node.kind === 211 /* BreakStatement */) { + labelMarker = "break-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); + } + else { + labelMarker = "continue-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); + } + } + var returnExpression = ts.createLiteral(labelMarker); + if (convertedLoopState.loopOutParameters.length) { + var outParams = convertedLoopState.loopOutParameters; + var expr = void 0; + for (var i = 0; i < outParams.length; i++) { + var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + if (i === 0) { + expr = copyExpr; + } + else { + expr = ts.createBinary(expr, 25 /* CommaToken */, copyExpr); + } + } + returnExpression = ts.createBinary(expr, 25 /* CommaToken */, returnExpression); + } + return ts.createReturn(returnExpression); } } - return undefined; + return ts.visitEachChild(node, visitor, context); } /** - * Visits a variable statement, hoisting declared names to the top-level module body. - * Each declaration is rewritten into an assignment expression. + * Visits a ClassDeclaration and transforms it into a variable statement. * - * @param node The variable statement to visit. + * @param node A ClassDeclaration node. */ - function visitVariableStatement(node) { - // hoist only non-block scoped declarations or block scoped declarations parented by source file - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || - enclosingBlockScopedContainer.kind === 256 /* SourceFile */; - if (!shouldHoist) { - return node; + function visitClassDeclaration(node) { + // [source] + // class C { } + // + // [output] + // var C = (function () { + // function C() { + // } + // return C; + // }()); + var modifierFlags = ts.getModifierFlags(node); + var isExported = modifierFlags & 1 /* Export */; + var isDefault = modifierFlags & 512 /* Default */; + // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) + var modifiers = isExported && !isDefault + ? ts.filter(node.modifiers, isExportModifier) + : undefined; + var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), + /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) + ]), + /*location*/ node); + ts.setOriginalNode(statement, node); + ts.startOnNewLine(statement); + // Add an `export default` statement for default exports (for `--target es5 --module es6`) + if (isExported && isDefault) { + var statements = [statement]; + statements.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); + return statements; } - var isExported = ts.hasModifier(node, 1 /* Export */); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } + return statement; + } + function isExportModifier(node) { + return node.kind === 83 /* ExportKeyword */; + } + /** + * Visits a ClassExpression and transforms it into an expression. + * + * @param node A ClassExpression node. + */ + function visitClassExpression(node) { + // [source] + // C = class { } + // + // [output] + // C = (function () { + // function class_1() { + // } + // return class_1; + // }()) + return transformClassLikeDeclarationToExpression(node); + } + /** + * Transforms a ClassExpression or ClassDeclaration into an expression. + * + * @param node A ClassExpression or ClassDeclaration node. + */ + function transformClassLikeDeclarationToExpression(node) { + // [source] + // class C extends D { + // constructor() {} + // method() {} + // get prop() {} + // set prop(v) {} + // } + // + // [output] + // (function (_super) { + // __extends(C, _super); + // function C() { + // } + // C.prototype.method = function () {} + // Object.defineProperty(C.prototype, "prop", { + // get: function() {}, + // set: function() {}, + // enumerable: true, + // configurable: true + // }); + // return C; + // }(D)) + if (node.name) { + enableSubstitutionsForBlockScopedBindings(); } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); + var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var classFunction = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], + /*type*/ undefined, transformClassBody(node, extendsClauseElement)); + // To preserve the behavior of the old emitter, we explicitly indent + // the body of the function here if it was requested in an earlier + // transformation. + if (ts.getEmitFlags(node) & 524288 /* Indented */) { + ts.setEmitFlags(classFunction, 524288 /* Indented */); } - return undefined; + // "inner" and "outer" below are added purely to preserve source map locations from + // the old emitter + var inner = ts.createPartiallyEmittedExpression(classFunction); + inner.end = node.end; + ts.setEmitFlags(inner, 49152 /* NoComments */); + var outer = ts.createPartiallyEmittedExpression(inner); + outer.end = ts.skipTrivia(currentText, node.pos); + ts.setEmitFlags(outer, 49152 /* NoComments */); + return ts.createParen(ts.createCall(outer, + /*typeArguments*/ undefined, extendsClauseElement + ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] + : [])); } /** - * Transforms a VariableDeclaration into one or more assignment expressions. + * Transforms a ClassExpression or ClassDeclaration into a function body. * - * @param node The VariableDeclaration to transform. - * @param isExported A value used to indicate whether the containing statement was exported. + * @param node A ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. */ - function transformVariable(node, isExported) { - // Hoist any bound names within the declaration. - hoistBindingElement(node, isExported); - if (!node.initializer) { - // If the variable has no initializer, ignore it. - return; + function transformClassBody(node, extendsClauseElement) { + var statements = []; + startLexicalEnvironment(); + addExtendsHelperIfNeeded(statements, node, extendsClauseElement); + addConstructor(statements, node, extendsClauseElement); + addClassMembers(statements, node); + // Create a synthetic text range for the return statement. + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); + var localName = getLocalName(node); + // The following partially-emitted expression exists purely to align our sourcemap + // emit with the original emitter. + var outer = ts.createPartiallyEmittedExpression(localName); + outer.end = closingBraceLocation.end; + ts.setEmitFlags(outer, 49152 /* NoComments */); + var statement = ts.createReturn(outer); + statement.pos = closingBraceLocation.pos; + ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); + statements.push(statement); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + ts.setEmitFlags(block, 49152 /* NoComments */); + return block; + } + /** + * Adds a call to the `__extends` helper if needed for a class. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { + if (extendsClauseElement) { + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), + /*location*/ extendsClauseElement)); + } + } + /** + * Adds the constructor of the class to a class body function. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addConstructor(statements, node, extendsClauseElement) { + var constructor = ts.getFirstConstructorWithBody(node); + var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); + var constructorFunction = ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, getDeclarationName(node), + /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), + /*location*/ constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); + } + statements.push(constructorFunction); + } + /** + * Transforms the parameters of the constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorParameters(constructor, hasSynthesizedSuper) { + // If the TypeScript transformer needed to synthesize a constructor for property + // initializers, it would have also added a synthetic `...args` parameter and + // `super` call. + // If this is the case, we do not include the synthetic `...args` parameter and + // will instead use the `arguments` object in ES5/3. + if (constructor && !hasSynthesizedSuper) { + return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); + } + return []; + } + /** + * Transforms the body of a constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param node The node which contains the constructor. + * @param extendsClauseElement The expression for the class `extends` clause. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + // If a super call has already been synthesized, + // we're going to assume that we should just transform everything after that. + // The assumption is that no prior step in the pipeline has added any prologue directives. + statementOffset = 1; + } + else if (constructor) { + // Otherwise, try to emit all potential prologue directives first. + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + } + if (constructor) { + addDefaultValueAssignmentsIfNeeded(statements, constructor); + addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // The last statement expression was replaced. Skip it. + if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { + statementOffset++; } - var name = node.name; - if (ts.isIdentifier(name)) { - // If the variable has an IdentifierName, write out an assignment expression in its place. - return ts.createAssignment(name, node.initializer); + if (constructor) { + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); + ts.addRange(statements, body); } - else { - // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + // 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 + && superCaptureStatus !== 2 /* ReplaceWithReturn */ + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); } + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, + /*location*/ constructor ? constructor.body.statements : node.members), + /*location*/ constructor ? constructor.body : node, + /*multiLine*/ true); + if (!constructor) { + ts.setEmitFlags(block, 49152 /* NoComments */); + } + return block; } /** - * Visits a FunctionDeclaration, hoisting it to the outer module body function. - * - * @param node The function declaration to visit. + * We want to try to avoid emitting a return statement in certain cases if a user already returned something. + * It would generate obviously dead code, so we'll try to make things a little bit prettier + * by doing a minimal check on whether some common patterns always explicitly return. */ - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1 /* Export */)) { - // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_31 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name_31, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node); - // Record a declaration export in the outer module body function. - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_31); + function isSufficientlyCoveredByReturnStatements(statement) { + // A return statement is considered covered. + if (statement.kind === 212 /* ReturnStatement */) { + return true; + } + else if (statement.kind === 204 /* IfStatement */) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } - ts.setOriginalNode(newNode, node); - node = newNode; } - // Hoist the function declaration to the outer module body function. - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 /* ModuleDeclaration */ || originalNode.kind === 224 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_32 = getDeclarationName(originalNode); - // We only need to hoistVariableDeclaration for EnumDeclaration - // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement - // which then call transformsVariable for each declaration in declarationList - if (originalNode.kind === 224 /* EnumDeclaration */) { - hoistVariableDeclaration(name_32); + else if (statement.kind === 200 /* Block */) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; } - return [ - node, - createExportStatement(name_32, name_32) - ]; } - return node; + return false; } /** - * Visits a ClassDeclaration, hoisting its name to the outer module body function. + * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. * - * @param node The class declaration to visit. + * @returns The new statement offset into the `statements` array. */ - function visitClassDeclaration(node) { - // Hoist the name of the class declaration to the outer module body function. - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - // Rewrite the class declaration into an assignment of a class expression. - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node)), - /*location*/ node)); - // If the class was exported, write a declaration export to the inner module body function. - if (ts.hasModifier(node, 1 /* Export */)) { - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name); + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + // If this isn't a derived class, just capture 'this' for arrow functions if necessary. + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); } - statements.push(createDeclarationExport(node)); + return 0 /* NoReplacement */; } - return statements; + // We must be here because the user didn't write a constructor + // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. + // If that's the case we can just immediately return the result of a 'super()' call. + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2 /* ReplaceWithReturn */; + } + // The constructor exists, but it and the 'super()' call it contains were generated + // for something like property initializers. + // Create a captured '_this' variable and assume it will subsequently be used. + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1 /* ReplaceSuperCapture */; + } + // Most of the time, a 'super' call will be the first real statement in a constructor body. + // In these cases, we'd like to transform these into a *single* statement instead of a declaration + // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, + // we'd get: + // + // var _this; + // _this = _super.call(...) || this; + // + // instead of + // + // var _this = _super.call(...) || this; + // + // Additionally, if the 'super()' call is the last statement, we should just avoid capturing + // entirely and immediately return the result like so: + // + // return _super.call(...) || this; + // + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + // Return the result if we have an immediate super() call on the last statement. + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2 /* ReplaceWithReturn */; + } + // Perform the capture. + captureThisForNode(statements, ctor, superCallExpression, 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 shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } /** - * Visits the body of a ForStatement to hoist declarations. + * Visits a parameter declaration. * - * @param node The statement to visit. + * @param node A ParameterDeclaration node. */ - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, /*isExported*/ false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), - /*location*/ node); + function visitParameter(node) { + if (node.dotDotDotToken) { + // rest parameters are elided + return undefined; + } + else if (ts.isBindingPattern(node.name)) { + // Binding patterns are converted into a generated name and are + // evaluated inside the function body. + return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); + } + else if (node.initializer) { + // Initializers are elided + return ts.setOriginalNode(ts.createParameter(node.name, + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); } else { - return ts.visitEachChild(node, visitNestedNode, context); + return node; } } /** - * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. + * Gets a value indicating whether we need to add default value assignments for a + * function-like node. * - * @param node The decalaration list to transform. + * @param node A function-like node. */ - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, /*isExported*/ false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 262144 /* ContainsDefaultValueAssignments */) !== 0; } /** - * Visits the body of a ForInStatement to hoist declarations. + * Adds statements to the body of a function-like node if it contains parameters with + * binding patterns or initializers. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param node A function-like node. */ - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; + function addDefaultValueAssignmentsIfNeeded(statements, node) { + if (!shouldAddDefaultValueAssignments(node)) { + return; } - else { - return ts.visitEachChild(node, visitNestedNode, context); + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); + } } } /** - * Visits the body of a ForOfStatement to hoist declarations. + * Adds statements to the body of a function-like node for parameters with binding patterns * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. */ - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { + var temp = ts.getGeneratedNameForNode(parameter); + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + if (name.elements.length > 0) { + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608 /* CustomPrologue */)); } - else { - return ts.visitEachChild(node, visitNestedNode, context); + else if (initializer) { + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); } } /** - * Visits the body of a DoStatement to hoist declarations. + * Adds statements to the body of a function-like node for parameters with initializers. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. */ - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), + /*location*/ parameter)) + ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), + /*elseStatement*/ undefined, + /*location*/ parameter); + statement.startsOnNewLine = true; + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + statements.push(statement); } /** - * Visits the body of a WhileStatement to hoist declarations. + * Gets a value indicating whether we need to add statements to handle a rest parameter. * - * @param node The statement to visit. + * @param node A ParameterDeclaration node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` */ - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** - * Visits the body of a LabeledStatement to hoist declarations. + * Adds statements to the body of a function-like node if it contains a rest parameter. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param node A function-like node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` */ - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; } - return node; + // `declarationName` is the name of the local declaration for the parameter. + var declarationName = ts.getMutableClone(parameter.name); + ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); + // `expressionName` is the name of the parameter used in expressions. + var expressionName = ts.getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = ts.createLoopVariable(); + // var param = []; + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declarationName, + /*type*/ undefined, ts.createArrayLiteral([])) + ]), + /*location*/ parameter), 8388608 /* CustomPrologue */)); + // for (var _i = restIndex; _i < arguments.length; _i++) { + // param[_i - restIndex] = arguments[_i]; + // } + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) + ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), + /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ + ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + /*location*/ parameter)) + ])); + ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); + ts.startOnNewLine(forStatement); + statements.push(forStatement); } /** - * Visits the body of a WithStatement to hoist declarations. + * Adds a statement to capture the `this` of a function declaration if it is needed. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param node A node. */ - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + function addCaptureThisForNodeIfNeeded(statements, node) { + if (node.transformFlags & 65536 /* ContainsCapturedLexicalThis */ && node.kind !== 181 /* ArrowFunction */) { + captureThisForNode(statements, node, ts.createThis()); } - return node; } - /** - * Visits the body of a SwitchStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); } /** - * Visits the body of a CaseBlock to hoist declarations. + * Adds statements to the class body function for a class to define the members of the + * class. * - * @param node The node to visit. + * @param statements The statements for the class body function. + * @param node The ClassExpression or ClassDeclaration node. */ - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; + function addClassMembers(statements, node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + switch (member.kind) { + case 199 /* SemicolonClassElement */: + statements.push(transformSemicolonClassElementToStatement(member)); + break; + case 148 /* MethodDeclaration */: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + break; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + } + break; + case 149 /* Constructor */: + // Constructors are handled in visitClassExpression/visitClassDeclaration + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } } - return node; } /** - * Visits the body of a CaseClause to hoist declarations. + * Transforms a SemicolonClassElement into a statement for a class body function. * - * @param node The clause to visit. + * @param member The SemicolonClassElement node. */ - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; + function transformSemicolonClassElementToStatement(member) { + return ts.createEmptyStatement(/*location*/ member); } /** - * Visits the body of a DefaultClause to hoist declarations. + * Transforms a MethodDeclaration into a statement for a class body function. * - * @param node The clause to visit. + * @param receiver The receiver for the member. + * @param member The MethodDeclaration node. */ - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); + function transformClassMethodDeclarationToStatement(receiver, member) { + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); + var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + ts.setEmitFlags(func, 49152 /* NoComments */); + ts.setSourceMapRange(func, sourceMapRange); + var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), + /*location*/ member.name), func), + /*location*/ member); + ts.setOriginalNode(statement, member); + ts.setCommentRange(statement, commentRange); + // The location for the statement is used to emit comments only. + // No source map should be emitted for this statement to align with the + // old emitter. + ts.setEmitFlags(statement, 1536 /* NoSourceMap */); + return statement; } /** - * Visits the body of a TryStatement to hoist declarations. + * Transforms a set of related of get/set accessors into a statement for a class body function. * - * @param node The statement to visit. + * @param receiver The receiver for the member. + * @param accessors The set of related get/set accessors. */ - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); + function transformAccessorsToStatement(receiver, accessors) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*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 + // old emitter. + ts.setEmitFlags(statement, 49152 /* NoComments */); + return statement; } /** - * Visits the body of a CatchClause to hoist declarations. + * Transforms a set of related get/set accessors into an expression for either a class + * body function or an ObjectLiteralExpression with computed properties. * - * @param node The clause to visit. + * @param receiver The receiver for the member. */ - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; + function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + // 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); + ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); + ts.setSourceMapRange(target, firstAccessor.name); + var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); + ts.setSourceMapRange(propertyName, firstAccessor.name); + var properties = []; + if (getAccessor) { + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); + properties.push(getter); + } + if (setAccessor) { + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); + properties.push(setter); + } + properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + target, + propertyName, + ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ]); + if (startsOnNewLine) { + call.startsOnNewLine = true; } - return node; + return call; } /** - * Visits the body of a Block to hoist declarations. + * Visits an ArrowFunction and transforms it into a FunctionExpression. * - * @param node The block to visit. + * @param node An ArrowFunction node. */ - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - // - // Substitutions - // - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); + function visitArrowFunction(node) { + if (node.transformFlags & 32768 /* ContainsLexicalThis */) { + enableSubstitutionsForCapturedThis(); } + var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); + ts.setEmitFlags(func, 256 /* CapturesThis */); + return func; } /** - * Hooks node substitutions. + * Visits a FunctionExpression node. * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. + * @param node a FunctionExpression node. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - return node; + function visitFunctionExpression(node) { + return transformFunctionLikeToExpression(node, /*location*/ node, node.name); } /** - * Substitute the expression, if necessary. + * Visits a FunctionDeclaration node. * - * @param node The node to substitute. + * @param node a FunctionDeclaration node. */ - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; + function visitFunctionDeclaration(node) { + return ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node), + /*original*/ node); } /** - * Substitution for identifiers exported at the top level of a module. + * Transforms a function-like node into a FunctionExpression. + * + * @param node The function-like node to transform. + * @param location The source-map location for the new FunctionExpression. + * @param name The name of the new FunctionExpression. */ - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var left = node.left; - switch (left.kind) { - case 69 /* Identifier */: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 171 /* ObjectLiteralExpression */: - case 170 /* ArrayLiteralExpression */: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256 /* SourceFile */; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 69 /* Identifier */: - return isExportedBinding(node); - case 171 /* ObjectLiteralExpression */: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 170 /* ArrayLiteralExpression */: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); + function transformFunctionLikeToExpression(node, location, name) { + var savedContainingNonArrowFunction = enclosingNonArrowFunction; + if (node.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = node; } + var expression = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*original*/ node); + enclosingNonArrowFunction = savedContainingNonArrowFunction; + return expression; } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 56 /* EqualsToken */ - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); + /** + * Transforms the body of a function-like node. + * + * @param node A function-like node. + */ + function transformFunctionBody(node) { + var multiLine = false; // indicates whether the block *must* be emitted as multiple lines + var singleLine = false; // indicates whether the block *may* be emitted as a single line + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + startLexicalEnvironment(); + if (ts.isBlock(body)) { + // ensureUseStrict is false because no new prologue-directive should be added. + // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array + statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); + addCaptureThisForNodeIfNeeded(statements, node); + addDefaultValueAssignmentsIfNeeded(statements, node); + addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); + // If we added any generated statements, this must be a multi-line block. + if (!multiLine && statements.length > 0) { + multiLine = true; } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + // If the original body was a multi-line block, this must be a multi-line block. + if (!multiLine && body.multiLine) { + multiLine = true; + } } else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 186 /* PostfixUnaryExpression */ || - (node.kind === 185 /* PrefixUnaryExpression */ && (operator === 41 /* PlusPlusToken */ || operator === 42 /* MinusMinusToken */))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128 /* NoSubstitution */); - var call = createExportExpression(operand, expr); - if (node.kind === 185 /* PrefixUnaryExpression */) { - return call; + ts.Debug.assert(node.kind === 181 /* ArrowFunction */); + // To align with the old emitter, we use a synthetic end position on the location + // for the statement list we synthesize when we down-level an arrow function with + // an expression function body. This prevents both comments and source maps from + // being emitted for the end position only. + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; } else { - // export function returns the value that was passes as the second argument - // however for postfix unary expressions result value should be the value before modification. - // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' - return operator === 41 /* PlusPlusToken */ - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); + multiLine = true; } } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = ts.createReturn(expression, /*location*/ body); + ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + statements.push(returnStatement); + // To align with the source map emit for the old emitter, we set a custom + // source map location for the close brace. + closeBraceLocation = body; } - return node; - } - /** - * Gets a name to use for a DeclarationStatement. - * @param node The declaration statement. - */ - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, exportStarFunction, - /*typeParameters*/ undefined, [ts.createParameter(m)], - /*type*/ undefined, ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, - /*type*/ undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, /*type*/ undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true))); - return exportStarFunction; - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - /** - * Creates a call to the current file's export function to export a declaration. - * @param node The declaration to export. - */ - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - if (name.originalKeywordKind && languageVersion === 0 /* ES3 */) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } + var lexicalEnvironment = endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + // If we added any final generated statements, this must be a multi-line block + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; + var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + ts.setEmitFlags(block, 32 /* SingleLine */); } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; + if (closeBraceLocation) { + ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); } - exportedFunctionDeclarations.push(createDeclarationExport(node)); + ts.setOriginalNode(block, node.body); + return block; } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + /** + * Visits an ExpressionStatement that contains a destructuring assignment. + * + * @param node An ExpressionStatement node. + */ + function visitExpressionStatement(node) { + // If we are here it is most likely because our expression is a destructuring assignment. + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 188 /* BinaryExpression */: + return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } + return ts.visitEachChild(node, visitor, context); } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); - context.enableEmitNotification(256 /* SourceFile */); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - // Subset of exportSpecifiers that is a binding-name. - // This is to reduce amount of memory we have to keep around even after we done with module-transformer - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; /** - * Transforms the module aspects of a SourceFile. + * Visits a ParenthesizedExpression that may contain a destructuring assignment. * - * @param node The SourceFile node. + * @param node A ParenthesizedExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - // Collect information about the external module. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Perform the transformation. - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; + function visitParenthesizedExpression(node, needsDestructuringValue) { + // If we are here it is most likely because our expression is a destructuring assignment. + if (needsDestructuringValue) { + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + case 188 /* BinaryExpression */: + return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + } } - return node; - var _a; + return ts.visitEachChild(node, visitor, context); } /** - * Transforms a SourceFile into a CommonJS module. + * Visits a BinaryExpression that contains a destructuring assignment. * - * @param node The SourceFile node. + * @param node A BinaryExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); + function visitBinaryExpression(node, needsDestructuringValue) { + // If we are here it is because this is a destructuring assignment. + ts.Debug.assert(ts.isDestructuringAssignment(node)); + return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + } + function visitVariableStatement(node) { + if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 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++) { + var decl = _a[_i]; + hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); + if (decl.initializer) { + var assignment = void 0; + if (ts.isBindingPattern(decl.name)) { + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); + } + else { + assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + } + (assignments || (assignments = [])).push(assignment); + } + } + if (assignments) { + return 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; + } } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); + return ts.visitEachChild(node, visitor, context); } /** - * Transforms a SourceFile into a UMD module. + * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). * - * @param node The SourceFile node. + * @param node A VariableDeclarationList node. */ - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16 /* UMDDefine */); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); + function visitVariableDeclarationList(node) { + 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; } /** - * Transforms a SourceFile into an AMD or UMD module. + * Gets a value indicating whether we should emit an explicit initializer for a variable + * declaration in a `let` declaration list. * - * @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. + * @param node A VariableDeclaration node. */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: + function shouldEmitExplicitInitializerForLetDeclaration(node) { + // Nested let bindings might need to be initialized explicitly to preserve + // ES6 semantic: // - // define(id?, dependencies?, factory); + // { let x = 1; } + // { let x; } // x here should be undefined. not 1 // - // This has the shape of the following: + // Top level bindings never collide with anything and thus don't require + // explicit initialization. As for nested let bindings there are two cases: // - // define(name, ["module1", "module2"], function (module1Alias) { ... } + // - Nested let bindings that were not renamed definitely should be + // initialized explicitly: // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. + // { let x = 1; } + // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } // - // To ensure this is true in cases of modules with no aliases, e.g.: + // Without explicit initialization code in /*1*/ can be executed even if + // some-condition is evaluated to false. // - // import "module" + // - Renaming introduces fresh name that should not collide with any + // existing names, however renamed bindings sometimes also should be + // explicitly initialized. One particular case: non-captured binding + // declared inside loop body (but not in loop initializer): // - // or + // let x; + // for (;;) { + // let x; + // } // - // /// + // In downlevel codegen inner 'x' will be renamed so it won't collide + // with outer 'x' however it will should be reset on every iteration as + // if it was declared anew. // - // 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; - // Create an updated SourceFile: + // * Why non-captured binding? + // - Because if loop contains block scoped binding captured in some + // function then loop body will be rewritten to have a fresh scope + // on every iteration so everything will just work. // - // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); + // * Why loop initializer is excluded? + // - Since we've introduced a fresh name it already will be undefined. + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + || (isCapturedInFunction + && isDeclaredInLoop + && ts.isBlock(enclosingBlockScopeContainer) + && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + var emitExplicitInitializer = !emittedAsTopLevel + && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && (!resolver.isDeclarationWithCollidingName(node) + || (isDeclaredInLoop + && !isCapturedInFunction + && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + return emitExplicitInitializer; } /** - * Transforms a SourceFile into an AMD or UMD module body. + * Visits a VariableDeclaration in a `let` declaration list. * - * @param node The SourceFile node. + * @param node A VariableDeclaration node. */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - // Visit each statement of the module body. - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.setEmitFlags(body, 2 /* EmitExportStar */); + function visitVariableDeclarationInLetDeclarationList(node) { + // For binding pattern names that lack initializers there is no point to emit + // explicit initializer since downlevel codegen for destructuring will fail + // in the absence of initializer so all binding elements will say uninitialized + var name = node.name; + if (ts.isBindingPattern(name)) { + return visitVariableDeclaration(node); } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, - /*location*/ exportEquals); - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), - /*location*/ exportEquals); - ts.setEmitFlags(statement, 49152 /* NoComments */); - statements.push(statement); - } + if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { + var clone_5 = ts.getMutableClone(node); + clone_5.initializer = ts.createVoidZero(); + return clone_5; } + return ts.visitEachChild(node, visitor, context); } /** - * Visits a node at the top level of the source file. + * Visits a VariableDeclaration node with a binding pattern. * - * @param node The node. + * @param node A VariableDeclaration node. */ - function visitor(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; + function visitVariableDeclaration(node) { + // If we are here it is because the name contains a binding pattern. + if (ts.isBindingPattern(node.name)) { + var recordTempVariablesInLine = !enclosingVariableStatement + || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); + return ts.flattenVariableDestructuring(node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + } + 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); + } + else { + result = ts.visitEachChild(node, visitor, context); + } + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; } + return result; + } + function visitDoStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitWhileStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForInStatement(node) { + return convertIterationStatementBodyIfNecessary(node); } /** - * Visits an ImportDeclaration node. + * Visits a ForOfStatement and converts it into a compatible ForStatement. * - * @param node The ImportDeclaration node. + * @param node A ForOfStatement. */ - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } + function visitForOfStatement(node) { + return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + } + function convertForOfToFor(node, convertedLoopBodyStatements) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (var _i = 0, _a = expr; _i < _a.length; _i++) { + // var v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - statements.push(ts.createStatement(createRequireCall(node), - /*location*/ node)); + // In the case where the user wrote an identifier as the RHS, like this: + // + // for (let v of arr) { } + // + // we don't want to emit a temporary variable for the RHS, just use it directly. + var counter = ts.createLoopVariable(); + var rhsReference = expression.kind === 70 /* Identifier */ + ? ts.createUniqueName(expression.text) + : ts.createTempVariable(/*recordTempVariable*/ undefined); + // Initialize LHS + // var v = _a[_i]; + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + ts.setOriginalNode(declarationList, initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createConstDeclarationList(variables), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - // Set emitFlags on the name of the importEqualsDeclaration - // This is so the printer will not substitute the identifier - ts.setEmitFlags(node.name, 128 /* NoSubstitution */); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), - /*location*/ node)); + /*modifiers*/ undefined, declarationList)); } else { + // The following call does not include the initializer, so we have + // to emit it separately. statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES6 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) + ], /*location*/ ts.moveRangePos(initializer, -1)), + /*location*/ ts.moveRangeEnd(initializer, -1))); } } else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), - /*location*/ node)); + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); + if (ts.isDestructuringAssignment(assignment)) { + // This is a destructuring pattern, so we flatten the destructuring instead. + statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, + /*needsValue*/ false, hoistVariableDeclaration, visitor))); + } + else { + // Currently there is not way to check that assignment is binary expression of destructing assignment + // so we have to cast never type to binaryExpression + assignment.end = initializer.end; + statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); } } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier)); - } + else { + statements.push(statement); } - return ts.singleOrMany(statements); - } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); } + // The old emitter does not emit source maps for the expression + ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), + /*location*/ bodyLocation); + ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), + ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) + ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), + /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, + /*location*/ node); + // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. + ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + return forStatement; } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; + /** + * Visits an ObjectLiteralExpression with computed propety names. + * + * @param node An ObjectLiteralExpression node. + */ + function visitObjectLiteralExpression(node) { + // We are here because a ComputedPropertyName was used somewhere in the expression. + var properties = node.properties; + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialProperties = numProperties; + for (var i = 0; i < numProperties; i++) { + var property = properties[i]; + if (property.transformFlags & 16777216 /* ContainsYield */ + || property.name.kind === 141 /* ComputedPropertyName */) { + numInitialProperties = i; + break; } } - return undefined; + 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), 524288 /* 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); } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + function shouldConvertIterationStatementBody(node) { + return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256 /* SourceFile */); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + /** + * Records constituents of name for the given variable to be hoisted in the outer scope. + */ + function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(node.name); + function visit(node) { + if (node.kind === 70 /* Identifier */) { + state.hoistedLocalVariables.push(node); } else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); + for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + visit(element.name); + } + } + } + } + } + function convertIterationStatementBodyIfNecessary(node, convert) { + if (!shouldConvertIterationStatementBody(node)) { + var saveAllowedNonLabeledJumps = void 0; + if (convertedLoopState) { + // we get here if we are trying to emit normal loop loop inside converted loop + // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } + var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + return result; } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); + var functionName = ts.createUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + var initializer = node.initializer; + if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + loopInitializer = initializer; + } + break; } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); + // variables that will be passed to the loop as parameters + var loopParameters = []; + // variables declared in the loop initializer that will be changed inside the loop + var loopOutParameters = []; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); } } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); + var outerConvertedLoopState = convertedLoopState; + convertedLoopState = { loopOutParameters: loopOutParameters }; + if (outerConvertedLoopState) { + // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. + // if outer converted loop has already accumulated some state - pass it through + if (outerConvertedLoopState.argumentsName) { + // outer loop has already used 'arguments' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), - /*location*/ specifier.name))); + if (outerConvertedLoopState.thisName) { + // outer loop has already used 'this' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.thisName = outerConvertedLoopState.thisName; + } + if (outerConvertedLoopState.hoistedLocalVariables) { + // we've already collected some non-block scoped variable declarations in enclosing loop + // use the same storage in nested loop + convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; } } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512 /* Default */)) { - addExportDefault(statements, getDeclarationName(node), /*location*/ node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var currentState = convertedLoopState; + convertedLoopState = outerConvertedLoopState; + if (loopOutParameters.length) { + var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; + copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); + loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); } - } - function visitVariableStatement(node) { - // If the variable is for a generated declaration, - // we should maintain it and just strip off the 'export' modifier if necessary. - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 /* ModuleDeclaration */ || - originalKind === 224 /* EnumDeclaration */ || - originalKind === 221 /* ClassDeclaration */) { - if (!ts.hasModifier(node, 1 /* Export */)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, node.declarationList), node); + if (!ts.isBlock(loopBody)) { + loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } - var resultStatements = []; - // If we're exporting these variables, then these just become assignments to 'exports.blah'. - // We only want to emit assignments for variables with initializers. - if (ts.hasModifier(node, 1 /* Export */)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } + var isAsyncBlockContainingAwait = enclosingNonArrowFunction + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 + && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var loopBodyFlags = 0; + if (currentState.containsLexicalThis) { + loopBodyFlags |= 256 /* CapturesThis */; } - else { - resultStatements.push(node); + if (isAsyncBlockContainingAwait) { + loopBodyFlags |= 2097152 /* AsyncFunctionBody */; } - // While we might not have been exported here, each variable might have been exported - // later on in an export specifier (e.g. `export {foo as blah, bar}`). - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); + var convertedLoopVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(functionName, + /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, loopParameters, + /*type*/ undefined, loopBody), loopBodyFlags)) + ])); + var statements = [convertedLoopVariable]; + var extraVariableDeclarations; + // propagate state from the inner loop to the outer loop if necessary + if (currentState.argumentsName) { + // if alias for arguments is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.argumentsName = currentState.argumentsName; + } + else { + // this is top level converted loop and we need to create an alias for 'arguments' object + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, + /*type*/ undefined, ts.createIdentifier("arguments"))); + } } - return resultStatements; - } - /** - * Creates appropriate assignments for each binding identifier that is exported in an export specifier, - * and inserts it into 'resultStatements'. - */ - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } + if (currentState.thisName) { + // if alias for this is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.thisName = currentState.thisName; + } + else { + // this is top level converted loop so we need to create an alias for 'this' here + // NOTE: + // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. + // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, + /*type*/ undefined, ts.createIdentifier("this"))); } } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + if (currentState.hoistedLocalVariables) { + // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later + if (outerConvertedLoopState) { + // pass them to outer converted loop + outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; + } + else { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + // hoist collected variable declarations + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; + extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); } } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); + // add extra variables to hold out parameters if necessary + if (loopOutParameters.length) { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; + extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); + } } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); + // create variable statement to hold all introduced variable declarations + if (extraVariableDeclarations) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var loop; + if (convert) { + loop = convert(node, convertedLoopBodyStatements); } else { - statements.push(node); + loop = ts.getMutableClone(node); + // clean statement part + loop.statement = undefined; + // visit childnodes to transform initializer/condition/incrementor parts + loop = ts.visitEachChild(loop, visitor, context); + // set loop statement + loop.statement = ts.createBlock(convertedLoopBodyStatements, + /*location*/ undefined, + /*multiline*/ true); + // reset and re-aggregate the transform flags + loop.transformFlags = 0; + ts.aggregateTransformFlags(loop); } - if (node.name) { - addExportMemberAssignments(statements, node.name); + statements.push(currentParent.kind === 215 /* LabeledStatement */ + ? ts.createLabel(currentParent.label, loop) + : loop); + return statements; + } + function copyOutParameter(outParam, copyDirection) { + var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; + return ts.createBinary(target, 57 /* EqualsToken */, source); + } + function copyOutParameters(outParams, copyDirection, statements) { + for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { + var outParam = outParams_1[_i]; + statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); } - return ts.singleOrMany(statements); } - function visitClassDeclaration(node) { + function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { + var outerConvertedLoopState = convertedLoopState; var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); + // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop + // simple loops are emitted as just 'loop()'; + // NOTE: if loop uses only 'continue' it still will be emitted as simple loop + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + !state.labeledNonLocalBreaks && + !state.labeledNonLocalContinues; + var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38 /* AsteriskToken */), call) : call; + if (isSimpleLoop) { + statements.push(ts.createStatement(callResult)); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { - statements.push(node); - } - // Decorators end up creating a series of assignment expressions which overwrite - // the local binding that we export, so we need to defer from exporting decorated classes - // until the decoration assignments take place. We do this when visiting expression-statements. - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 224 /* EnumDeclaration */ || origKind === 225 /* ModuleDeclaration */) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 221 /* ClassDeclaration */) { - // The decorated assignment for a class name may need to be transformed. - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; + var loopResultName = ts.createUniqueName("state"); + var stateVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); + statements.push(stateVariable); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Return */) { + var returnStatement = void 0; + if (outerConvertedLoopState) { + outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; + returnStatement = ts.createReturn(loopResultName); + } + else { + returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + } + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + } + if (state.nonLocalJumps & 2 /* Break */) { + statements.push(ts.createIf(ts.createBinary(loopResultName, 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + } + if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { + var caseClauses = []; + processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); + processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); + statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); } } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - // Preserve old behavior for enums in which a variable statement is emitted after the body itself. - if (ts.hasModifier(original, 1 /* Export */) && - original.kind === 224 /* EnumDeclaration */ && - ts.isFirstDeclarationOfKind(original, 224 /* EnumDeclaration */)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); return statements; } - /** - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], - /*location*/ node); - ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = ts.createMap(); + } + state.labeledNonLocalBreaks[labelText] = labelMarker; } else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = ts.createMap(); } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); + state.labeledNonLocalContinues[labelText] = labelMarker; } - return node; } - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 186 /* PostfixUnaryExpression */: - case 185 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); + function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { + if (!table) { + return; } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; + for (var labelText in table) { + var labelMarker = table[labelText]; + var statements = []; + // 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])) { + var label = ts.createIdentifier(labelText); + statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + statements.push(ts.createReturn(loopResultName)); } + caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); } - return node; } - function substituteUnaryExpression(node) { - // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are - // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var transformedUnaryExpression = void 0; - if (node.kind === 186 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node); - // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); + function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { + var name = decl.name; + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + processLoopVariableDeclaration(element, loopParameters, loopOutParameters); } - return nestedExportAssignment; } } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144 /* LocalName */) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); - if (container) { - if (container.kind === 256 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } + else { + loopParameters.push(ts.createParameter(name)); + if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { + var outParamName = ts.createUniqueName("out_" + name.text); + loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } - return undefined; } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - if (languageVersion >= 1 /* ES5 */) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), - /*location*/ node); - } - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - if (name_35.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), - /*location*/ node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), - /*location*/ node); + /** + * Adds the members of an object literal to an array of expressions. + * + * @param expressions An array of expressions. + * @param node An ObjectLiteralExpression node. + * @param receiver The receiver for members of the ObjectLiteralExpression. + * @param numInitialNonComputedProperties The number of initial properties without + * computed property names. + */ + function addObjectLiteralMembers(expressions, node, receiver, start) { + var properties = node.properties; + var numProperties = properties.length; + for (var i = start; i < numProperties; i++) { + var property = properties[i]; + switch (property.kind) { + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property === accessors.firstAccessor) { + expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } - } + break; + case 253 /* PropertyAssignment */: + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 254 /* ShorthandPropertyAssignment */: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 148 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; } } - return undefined; } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, - /*location*/ name); + /** + * Transforms a PropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the PropertyAssignment. + * @param property The PropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); + /** + * Transforms a ShorthandPropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. + * @param property The ShorthandPropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + return expression; } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); + /** + * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. + * + * @param node The ObjectLiteralExpression that contains the MethodDeclaration. + * @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), + /*location*/ method); + if (startsOnNewLine) { + expression.startsOnNewLine = true; } - return statement; + return expression; } - function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion === 0 /* ES3 */ - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + /** + * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a + * PropertyAssignment. + * + * @param node A MethodDeclaration node. + */ + function visitMethodDeclaration(node) { + // We should only get here for methods on an object literal with regular identifier names. + // 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); + ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + return ts.createPropertyAssignment(node.name, functionExpression, + /*location*/ node); } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + /** + * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. + * + * @param node A ShorthandPropertyAssignment node. + */ + function visitShorthandPropertyAssignment(node) { + return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + /*location*/ node); } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; + /** + * Visits a YieldExpression node. + * + * @param node A YieldExpression node. + */ + function visitYieldExpression(node) { + // `yield` expressions are transformed using the generators transformer. + return ts.visitEachChild(node, visitor, context); } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - var entities = createEntitiesMap(); - function transformJsx(context) { - var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; - return transformSourceFile; /** - * Transform JSX-specific syntax in a SourceFile. + * Visits an ArrayLiteralExpression that contains a spread element. * - * @param node A SourceFile node. + * @param node An ArrayLiteralExpression node. */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - node = ts.visitEachChild(node, visitor, context); - currentSourceFile = undefined; - return node; + function visitArrayLiteralExpression(node) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); } - function visitor(node) { - if (node.transformFlags & 4 /* Jsx */) { - return visitorWorker(node); + /** + * Visits a CallExpression that contains either a spread element or `super`. + * + * @param node a CallExpression. + */ + function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { + // We are here either because SuperKeyword was used somewhere in the expression, or + // because we contain a SpreadElementExpression. + var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 96 /* SuperKeyword */) { + ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); } - else if (node.transformFlags & 8 /* ContainsJsx */) { - return ts.visitEachChild(node, visitor, context); + var resultingCall; + if (node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) { + // [source] + // f(...a, b) + // x.m(...a, b) + // super(...a, b) + // super.m(...a, b) // in static + // super.m(...a, b) // in instance + // + // [output] + // f.apply(void 0, a.concat([b])) + // (_a = x).m.apply(_a, a.concat([b])) + // _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)); } else { - return node; + // [source] + // super(a) + // super.m(a) // in static + // super.m(a) // in instance + // + // [output] + // _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), + /*location*/ node); } - } - function visitorWorker(node) { - switch (node.kind) { - case 241 /* JsxElement */: - return visitJsxElement(node, /*isChild*/ false); - case 242 /* JsxSelfClosingElement */: - return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 248 /* JsxExpression */: - return visitJsxExpression(node); - default: - ts.Debug.failBadSyntaxKind(node); - return undefined; + if (node.expression.kind === 96 /* SuperKeyword */) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; } + return resultingCall; } - function transformJsxChildToExpression(node) { - switch (node.kind) { - case 244 /* JsxText */: - return visitJsxText(node); - case 248 /* JsxExpression */: - return visitJsxExpression(node); - case 241 /* JsxElement */: - return visitJsxElement(node, /*isChild*/ true); - case 242 /* JsxSelfClosingElement */: - return visitJsxSelfClosingElement(node, /*isChild*/ true); - default: - ts.Debug.failBadSyntaxKind(node); - return undefined; + /** + * Visits a NewExpression that contains a spread element. + * + * @param node A NewExpression node. + */ + function visitNewExpression(node) { + // We are here because we contain a SpreadElementExpression. + ts.Debug.assert((node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) !== 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, []); + } + /** + * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * + * @param elements The array of Expression nodes. + * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. + * @param multiLine A value indicating whether the result should be emitted on multiple lines. + */ + function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { + // [source] + // [a, ...b, c] + // + // [output] + // [a].concat(b, [c]) + // Map spans of spread expressions into their expressions and spans of other + // expressions into an array literal. + var numElements = elements.length; + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); + })); + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 /* ArrayLiteralExpression */ + ? ts.createArraySlice(segments[0]) + : segments[0]; } + // Rewrite using the pattern .concat(, , ...) + return ts.createArrayConcat(segments.shift(), segments); } - function visitJsxElement(node, isChild) { - return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, /*location*/ node); + function partitionSpreadElement(node) { + return ts.isSpreadElementExpression(node) + ? visitSpanOfSpreadElements + : visitSpanOfNonSpreadElements; } - function visitJsxSelfClosingElement(node, isChild) { - return visitJsxOpeningLikeElement(node, /*children*/ undefined, isChild, /*location*/ node); + function visitSpanOfSpreadElements(chunk) { + return ts.map(chunk, visitExpressionOfSpreadElement); } - function visitJsxOpeningLikeElement(node, children, isChild, location) { - var tagName = getTagName(node); - var objectProperties; - var attrs = node.attributes; - if (attrs.length === 0) { - // When there are no attributes, React wants "null" - objectProperties = ts.createNull(); - } - else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument. - segments.unshift(ts.createObjectLiteral()); - } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments) - || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); - } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); - if (isChild) { - ts.startOnNewLine(element); - } - return element; + function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), + /*location*/ undefined, multiLine); } - function transformJsxSpreadAttributeToExpression(node) { + /** + * Transforms the expression of a SpreadElementExpression node. + * + * @param node A SpreadElementExpression node. + */ + function visitExpressionOfSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } - function transformJsxAttributeToObjectLiteralElement(node) { - var name = getAttributeName(node); - var expression = transformJsxAttributeInitializer(node.initializer); - return ts.createPropertyAssignment(name, expression); + /** + * Visits a template literal. + * + * @param node A template literal. + */ + function visitTemplateLiteral(node) { + return ts.createLiteral(node.text, /*location*/ node); } - function transformJsxAttributeInitializer(node) { - if (node === undefined) { - return ts.createLiteral(true); + /** + * Visits a TaggedTemplateExpression node. + * + * @param node A TaggedTemplateExpression node. + */ + function visitTaggedTemplateExpression(node) { + // Visit the tag expression + var tag = ts.visitNode(node.tag, visitor, ts.isExpression); + // Allocate storage for the template site object + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Build up the template arguments and the raw and cooked strings for the template. + var templateArguments = [temp]; + var cookedStrings = []; + var rawStrings = []; + var template = node.template; + if (ts.isNoSubstitutionTemplateLiteral(template)) { + cookedStrings.push(ts.createLiteral(template.text)); + rawStrings.push(getRawLiteral(template)); } - else if (node.kind === 9 /* StringLiteral */) { - var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + else { + cookedStrings.push(ts.createLiteral(template.head.text)); + rawStrings.push(getRawLiteral(template.head)); + for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { + var templateSpan = _a[_i]; + cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); + rawStrings.push(getRawLiteral(templateSpan.literal)); + templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); + } } - else if (node.kind === 248 /* JsxExpression */) { - return visitJsxExpression(node); + // NOTE: The parentheses here is entirely optional as we are now able to auto- + // parenthesize when rebuilding the tree. This should be removed in a + // future version. It is here for now to match our existing emit. + return ts.createParen(ts.inlineExpressions([ + ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), + ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), + ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) + ])); + } + /** + * Creates an ES5 compatible literal from an ES6 template literal. + * + * @param node The ES6 template literal. + */ + function getRawLiteral(node) { + // Find original source text, since we need to emit the raw strings of the tagged template. + // The raw strings contain the (escaped) strings of what the user wrote. + // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 12 /* NoSubstitutionTemplateLiteral */ || node.kind === 15 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + // Newline normalization: + // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's + // and LineTerminatorSequences are normalized to for both TV and TRV. + text = text.replace(/\r\n?/g, "\n"); + return ts.createLiteral(text, /*location*/ node); + } + /** + * Visits a TemplateExpression node. + * + * @param node A TemplateExpression node. + */ + function visitTemplateExpression(node) { + var expressions = []; + addTemplateHead(expressions, node); + addTemplateSpans(expressions, node); + // createAdd will check if each expression binds less closely than binary '+'. + // If it does, it wraps the expression in parentheses. Otherwise, something like + // `abc${ 1 << 2 }` + // becomes + // "abc" + 1 << 2 + "" + // which is really + // ("abc" + 1) << (2 + "") + // rather than + // "abc" + (1 << 2) + "" + var expression = ts.reduceLeft(expressions, ts.createAdd); + if (ts.nodeIsSynthesized(expression)) { + ts.setTextRange(expression, node); } - else { - ts.Debug.failBadSyntaxKind(node); + return expression; + } + /** + * Gets a value indicating whether we need to include the head of a TemplateExpression. + * + * @param node A TemplateExpression node. + */ + function shouldAddTemplateHead(node) { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // There is always atleast one templateSpan in this code path, since + // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + /** + * Adds the head of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateHead(expressions, node) { + if (!shouldAddTemplateHead(node)) { + return; } + expressions.push(ts.createLiteral(node.head.text)); } - function visitJsxText(node) { - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var parts; - var firstNonWhitespace = 0; - var 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 (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var 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(ts.createLiteral(decodeEntities(part))); - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } + /** + * Visits and adds the template spans of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateSpans(expressions, node) { + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span_6 = _a[_i]; + expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); + // Only emit if the literal is non-empty. + // The binary '+' operator is left-associative, so the first string concatenation + // with the head will force the result up to this point to be a string. + // Emitting a '+ ""' has no semantic effect for middles and tails. + if (span_6.literal.text.length !== 0) { + expressions.push(ts.createLiteral(span_6.literal.text)); } } - if (firstNonWhitespace !== -1) { - var 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(ts.createLiteral(decodeEntities(part))); + } + /** + * Visits the `super` keyword + */ + function visitSuperKeyword() { + return enclosingNonAsyncFunctionBody + && ts.isClassElement(enclosingNonAsyncFunctionBody) + && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) + && currentParent.kind !== 175 /* CallExpression */ + ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") + : ts.createIdentifier("_super"); + } + function visitSourceFileNode(node) { + var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + var statements = []; + startLexicalEnvironment(); + ts.addRange(statements, prologue); + addCaptureThisForNodeIfNeeded(statements, node); + ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); + ts.addRange(statements, endLexicalEnvironment()); + var clone = ts.getMutableClone(node); + clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); + return clone; + } + /** + * 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; + } + previousOnEmitNode(emitContext, node, emitCallback); + enclosingFunction = savedEnclosingFunction; + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains block-scoped bindings (e.g. `let` or `const`). + */ + function enableSubstitutionsForBlockScopedBindings() { + if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* BlockScopedBindings */; + context.enableSubstitution(70 /* Identifier */); } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains a captured `this`. + */ + function enableSubstitutionsForCapturedThis() { + if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* CapturedThis */; + context.enableSubstitution(98 /* ThisKeyword */); + context.enableEmitNotification(149 /* Constructor */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(181 /* ArrowFunction */); + context.enableEmitNotification(180 /* FunctionExpression */); + context.enableEmitNotification(221 /* FunctionDeclaration */); } - return undefined; } /** - * Aggregates two expressions by interpolating them with a whitespace literal. + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. */ - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + if (ts.isIdentifier(node)) { + return substituteIdentifier(node); + } + return node; } /** - * Replace entities like " ", "{", and "�" with the characters they encode. - * See https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references + * Hooks substitutions for non-expression identifiers. */ - function decodeEntities(text) { - return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { - if (decimal) { - return String.fromCharCode(parseInt(decimal, 10)); - } - else if (hex) { - return String.fromCharCode(parseInt(hex, 16)); - } - else { - var ch = entities[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; + function substituteIdentifier(node) { + // Only substitute the identifier if we have enabled substitutions for block-scoped + // bindings. + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var original = ts.getParseTreeNode(node, ts.isIdentifier); + if (original && isNameOfDeclarationWithCollidingName(original)) { + return ts.getGeneratedNameForNode(original); } - }); + } + return node; } - /** Like `decodeEntities` but returns `undefined` if there were no entities to decode. */ - function tryDecodeEntities(text) { - var decoded = decodeEntities(text); - return decoded === text ? undefined : decoded; + /** + * Determines whether a name is the name of a declaration with a colliding name. + * NOTE: This function expects to be called with an original source tree node. + * + * @param node An original source tree node. + */ + function isNameOfDeclarationWithCollidingName(node) { + var parent = node.parent; + switch (parent.kind) { + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + return parent.name === node + && resolver.isDeclarationWithCollidingName(parent); + } + return false; } - function getTagName(node) { - if (node.kind === 241 /* JsxElement */) { - return getTagName(node.openingElement); + /** + * Substitutes an expression. + * + * @param node An Expression node. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 98 /* ThisKeyword */: + return substituteThisKeyword(node); } - else { - 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_36); + return node; + } + /** + * Substitutes an expression identifier. + * + * @param node An Identifier node. + */ + function substituteExpressionIdentifier(node) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); + if (declaration) { + return ts.getGeneratedNameForNode(declaration.name); } } + return node; } /** - * Emit an attribute name, which is quoted if it needs to be quoted. Because - * these emit into an object literal property name, we don't need to be worried - * about keywords, just non-identifier characters + * Substitutes `this` when contained within an arrow function. + * + * @param node The ThisKeyword node. */ - function getAttributeName(node) { - var name = node.name; - if (/^[A-Za-z_]\w*$/.test(name.text)) { - return name; - } - else { - return ts.createLiteral(name.text); + function substituteThisKeyword(node) { + if (enabledSubstitutions & 1 /* CapturedThis */ + && enclosingFunction + && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { + return ts.createIdentifier("_this", /*location*/ node); } + return node; } - function visitJsxExpression(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); + /** + * Gets the local name for a declaration for use in expressions. + * + * A local name will *never* be prefixed with an module or namespace export modifier like + * "exports.". + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node, allowComments, allowSourceMaps) { + return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); } - } - ts.transformJsx = transformJsx; - function createEntitiesMap() { - return ts.createMap({ - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }); - } -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; + /** + * Gets the name of a declaration, without source map or comments. + * + * @param node The declaration. + * @param allowComments Allow comments for the name. + */ + function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && !ts.isGeneratedIdentifier(node.name)) { + var name_33 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= 1536 /* NoSourceMap */; + } + if (!allowComments) { + emitFlags |= 49152 /* NoComments */; + } + if (emitFlags) { + ts.setEmitFlags(name_33, emitFlags); + } + return name_33; } - return ts.visitEachChild(node, visitor, context); + return ts.getGeneratedNameForNode(node); } - function visitor(node) { - if (node.transformFlags & 16 /* ES7 */) { - return visitorWorker(node); - } - else if (node.transformFlags & 32 /* ContainsES7 */) { - return ts.visitEachChild(node, visitor, context); + function getClassMemberPrefix(node, member) { + var expression = getLocalName(node); + return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + } + function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { + if (!constructor || !hasExtendsClause) { + return false; } - else { - return node; + var parameter = ts.singleOrUndefined(constructor.parameters); + if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + return false; } - } - function visitorWorker(node) { - switch (node.kind) { - case 187 /* BinaryExpression */: - return visitBinaryExpression(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + var statement = ts.firstOrUndefined(constructor.body.statements); + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203 /* ExpressionStatement */) { + return false; } - } - function visitBinaryExpression(node) { - // We are here because ES7 adds support for the exponentiation operator. - var left = ts.visitNode(node.left, visitor, ts.isExpression); - var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - var target = void 0; - var value = void 0; - if (ts.isElementAccessExpression(left)) { - // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), - /*location*/ left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, - /*location*/ left); - } - else if (ts.isPropertyAccessExpression(left)) { - // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, - /*location*/ left); - value = ts.createPropertyAccess(expressionTemp, left.name, - /*location*/ left); - } - else { - // Transforms `a **= b` into `a = Math.pow(a, b)` - target = left; - value = left; - } - return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + var statementExpression = statement.expression; + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + return false; } - else if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */) { - // Transforms `a ** b` into `Math.pow(a, b)` - return ts.createMathPow(left, right, /*location*/ node); + var callTarget = statementExpression.expression; + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96 /* SuperKeyword */) { + return false; } - else { - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + var callArgument = ts.singleOrUndefined(statementExpression.arguments); + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192 /* SpreadElementExpression */) { + return false; } + var expression = callArgument.expression; + return ts.isIdentifier(expression) && expression === parameter.name; } } - ts.transformES7 = transformES7; + ts.transformES2015 = transformES2015; })(ts || (ts = {})); /// /// @@ -48214,7 +49378,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024 /* ContainsGenerator */) { + if (node.transformFlags & 4096 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -48234,10 +49398,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512 /* Generator */) { + else if (transformFlags & 2048 /* Generator */) { return visitGenerator(node); } - else if (transformFlags & 1024 /* ContainsGenerator */) { + else if (transformFlags & 4096 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -48251,13 +49415,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitWhileStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -48270,30 +49434,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return visitAccessorDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitVariableStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitForInStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return visitBreakStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return visitContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 /* ContainsGenerator */ | 8388608 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (4096 /* ContainsGenerator */ | 33554432 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -48308,21 +49472,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitConditionalExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitYieldExpression(node); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return visitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48335,9 +49499,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -48396,6 +49560,7 @@ var ts; // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, node.parameters, /*type*/ undefined, transformGeneratorFunctionBody(node.body), @@ -48497,7 +49662,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -48536,23 +49701,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 /* FirstCompoundAssignment */ - && kind <= 68 /* LastCompoundAssignment */; + return kind >= 58 /* FirstCompoundAssignment */ + && kind <= 69 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57 /* PlusEqualsToken */: return 35 /* PlusToken */; - case 58 /* MinusEqualsToken */: return 36 /* MinusToken */; - case 59 /* AsteriskEqualsToken */: return 37 /* AsteriskToken */; - case 60 /* AsteriskAsteriskEqualsToken */: return 38 /* AsteriskAsteriskToken */; - case 61 /* SlashEqualsToken */: return 39 /* SlashToken */; - case 62 /* PercentEqualsToken */: return 40 /* PercentToken */; - case 63 /* LessThanLessThanEqualsToken */: return 43 /* LessThanLessThanToken */; - case 64 /* GreaterThanGreaterThanEqualsToken */: return 44 /* GreaterThanGreaterThanToken */; - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanGreaterThanToken */; - case 66 /* AmpersandEqualsToken */: return 46 /* AmpersandToken */; - case 67 /* BarEqualsToken */: return 47 /* BarToken */; - case 68 /* CaretEqualsToken */: return 48 /* CaretToken */; + case 58 /* PlusEqualsToken */: return 36 /* PlusToken */; + case 59 /* MinusEqualsToken */: return 37 /* MinusToken */; + case 60 /* AsteriskEqualsToken */: return 38 /* AsteriskToken */; + case 61 /* AsteriskAsteriskEqualsToken */: return 39 /* AsteriskAsteriskToken */; + case 62 /* SlashEqualsToken */: return 40 /* SlashToken */; + case 63 /* PercentEqualsToken */: return 41 /* PercentToken */; + case 64 /* LessThanLessThanEqualsToken */: return 44 /* LessThanLessThanToken */; + case 65 /* GreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanToken */; + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanGreaterThanToken */; + case 67 /* AmpersandEqualsToken */: return 47 /* AmpersandToken */; + case 68 /* BarEqualsToken */: return 48 /* BarToken */; + case 69 /* CaretEqualsToken */: return 49 /* CaretToken */; } } /** @@ -48565,7 +49730,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -48577,7 +49742,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -48596,7 +49761,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -48609,7 +49774,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24 /* CommaToken */) { + else if (node.operatorToken.kind === 25 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -48620,10 +49785,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - 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; + var clone_6 = ts.getMutableClone(node); + clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -48664,7 +49829,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -48695,7 +49860,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -48785,7 +49950,7 @@ var ts; * @param elements The elements to visit. * @param multiLine Whether array literals created should be emitted on multiple lines. */ - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { // [source] // ar = [1, yield, 2]; // @@ -48877,10 +50042,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - 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; + var clone_7 = ts.getMutableClone(node); + clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_7; } return ts.visitEachChild(node, visitor, context); } @@ -48897,7 +50062,7 @@ var ts; // .mark resumeLabel // _b.apply(_a, _c.concat([%sent%, 2])); var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, /*cacheIdentifiers*/ true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false), + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); @@ -48915,7 +50080,7 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false)), + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), /*typeArguments*/ undefined, [], /*location*/ node), node); } @@ -48946,35 +50111,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199 /* Block */: + case 200 /* Block */: return transformAndEmitBlock(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return transformAndEmitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return transformAndEmitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return transformAndEmitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return transformAndEmitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -49538,7 +50703,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304 /* ContainsYield */) !== 0; + return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -49568,12 +50733,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_7 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_7, node); - ts.setCommentRange(clone_7, node); - return clone_7; + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); + return clone_8; } } } @@ -49626,3222 +50791,2468 @@ var ts; blockActions = []; blockOffsets = []; blockStack = []; - } - var index = blockActions.length; - blockActions[index] = 0 /* Open */; - blockOffsets[index] = operations ? operations.length : 0; - blocks[index] = block; - blockStack.push(block); - return index; - } - /** - * Ends the current block operation. - */ - function endBlock() { - var block = peekBlock(); - ts.Debug.assert(block !== undefined, "beginBlock was never called."); - var index = blockActions.length; - blockActions[index] = 1 /* Close */; - blockOffsets[index] = operations ? operations.length : 0; - blocks[index] = block; - blockStack.pop(); - return block; - } - /** - * Gets the current open block. - */ - function peekBlock() { - return ts.lastOrUndefined(blockStack); - } - /** - * Gets the kind of the current open block. - */ - function peekBlockKind() { - var block = peekBlock(); - return block && block.kind; - } - /** - * Begins a code block for a generated `with` statement. - * - * @param expression An identifier representing expression for the `with` block. - */ - function beginWithBlock(expression) { - var startLabel = defineLabel(); - var endLabel = defineLabel(); - markLabel(startLabel); - beginBlock({ - kind: 1 /* With */, - expression: expression, - startLabel: startLabel, - endLabel: endLabel - }); - } - /** - * Ends a code block for a generated `with` statement. - */ - function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); - var block = endBlock(); - markLabel(block.endLabel); - } - function isWithBlock(block) { - return block.kind === 1 /* With */; - } - /** - * Begins a code block for a generated `try` statement. - */ - function beginExceptionBlock() { - var startLabel = defineLabel(); - var endLabel = defineLabel(); - markLabel(startLabel); - beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, - startLabel: startLabel, - endLabel: endLabel - }); - emitNop(); - return endLabel; - } - /** - * Enters the `catch` clause of a generated `try` statement. - * - * @param variable The catch variable. - */ - function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var text = variable.name.text; - var name = declareLocal(text); - if (!renamedCatchVariables) { - renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69 /* Identifier */); - } - renamedCatchVariables[text] = true; - renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; - var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); - var endLabel = exception.endLabel; - emitBreak(endLabel); - var catchLabel = defineLabel(); - markLabel(catchLabel); - exception.state = 1 /* Catch */; - exception.catchVariable = name; - exception.catchLabel = catchLabel; - emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [])); - emitNop(); - } - /** - * Enters the `finally` block of a generated `try` statement. - */ - function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); - var endLabel = exception.endLabel; - emitBreak(endLabel); - var finallyLabel = defineLabel(); - markLabel(finallyLabel); - exception.state = 2 /* Finally */; - exception.finallyLabel = finallyLabel; - } - /** - * Ends the code block for a generated `try` statement. - */ - function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var exception = endBlock(); - var state = exception.state; - if (state < 2 /* Finally */) { - emitBreak(exception.endLabel); - } - else { - emitEndfinally(); - } - markLabel(exception.endLabel); - emitNop(); - exception.state = 3 /* Done */; - } - function isExceptionBlock(block) { - return block.kind === 0 /* Exception */; - } - /** - * Begins a code block that supports `break` or `continue` statements that are defined in - * the source tree and not from generated code. - * - * @param labelText Names from containing labeled statements. - */ - function beginScriptLoopBlock() { - beginBlock({ - kind: 3 /* Loop */, - isScript: true, - breakLabel: -1, - continueLabel: -1 - }); - } - /** - * Begins a code block that supports `break` or `continue` statements that are defined in - * generated code. Returns a label used to mark the operation to which to jump when a - * `break` statement targets this block. - * - * @param continueLabel A Label used to mark the operation to which to jump when a - * `continue` statement targets this block. - */ - function beginLoopBlock(continueLabel) { - var breakLabel = defineLabel(); - beginBlock({ - kind: 3 /* Loop */, - isScript: false, - breakLabel: breakLabel, - continueLabel: continueLabel - }); - return breakLabel; - } - /** - * Ends a code block that supports `break` or `continue` statements that are defined in - * generated code or in the source tree. - */ - function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); - var block = endBlock(); - var breakLabel = block.breakLabel; - if (!block.isScript) { - markLabel(breakLabel); - } - } - /** - * Begins a code block that supports `break` statements that are defined in the source - * tree and not from generated code. - * - */ - function beginScriptSwitchBlock() { - beginBlock({ - kind: 2 /* Switch */, - isScript: true, - breakLabel: -1 - }); - } - /** - * Begins a code block that supports `break` statements that are defined in generated code. - * Returns a label used to mark the operation to which to jump when a `break` statement - * targets this block. - */ - function beginSwitchBlock() { - var breakLabel = defineLabel(); - beginBlock({ - kind: 2 /* Switch */, - isScript: false, - breakLabel: breakLabel - }); - return breakLabel; - } - /** - * Ends a code block that supports `break` statements that are defined in generated code. - */ - function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); - var block = endBlock(); - var breakLabel = block.breakLabel; - if (!block.isScript) { - markLabel(breakLabel); - } - } - function beginScriptLabeledBlock(labelText) { - beginBlock({ - kind: 4 /* Labeled */, - isScript: true, - labelText: labelText, - breakLabel: -1 - }); - } - function beginLabeledBlock(labelText) { - var breakLabel = defineLabel(); - beginBlock({ - kind: 4 /* Labeled */, - isScript: false, - labelText: labelText, - breakLabel: breakLabel - }); - } - function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); - var block = endBlock(); - if (!block.isScript) { - markLabel(block.breakLabel); - } - } - /** - * Indicates whether the provided block supports `break` statements. - * - * @param block A code block. - */ - function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; - } - /** - * Indicates whether the provided block supports `break` statements with labels. - * - * @param block A code block. - */ - function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; - } - /** - * Indicates whether the provided block supports `continue` statements. - * - * @param block A code block. - */ - function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; - } - function hasImmediateContainingLabeledBlock(labelText, start) { - for (var j = start; j >= 0; j--) { - var containingBlock = blockStack[j]; - if (supportsLabeledBreakOrContinue(containingBlock)) { - if (containingBlock.labelText === labelText) { - return true; - } - } - else { - break; - } - } - return false; - } - /** - * Finds the label that is the target for a `break` statement. - * - * @param labelText An optional name of a containing labeled statement. - */ - function findBreakTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; - } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; - } - } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; - } - } - } - return 0; - } - /** - * Finds the label that is the target for a `continue` statement. - * - * @param labelText An optional name of a containing labeled statement. - */ - function findContinueTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; - } - } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; - } - } - } - return 0; - } - /** - * Creates an expression that can be used to indicate the value for a label. - * - * @param label A label. - */ - function createLabel(label) { - if (label > 0) { - if (labelExpressions === undefined) { - labelExpressions = []; - } - var expression = ts.createSynthesizedNode(8 /* NumericLiteral */); - if (labelExpressions[label] === undefined) { - labelExpressions[label] = [expression]; - } - else { - labelExpressions[label].push(expression); - } - return expression; - } - return ts.createNode(193 /* OmittedExpression */); - } - /** - * Creates a numeric literal for the provided instruction. - */ - function createInstruction(instruction) { - var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; - return literal; - } - /** - * Creates a statement that can be used indicate a Break operation to the provided label. - * - * @param label A label. - * @param location An optional source map location for the statement. - */ - function createInlineBreak(label, location) { - ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ - createInstruction(3 /* Break */), - createLabel(label) - ]), location); - } - /** - * Creates a statement that can be used indicate a Return operation. - * - * @param expression The expression for the return statement. - * @param location An optional source map location for the statement. - */ - function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), location); - } - /** - * Creates an expression that can be used to resume from a Yield operation. - */ - function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); - } - /** - * Emits an empty instruction. - */ - function emitNop() { - emitWorker(0 /* Nop */); - } - /** - * Emits a Statement. - * - * @param node A statement. - */ - function emitStatement(node) { - if (node) { - emitWorker(1 /* Statement */, [node]); - } - else { - emitNop(); - } - } - /** - * Emits an Assignment operation. - * - * @param left The left-hand side of the assignment. - * @param right The right-hand side of the assignment. - * @param location An optional source map location for the assignment. - */ - function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); - } - /** - * Emits a Break operation to the specified label. - * - * @param label A label. - * @param location An optional source map location for the assignment. - */ - function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); - } - /** - * Emits a Break operation to the specified label when a condition evaluates to a truthy - * value at runtime. - * - * @param label A label. - * @param condition The condition. - * @param location An optional source map location for the assignment. - */ - function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + } + var index = blockActions.length; + blockActions[index] = 0 /* Open */; + blockOffsets[index] = operations ? operations.length : 0; + blocks[index] = block; + blockStack.push(block); + return index; } /** - * Emits a Break to the specified label when a condition evaluates to a falsey value at - * runtime. - * - * @param label A label. - * @param condition The condition. - * @param location An optional source map location for the assignment. + * Ends the current block operation. */ - function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + function endBlock() { + var block = peekBlock(); + ts.Debug.assert(block !== undefined, "beginBlock was never called."); + var index = blockActions.length; + blockActions[index] = 1 /* Close */; + blockOffsets[index] = operations ? operations.length : 0; + blocks[index] = block; + blockStack.pop(); + return block; } /** - * Emits a YieldStar operation for the provided expression. - * - * @param expression An optional value for the yield operation. - * @param location An optional source map location for the assignment. + * Gets the current open block. */ - function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + function peekBlock() { + return ts.lastOrUndefined(blockStack); } /** - * Emits a Yield operation for the provided expression. - * - * @param expression An optional value for the yield operation. - * @param location An optional source map location for the assignment. + * Gets the kind of the current open block. */ - function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + function peekBlockKind() { + var block = peekBlock(); + return block && block.kind; } /** - * Emits a Return operation for the provided expression. + * Begins a code block for a generated `with` statement. * - * @param expression An optional value for the operation. - * @param location An optional source map location for the assignment. + * @param expression An identifier representing expression for the `with` block. */ - function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + function beginWithBlock(expression) { + var startLabel = defineLabel(); + var endLabel = defineLabel(); + markLabel(startLabel); + beginBlock({ + kind: 1 /* With */, + expression: expression, + startLabel: startLabel, + endLabel: endLabel + }); } /** - * Emits a Throw operation for the provided expression. - * - * @param expression A value for the operation. - * @param location An optional source map location for the assignment. + * Ends a code block for a generated `with` statement. */ - function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + function endWithBlock() { + ts.Debug.assert(peekBlockKind() === 1 /* With */); + var block = endBlock(); + markLabel(block.endLabel); + } + function isWithBlock(block) { + return block.kind === 1 /* With */; } /** - * Emits an Endfinally operation. This is used to handle `finally` block semantics. + * Begins a code block for a generated `try` statement. */ - function emitEndfinally() { - emitWorker(10 /* Endfinally */); + function beginExceptionBlock() { + var startLabel = defineLabel(); + var endLabel = defineLabel(); + markLabel(startLabel); + beginBlock({ + kind: 0 /* Exception */, + state: 0 /* Try */, + startLabel: startLabel, + endLabel: endLabel + }); + emitNop(); + return endLabel; } /** - * Emits an operation. + * Enters the `catch` clause of a generated `try` statement. * - * @param code The OpCode for the operation. - * @param args The optional arguments for the operation. + * @param variable The catch variable. */ - function emitWorker(code, args, location) { - if (operations === undefined) { - operations = []; - operationArguments = []; - operationLocations = []; - } - if (labelOffsets === undefined) { - // mark entry point - markLabel(defineLabel()); + function beginCatchBlock(variable) { + ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + var text = variable.name.text; + var name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = ts.createMap(); + renamedCatchVariableDeclarations = ts.createMap(); + context.enableSubstitution(70 /* Identifier */); } - var operationIndex = operations.length; - operations[operationIndex] = code; - operationArguments[operationIndex] = args; - operationLocations[operationIndex] = location; + renamedCatchVariables[text] = true; + renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; + var exception = peekBlock(); + ts.Debug.assert(exception.state < 1 /* Catch */); + var endLabel = exception.endLabel; + emitBreak(endLabel); + var catchLabel = defineLabel(); + markLabel(catchLabel); + exception.state = 1 /* Catch */; + exception.catchVariable = name; + exception.catchLabel = catchLabel; + emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [])); + emitNop(); } /** - * Builds the generator function body. + * Enters the `finally` block of a generated `try` statement. */ - function build() { - blockIndex = 0; - labelNumber = 0; - labelNumbers = undefined; - lastOperationWasAbrupt = false; - lastOperationWasCompletion = false; - clauses = undefined; - statements = undefined; - exceptionBlockStack = undefined; - currentExceptionBlock = undefined; - withBlockStack = undefined; - var buildResult = buildStatements(); - return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), - /*typeArguments*/ undefined, [ - ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(state)], - /*type*/ undefined, ts.createBlock(buildResult, - /*location*/ undefined, - /*multiLine*/ buildResult.length > 0)), 4194304 /* ReuseTempVariableScope */) - ]); + function beginFinallyBlock() { + ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + var exception = peekBlock(); + ts.Debug.assert(exception.state < 2 /* Finally */); + var endLabel = exception.endLabel; + emitBreak(endLabel); + var finallyLabel = defineLabel(); + markLabel(finallyLabel); + exception.state = 2 /* Finally */; + exception.finallyLabel = finallyLabel; } /** - * Builds the statements for the generator function body. + * Ends the code block for a generated `try` statement. */ - function buildStatements() { - if (operations) { - for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) { - writeOperation(operationIndex); - } - flushFinalLabel(operations.length); + function endExceptionBlock() { + ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + var exception = endBlock(); + var state = exception.state; + if (state < 2 /* Finally */) { + emitBreak(exception.endLabel); } else { - flushFinalLabel(0); - } - if (clauses) { - var labelExpression = ts.createPropertyAccess(state, "label"); - var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses)); - switchStatement.startsOnNewLine = true; - return [switchStatement]; - } - if (statements) { - return statements; + emitEndfinally(); } - return []; + markLabel(exception.endLabel); + emitNop(); + exception.state = 3 /* Done */; + } + function isExceptionBlock(block) { + return block.kind === 0 /* Exception */; } /** - * Flush the current label and advance to a new label. + * Begins a code block that supports `break` or `continue` statements that are defined in + * the source tree and not from generated code. + * + * @param labelText Names from containing labeled statements. */ - function flushLabel() { - if (!statements) { - return; - } - appendLabel(/*markLabelEnd*/ !lastOperationWasAbrupt); - lastOperationWasAbrupt = false; - lastOperationWasCompletion = false; - labelNumber++; + function beginScriptLoopBlock() { + beginBlock({ + kind: 3 /* Loop */, + isScript: true, + breakLabel: -1, + continueLabel: -1 + }); } /** - * Flush the final label of the generator function body. + * Begins a code block that supports `break` or `continue` statements that are defined in + * generated code. Returns a label used to mark the operation to which to jump when a + * `break` statement targets this block. + * + * @param continueLabel A Label used to mark the operation to which to jump when a + * `continue` statement targets this block. */ - function flushFinalLabel(operationIndex) { - if (isFinalLabelReachable(operationIndex)) { - tryEnterLabel(operationIndex); - withBlockStack = undefined; - writeReturn(/*expression*/ undefined, /*operationLocation*/ undefined); - } - if (statements && clauses) { - appendLabel(/*markLabelEnd*/ false); - } - updateLabelExpressions(); + function beginLoopBlock(continueLabel) { + var breakLabel = defineLabel(); + beginBlock({ + kind: 3 /* Loop */, + isScript: false, + breakLabel: breakLabel, + continueLabel: continueLabel + }); + return breakLabel; } /** - * Tests whether the final label of the generator function body - * is reachable by user code. + * Ends a code block that supports `break` or `continue` statements that are defined in + * generated code or in the source tree. */ - function isFinalLabelReachable(operationIndex) { - // if the last operation was *not* a completion (return/throw) then - // the final label is reachable. - if (!lastOperationWasCompletion) { - return true; - } - // if there are no labels defined or referenced, then the final label is - // not reachable. - if (!labelOffsets || !labelExpressions) { - return false; - } - // if the label for this offset is referenced, then the final label - // is reachable. - for (var label = 0; label < labelOffsets.length; label++) { - if (labelOffsets[label] === operationIndex && labelExpressions[label]) { - return true; - } + function endLoopBlock() { + ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + var block = endBlock(); + var breakLabel = block.breakLabel; + if (!block.isScript) { + markLabel(breakLabel); } - return false; } /** - * Appends a case clause for the last label and sets the new label. + * Begins a code block that supports `break` statements that are defined in the source + * tree and not from generated code. * - * @param markLabelEnd Indicates that the transition between labels was a fall-through - * from a previous case clause and the change in labels should be - * reflected on the `state` object. */ - function appendLabel(markLabelEnd) { - if (!clauses) { - clauses = []; - } - if (statements) { - if (withBlockStack) { - // The previous label was nested inside one or more `with` blocks, so we - // surround the statements in generated `with` blocks to create the same environment. - for (var i = withBlockStack.length - 1; i >= 0; i--) { - var withBlock = withBlockStack[i]; - statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))]; - } - } - if (currentExceptionBlock) { - // The previous label was nested inside of an exception block, so we must - // indicate entry into a protected region by pushing the label numbers - // for each block in the protected region. - var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), - /*typeArguments*/ undefined, [ - ts.createArrayLiteral([ - createLabel(startLabel), - createLabel(catchLabel), - createLabel(finallyLabel), - createLabel(endLabel) - ]) - ]))); - currentExceptionBlock = undefined; - } - if (markLabelEnd) { - // The case clause for the last label falls through to this label, so we - // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); - } - } - clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); - statements = undefined; + function beginScriptSwitchBlock() { + beginBlock({ + kind: 2 /* Switch */, + isScript: true, + breakLabel: -1 + }); } /** - * Tries to enter into a new label at the current operation index. + * Begins a code block that supports `break` statements that are defined in generated code. + * Returns a label used to mark the operation to which to jump when a `break` statement + * targets this block. */ - function tryEnterLabel(operationIndex) { - if (!labelOffsets) { - return; - } - for (var label = 0; label < labelOffsets.length; label++) { - if (labelOffsets[label] === operationIndex) { - flushLabel(); - if (labelNumbers === undefined) { - labelNumbers = []; - } - if (labelNumbers[labelNumber] === undefined) { - labelNumbers[labelNumber] = [label]; - } - else { - labelNumbers[labelNumber].push(label); - } - } - } + function beginSwitchBlock() { + var breakLabel = defineLabel(); + beginBlock({ + kind: 2 /* Switch */, + isScript: false, + breakLabel: breakLabel + }); + return breakLabel; } /** - * Updates literal expressions for labels with actual label numbers. + * Ends a code block that supports `break` statements that are defined in generated code. */ - function updateLabelExpressions() { - if (labelExpressions !== undefined && labelNumbers !== undefined) { - for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) { - var labels = labelNumbers[labelNumber_1]; - if (labels !== undefined) { - for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) { - var label = labels_1[_i]; - var expressions = labelExpressions[label]; - if (expressions !== undefined) { - for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) { - var expression = expressions_1[_a]; - expression.text = String(labelNumber_1); - } - } - } - } - } + function endSwitchBlock() { + ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + var block = endBlock(); + var breakLabel = block.breakLabel; + if (!block.isScript) { + markLabel(breakLabel); } } - /** - * Tries to enter or leave a code block. - */ - function tryEnterOrLeaveBlock(operationIndex) { - if (blocks) { - for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { - var block = blocks[blockIndex]; - var blockAction = blockActions[blockIndex]; - if (isExceptionBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!exceptionBlockStack) { - exceptionBlockStack = []; - } - if (!statements) { - statements = []; - } - exceptionBlockStack.push(currentExceptionBlock); - currentExceptionBlock = block; - } - else if (blockAction === 1 /* Close */) { - currentExceptionBlock = exceptionBlockStack.pop(); - } - } - else if (isWithBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!withBlockStack) { - withBlockStack = []; - } - withBlockStack.push(block); - } - else if (blockAction === 1 /* Close */) { - withBlockStack.pop(); - } - } - } + function beginScriptLabeledBlock(labelText) { + beginBlock({ + kind: 4 /* Labeled */, + isScript: true, + labelText: labelText, + breakLabel: -1 + }); + } + function beginLabeledBlock(labelText) { + var breakLabel = defineLabel(); + beginBlock({ + kind: 4 /* Labeled */, + isScript: false, + labelText: labelText, + breakLabel: breakLabel + }); + } + function endLabeledBlock() { + ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + var block = endBlock(); + if (!block.isScript) { + markLabel(block.breakLabel); } } /** - * Writes an operation as a statement to the current label's statement list. + * Indicates whether the provided block supports `break` statements. * - * @param operation The OpCode of the operation + * @param block A code block. */ - function writeOperation(operationIndex) { - tryEnterLabel(operationIndex); - tryEnterOrLeaveBlock(operationIndex); - // early termination, nothing else to process in this label - if (lastOperationWasAbrupt) { - return; - } - lastOperationWasAbrupt = false; - lastOperationWasCompletion = false; - var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { - return; - } - else if (opcode === 10 /* Endfinally */) { - return writeEndfinally(); - } - var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { - return writeStatement(args[0]); - } - var location = operationLocations[operationIndex]; - switch (opcode) { - case 2 /* Assign */: - return writeAssign(args[0], args[1], location); - case 3 /* Break */: - return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: - return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: - return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: - return writeYield(args[0], location); - case 7 /* YieldStar */: - return writeYieldStar(args[0], location); - case 8 /* Return */: - return writeReturn(args[0], location); - case 9 /* Throw */: - return writeThrow(args[0], location); - } + function supportsUnlabeledBreak(block) { + return block.kind === 2 /* Switch */ + || block.kind === 3 /* Loop */; } /** - * Writes a statement to the current label's statement list. + * Indicates whether the provided block supports `break` statements with labels. * - * @param statement A statement to write. + * @param block A code block. */ - function writeStatement(statement) { - if (statement) { - if (!statements) { - statements = [statement]; - } - else { - statements.push(statement); - } - } + function supportsLabeledBreakOrContinue(block) { + return block.kind === 4 /* Labeled */; } /** - * Writes an Assign operation to the current label's statement list. + * Indicates whether the provided block supports `continue` statements. * - * @param left The left-hand side of the assignment. - * @param right The right-hand side of the assignment. - * @param operationLocation The source map location for the operation. + * @param block A code block. */ - function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + function supportsUnlabeledContinue(block) { + return block.kind === 3 /* Loop */; + } + function hasImmediateContainingLabeledBlock(labelText, start) { + for (var j = start; j >= 0; j--) { + var containingBlock = blockStack[j]; + if (supportsLabeledBreakOrContinue(containingBlock)) { + if (containingBlock.labelText === labelText) { + return true; + } + } + else { + break; + } + } + return false; } /** - * Writes a Throw operation to the current label's statement list. + * Finds the label that is the target for a `break` statement. * - * @param expression The value to throw. - * @param operationLocation The source map location for the operation. + * @param labelText An optional name of a containing labeled statement. */ - function writeThrow(expression, operationLocation) { - lastOperationWasAbrupt = true; - lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + function findBreakTarget(labelText) { + ts.Debug.assert(blocks !== undefined); + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } + } + } + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } + } + } + return 0; } /** - * Writes a Return operation to the current label's statement list. + * Finds the label that is the target for a `continue` statement. * - * @param expression The value to return. - * @param operationLocation The source map location for the operation. + * @param labelText An optional name of a containing labeled statement. */ - function writeReturn(expression, operationLocation) { - lastOperationWasAbrupt = true; - lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + function findContinueTarget(labelText) { + ts.Debug.assert(blocks !== undefined); + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } + } + } + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } + } + } + return 0; } /** - * Writes a Break operation to the current label's statement list. + * Creates an expression that can be used to indicate the value for a label. * - * @param label The label for the Break. - * @param operationLocation The source map location for the operation. + * @param label A label. */ - function writeBreak(label, operationLocation) { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ - createInstruction(3 /* Break */), - createLabel(label) - ]), operationLocation)); + function createLabel(label) { + if (label > 0) { + if (labelExpressions === undefined) { + labelExpressions = []; + } + var expression = ts.createSynthesizedNode(8 /* NumericLiteral */); + if (labelExpressions[label] === undefined) { + labelExpressions[label] = [expression]; + } + else { + labelExpressions[label].push(expression); + } + return expression; + } + return ts.createNode(194 /* OmittedExpression */); } /** - * Writes a BreakWhenTrue operation to the current label's statement list. - * - * @param label The label for the Break. - * @param condition The condition for the Break. - * @param operationLocation The source map location for the operation. + * Creates a numeric literal for the provided instruction. */ - function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ - createInstruction(3 /* Break */), - createLabel(label) - ]), operationLocation))); + function createInstruction(instruction) { + var literal = ts.createLiteral(instruction); + literal.trailingComment = instructionNames[instruction]; + return literal; } /** - * Writes a BreakWhenFalse operation to the current label's statement list. + * Creates a statement that can be used indicate a Break operation to the provided label. * - * @param label The label for the Break. - * @param condition The condition for the Break. - * @param operationLocation The source map location for the operation. + * @param label A label. + * @param location An optional source map location for the statement. */ - function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + function createInlineBreak(label, location) { + ts.Debug.assert(label > 0, "Invalid label: " + label); + return ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), location); } /** - * Writes a Yield operation to the current label's statement list. + * Creates a statement that can be used indicate a Return operation. * - * @param expression The expression to yield. - * @param operationLocation The source map location for the operation. + * @param expression The expression for the return statement. + * @param location An optional source map location for the statement. */ - function writeYield(expression, operationLocation) { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + function createInlineReturn(expression, location) { + return ts.createReturn(ts.createArrayLiteral(expression + ? [createInstruction(2 /* Return */), expression] + : [createInstruction(2 /* Return */)]), location); } /** - * Writes a YieldStar instruction to the current label's statement list. - * - * @param expression The expression to yield. - * @param operationLocation The source map location for the operation. + * Creates an expression that can be used to resume from a Yield operation. */ - function writeYieldStar(expression, operationLocation) { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ - createInstruction(5 /* YieldStar */), - expression - ]), operationLocation)); + function createGeneratorResume(location) { + return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); } /** - * Writes an Endfinally instruction to the current label's statement list. + * Emits an empty instruction. */ - function writeEndfinally() { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ - createInstruction(7 /* Endfinally */) - ]))); + function emitNop() { + emitWorker(0 /* Nop */); } - } - ts.transformGenerators = transformGenerators; - var _a; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - var ES6SubstitutionFlags; - (function (ES6SubstitutionFlags) { - /** Enables substitutions for captured `this` */ - ES6SubstitutionFlags[ES6SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; - /** Enables substitutions for block-scoped bindings. */ - ES6SubstitutionFlags[ES6SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; - })(ES6SubstitutionFlags || (ES6SubstitutionFlags = {})); - var CopyDirection; - (function (CopyDirection) { - CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; - CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; - })(CopyDirection || (CopyDirection = {})); - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); - var SuperCaptureResult; - (function (SuperCaptureResult) { - /** - * A capture may have been added for calls to 'super', but - * the caller should emit subsequent statements normally. - */ - SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; - /** - * A call to 'super()' got replaced with a capturing statement like: - * - * var _this = _super.call(...) || this; - * - * Callers should skip the current statement. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; /** - * A call to 'super()' got replaced with a capturing statement like: - * - * return _super.call(...) || this; + * Emits a Statement. * - * Callers should skip the current statement and avoid any returns of '_this'. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; - })(SuperCaptureResult || (SuperCaptureResult = {})); - function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var resolver = context.getEmitResolver(); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; - context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; - var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - /** - * Used to track if we are emitting body of the converted loop - */ - var convertedLoopState; - /** - * Keeps track of whether substitutions have been enabled for specific cases. - * They are persisted between each SourceFile transformation and should not - * be reset. + * @param node A statement. */ - var enabledSubstitutions; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - currentText = node.text; - return ts.visitNode(node, visitor, ts.isSourceFile); - } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); - } - 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; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES6 */) !== 0 || - node.kind === 214 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); - } - function visitorWorker(node) { - if (shouldCheckNode(node)) { - return visitJavaScript(node); - } - else if (node.transformFlags & 128 /* ContainsES6 */) { - return ts.visitEachChild(node, visitor, context); - } - else { - return node; - } - } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function emitStatement(node) { + if (node) { + emitWorker(1 /* Statement */, [node]); } else { - result = visitNodesInConvertedLoop(node); - } - return result; - } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 211 /* ReturnStatement */: - return visitReturnStatement(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 97 /* ThisKeyword */: - return visitThisKeyword(node); - case 69 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitJavaScript(node) { - switch (node.kind) { - case 82 /* ExportKeyword */: - return node; - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 192 /* ClassExpression */: - return visitClassExpression(node); - case 142 /* Parameter */: - return visitParameter(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 180 /* ArrowFunction */: - return visitArrowFunction(node); - case 179 /* FunctionExpression */: - return visitFunctionExpression(node); - case 218 /* VariableDeclaration */: - return visitVariableDeclaration(node); - case 69 /* Identifier */: - return visitIdentifier(node); - case 219 /* VariableDeclarationList */: - return visitVariableDeclarationList(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 206 /* ForStatement */: - return visitForStatement(node); - case 207 /* ForInStatement */: - return visitForInStatement(node); - case 208 /* ForOfStatement */: - return visitForOfStatement(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - case 171 /* ObjectLiteralExpression */: - return visitObjectLiteralExpression(node); - case 254 /* ShorthandPropertyAssignment */: - return visitShorthandPropertyAssignment(node); - case 170 /* ArrayLiteralExpression */: - return visitArrayLiteralExpression(node); - case 174 /* CallExpression */: - return visitCallExpression(node); - case 175 /* NewExpression */: - return visitNewExpression(node); - case 178 /* ParenthesizedExpression */: - return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 187 /* BinaryExpression */: - return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return visitTemplateLiteral(node); - case 176 /* TaggedTemplateExpression */: - return visitTaggedTemplateExpression(node); - case 189 /* TemplateExpression */: - return visitTemplateExpression(node); - case 190 /* YieldExpression */: - return visitYieldExpression(node); - case 95 /* SuperKeyword */: - return visitSuperKeyword(node); - case 190 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); - case 147 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 256 /* SourceFile */: - return visitSourceFileNode(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); - } - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 2097152 /* 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 200 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 219 /* VariableDeclarationList */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - 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; - } - 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()) - ])); - } - function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; - } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); - } - function visitIdentifier(node) { - if (!convertedLoopState) { - return node; - } - if (ts.isGeneratedIdentifier(node)) { - return node; - } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { - return node; + emitNop(); } - return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } - function visitBreakOrContinueStatement(node) { - if (convertedLoopState) { - // check if we can emit break/continue as is - // 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 === 210 /* 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 === 210 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; - labelMarker = "break"; - } - else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; - // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. - labelMarker = "continue"; - } - } - else { - if (node.kind === 210 /* BreakStatement */) { - labelMarker = "break-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); - } - else { - labelMarker = "continue-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); - } - } - var returnExpression = ts.createLiteral(labelMarker); - if (convertedLoopState.loopOutParameters.length) { - var outParams = convertedLoopState.loopOutParameters; - var expr = void 0; - for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); - if (i === 0) { - expr = copyExpr; - } - else { - expr = ts.createBinary(expr, 24 /* CommaToken */, copyExpr); - } - } - returnExpression = ts.createBinary(expr, 24 /* CommaToken */, returnExpression); - } - return ts.createReturn(returnExpression); - } - } - return ts.visitEachChild(node, visitor, context); + /** + * Emits an Assignment operation. + * + * @param left The left-hand side of the assignment. + * @param right The right-hand side of the assignment. + * @param location An optional source map location for the assignment. + */ + function emitAssignment(left, right, location) { + emitWorker(2 /* Assign */, [left, right], location); } /** - * Visits a ClassDeclaration and transforms it into a variable statement. + * Emits a Break operation to the specified label. * - * @param node A ClassDeclaration node. + * @param label A label. + * @param location An optional source map location for the assignment. */ - function visitClassDeclaration(node) { - // [source] - // class C { } - // - // [output] - // var C = (function () { - // function C() { - // } - // return C; - // }()); - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1 /* Export */; - var isDefault = modifierFlags & 512 /* Default */; - // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), - /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) - ]), - /*location*/ node); - ts.setOriginalNode(statement, node); - ts.startOnNewLine(statement); - // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); - return statements; - } - return statement; + function emitBreak(label, location) { + emitWorker(3 /* Break */, [label], location); } - function isExportModifier(node) { - return node.kind === 82 /* ExportKeyword */; + /** + * Emits a Break operation to the specified label when a condition evaluates to a truthy + * value at runtime. + * + * @param label A label. + * @param condition The condition. + * @param location An optional source map location for the assignment. + */ + function emitBreakWhenTrue(label, condition, location) { + emitWorker(4 /* BreakWhenTrue */, [label, condition], location); } /** - * Visits a ClassExpression and transforms it into an expression. + * Emits a Break to the specified label when a condition evaluates to a falsey value at + * runtime. * - * @param node A ClassExpression node. + * @param label A label. + * @param condition The condition. + * @param location An optional source map location for the assignment. */ - function visitClassExpression(node) { - // [source] - // C = class { } - // - // [output] - // C = (function () { - // function class_1() { - // } - // return class_1; - // }()) - return transformClassLikeDeclarationToExpression(node); + function emitBreakWhenFalse(label, condition, location) { + emitWorker(5 /* BreakWhenFalse */, [label, condition], location); } /** - * Transforms a ClassExpression or ClassDeclaration into an expression. + * Emits a YieldStar operation for the provided expression. * - * @param node A ClassExpression or ClassDeclaration node. + * @param expression An optional value for the yield operation. + * @param location An optional source map location for the assignment. */ - function transformClassLikeDeclarationToExpression(node) { - // [source] - // class C extends D { - // constructor() {} - // method() {} - // get prop() {} - // set prop(v) {} - // } - // - // [output] - // (function (_super) { - // __extends(C, _super); - // function C() { - // } - // C.prototype.method = function () {} - // Object.defineProperty(C.prototype, "prop", { - // get: function() {}, - // set: function() {}, - // enumerable: true, - // configurable: true - // }); - // return C; - // }(D)) - if (node.name) { - enableSubstitutionsForBlockScopedBindings(); - } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], - /*type*/ undefined, transformClassBody(node, extendsClauseElement)); - // To preserve the behavior of the old emitter, we explicitly indent - // the body of the function here if it was requested in an earlier - // transformation. - if (ts.getEmitFlags(node) & 524288 /* Indented */) { - ts.setEmitFlags(classFunction, 524288 /* Indented */); - } - // "inner" and "outer" below are added purely to preserve source map locations from - // the old emitter - var inner = ts.createPartiallyEmittedExpression(classFunction); - inner.end = node.end; - ts.setEmitFlags(inner, 49152 /* NoComments */); - var outer = ts.createPartiallyEmittedExpression(inner); - outer.end = ts.skipTrivia(currentText, node.pos); - ts.setEmitFlags(outer, 49152 /* NoComments */); - return ts.createParen(ts.createCall(outer, - /*typeArguments*/ undefined, extendsClauseElement - ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] - : [])); + function emitYieldStar(expression, location) { + emitWorker(7 /* YieldStar */, [expression], location); } /** - * Transforms a ClassExpression or ClassDeclaration into a function body. + * Emits a Yield operation for the provided expression. * - * @param node A ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. + * @param expression An optional value for the yield operation. + * @param location An optional source map location for the assignment. */ - function transformClassBody(node, extendsClauseElement) { - var statements = []; - startLexicalEnvironment(); - addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); - addClassMembers(statements, node); - // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16 /* CloseBraceToken */); - var localName = getLocalName(node); - // The following partially-emitted expression exists purely to align our sourcemap - // emit with the original emitter. - var outer = ts.createPartiallyEmittedExpression(localName); - outer.end = closingBraceLocation.end; - ts.setEmitFlags(outer, 49152 /* NoComments */); - var statement = ts.createReturn(outer); - statement.pos = closingBraceLocation.pos; - ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); - statements.push(statement); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); - ts.setEmitFlags(block, 49152 /* NoComments */); - return block; + function emitYield(expression, location) { + emitWorker(6 /* Yield */, [expression], location); } /** - * Adds a call to the `__extends` helper if needed for a class. + * Emits a Return operation for the provided expression. * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. + * @param expression An optional value for the operation. + * @param location An optional source map location for the assignment. */ - function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { - if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), - /*location*/ extendsClauseElement)); - } + function emitReturn(expression, location) { + emitWorker(8 /* Return */, [expression], location); } /** - * Adds the constructor of the class to a class body function. + * Emits a Throw operation for the provided expression. * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. + * @param expression A value for the operation. + * @param location An optional source map location for the assignment. */ - function addConstructor(statements, node, extendsClauseElement) { - var constructor = ts.getFirstConstructorWithBody(node); - var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, getDeclarationName(node), - /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); - if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); - } - statements.push(constructorFunction); + function emitThrow(expression, location) { + emitWorker(9 /* Throw */, [expression], location); } /** - * Transforms the parameters of the constructor declaration of a class. + * Emits an Endfinally operation. This is used to handle `finally` block semantics. + */ + function emitEndfinally() { + emitWorker(10 /* Endfinally */); + } + /** + * Emits an operation. * - * @param constructor The constructor for the class. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. + * @param code The OpCode for the operation. + * @param args The optional arguments for the operation. */ - function transformConstructorParameters(constructor, hasSynthesizedSuper) { - // If the TypeScript transformer needed to synthesize a constructor for property - // initializers, it would have also added a synthetic `...args` parameter and - // `super` call. - // If this is the case, we do not include the synthetic `...args` parameter and - // will instead use the `arguments` object in ES5/3. - if (constructor && !hasSynthesizedSuper) { - return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); + function emitWorker(code, args, location) { + if (operations === undefined) { + operations = []; + operationArguments = []; + operationLocations = []; } - return []; + if (labelOffsets === undefined) { + // mark entry point + markLabel(defineLabel()); + } + var operationIndex = operations.length; + operations[operationIndex] = code; + operationArguments[operationIndex] = args; + operationLocations[operationIndex] = location; } /** - * Transforms the body of a constructor declaration of a class. - * - * @param constructor The constructor for the class. - * @param node The node which contains the constructor. - * @param extendsClauseElement The expression for the class `extends` clause. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. + * Builds the generator function body. */ - function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { - var statements = []; - startLexicalEnvironment(); - var statementOffset = -1; - if (hasSynthesizedSuper) { - // If a super call has already been synthesized, - // we're going to assume that we should just transform everything after that. - // The assumption is that no prior step in the pipeline has added any prologue directives. - statementOffset = 1; + function build() { + blockIndex = 0; + labelNumber = 0; + labelNumbers = undefined; + lastOperationWasAbrupt = false; + lastOperationWasCompletion = false; + clauses = undefined; + statements = undefined; + exceptionBlockStack = undefined; + currentExceptionBlock = undefined; + withBlockStack = undefined; + var buildResult = buildStatements(); + return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), + /*typeArguments*/ undefined, [ + ts.createThis(), + ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(state)], + /*type*/ undefined, ts.createBlock(buildResult, + /*location*/ undefined, + /*multiLine*/ buildResult.length > 0)), 4194304 /* ReuseTempVariableScope */) + ]); + } + /** + * Builds the statements for the generator function body. + */ + function buildStatements() { + if (operations) { + for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) { + writeOperation(operationIndex); + } + flushFinalLabel(operations.length); } - else if (constructor) { - // Otherwise, try to emit all potential prologue directives first. - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + else { + flushFinalLabel(0); } - if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); - ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + if (clauses) { + var labelExpression = ts.createPropertyAccess(state, "label"); + var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses)); + switchStatement.startsOnNewLine = true; + return [switchStatement]; } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); - // The last statement expression was replaced. Skip it. - if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { - statementOffset++; + if (statements) { + return statements; } - if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); - ts.addRange(statements, body); + return []; + } + /** + * Flush the current label and advance to a new label. + */ + function flushLabel() { + if (!statements) { + return; } - // 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 - && superCaptureStatus !== 2 /* ReplaceWithReturn */ - && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { - statements.push(ts.createReturn(ts.createIdentifier("_this"))); + appendLabel(/*markLabelEnd*/ !lastOperationWasAbrupt); + lastOperationWasAbrupt = false; + lastOperationWasCompletion = false; + labelNumber++; + } + /** + * Flush the final label of the generator function body. + */ + function flushFinalLabel(operationIndex) { + if (isFinalLabelReachable(operationIndex)) { + tryEnterLabel(operationIndex); + withBlockStack = undefined; + writeReturn(/*expression*/ undefined, /*operationLocation*/ undefined); } - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, - /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, - /*multiLine*/ true); - if (!constructor) { - ts.setEmitFlags(block, 49152 /* NoComments */); + if (statements && clauses) { + appendLabel(/*markLabelEnd*/ false); } - return block; + updateLabelExpressions(); } /** - * We want to try to avoid emitting a return statement in certain cases if a user already returned something. - * It would generate obviously dead code, so we'll try to make things a little bit prettier - * by doing a minimal check on whether some common patterns always explicitly return. + * Tests whether the final label of the generator function body + * is reachable by user code. */ - function isSufficientlyCoveredByReturnStatements(statement) { - // A return statement is considered covered. - if (statement.kind === 211 /* ReturnStatement */) { + function isFinalLabelReachable(operationIndex) { + // if the last operation was *not* a completion (return/throw) then + // the final label is reachable. + if (!lastOperationWasCompletion) { return true; } - else if (statement.kind === 203 /* IfStatement */) { - var ifStatement = statement; - if (ifStatement.elseStatement) { - return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && - isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); - } + // if there are no labels defined or referenced, then the final label is + // not reachable. + if (!labelOffsets || !labelExpressions) { + return false; } - else if (statement.kind === 199 /* Block */) { - var lastStatement = ts.lastOrUndefined(statement.statements); - if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + // if the label for this offset is referenced, then the final label + // is reachable. + for (var label = 0; label < labelOffsets.length; label++) { + if (labelOffsets[label] === operationIndex && labelExpressions[label]) { return true; } } return false; } /** - * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. + * Appends a case clause for the last label and sets the new label. * - * @returns The new statement offset into the `statements` array. + * @param markLabelEnd Indicates that the transition between labels was a fall-through + * from a previous case clause and the change in labels should be + * reflected on the `state` object. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { - if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + function appendLabel(markLabelEnd) { + if (!clauses) { + clauses = []; + } + if (statements) { + if (withBlockStack) { + // The previous label was nested inside one or more `with` blocks, so we + // surround the statements in generated `with` blocks to create the same environment. + for (var i = withBlockStack.length - 1; i >= 0; i--) { + var withBlock = withBlockStack[i]; + statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))]; + } + } + if (currentExceptionBlock) { + // The previous label was nested inside of an exception block, so we must + // indicate entry into a protected region by pushing the label numbers + // for each block in the protected region. + var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; + statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + createLabel(startLabel), + createLabel(catchLabel), + createLabel(finallyLabel), + createLabel(endLabel) + ]) + ]))); + currentExceptionBlock = undefined; + } + if (markLabelEnd) { + // The case clause for the last label falls through to this label, so we + // add an assignment statement to reflect the change in labels. + statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } - return 0 /* NoReplacement */; } - // We must be here because the user didn't write a constructor - // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. - // If that's the case we can just immediately return the result of a 'super()' call. - if (!ctor) { - statements.push(ts.createReturn(createDefaultSuperCallOrThis())); - return 2 /* ReplaceWithReturn */; + clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); + statements = undefined; + } + /** + * Tries to enter into a new label at the current operation index. + */ + function tryEnterLabel(operationIndex) { + if (!labelOffsets) { + return; } - // The constructor exists, but it and the 'super()' call it contains were generated - // for something like property initializers. - // Create a captured '_this' variable and assume it will subsequently be used. - if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); - enableSubstitutionsForCapturedThis(); - return 1 /* ReplaceSuperCapture */; + for (var label = 0; label < labelOffsets.length; label++) { + if (labelOffsets[label] === operationIndex) { + flushLabel(); + if (labelNumbers === undefined) { + labelNumbers = []; + } + if (labelNumbers[labelNumber] === undefined) { + labelNumbers[labelNumber] = [label]; + } + else { + labelNumbers[labelNumber].push(label); + } + } } - // Most of the time, a 'super' call will be the first real statement in a constructor body. - // In these cases, we'd like to transform these into a *single* statement instead of a declaration - // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, - // we'd get: - // - // var _this; - // _this = _super.call(...) || this; - // - // instead of - // - // var _this = _super.call(...) || this; - // - // Additionally, if the 'super()' call is the last statement, we should just avoid capturing - // entirely and immediately return the result like so: - // - // return _super.call(...) || this; - // - var firstStatement; - var superCallExpression; - var ctorStatements = ctor.body.statements; - if (statementOffset < ctorStatements.length) { - firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + /** + * Updates literal expressions for labels with actual label numbers. + */ + function updateLabelExpressions() { + if (labelExpressions !== undefined && labelNumbers !== undefined) { + for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) { + var labels = labelNumbers[labelNumber_1]; + if (labels !== undefined) { + for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) { + var label = labels_1[_i]; + var expressions = labelExpressions[label]; + if (expressions !== undefined) { + for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) { + var expression = expressions_1[_a]; + expression.text = String(labelNumber_1); + } + } + } + } } } - // Return the result if we have an immediate super() call on the last statement. - if (superCallExpression && statementOffset === ctorStatements.length - 1) { - statements.push(ts.createReturn(superCallExpression)); - return 2 /* ReplaceWithReturn */; + } + /** + * Tries to enter or leave a code block. + */ + function tryEnterOrLeaveBlock(operationIndex) { + if (blocks) { + for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { + var block = blocks[blockIndex]; + var blockAction = blockActions[blockIndex]; + if (isExceptionBlock(block)) { + if (blockAction === 0 /* Open */) { + if (!exceptionBlockStack) { + exceptionBlockStack = []; + } + if (!statements) { + statements = []; + } + exceptionBlockStack.push(currentExceptionBlock); + currentExceptionBlock = block; + } + else if (blockAction === 1 /* Close */) { + currentExceptionBlock = exceptionBlockStack.pop(); + } + } + else if (isWithBlock(block)) { + if (blockAction === 0 /* Open */) { + if (!withBlockStack) { + withBlockStack = []; + } + withBlockStack.push(block); + } + else if (blockAction === 1 /* Close */) { + withBlockStack.pop(); + } + } + } + } + } + /** + * Writes an operation as a statement to the current label's statement list. + * + * @param operation The OpCode of the operation + */ + function writeOperation(operationIndex) { + tryEnterLabel(operationIndex); + tryEnterOrLeaveBlock(operationIndex); + // early termination, nothing else to process in this label + if (lastOperationWasAbrupt) { + return; + } + lastOperationWasAbrupt = false; + lastOperationWasCompletion = false; + var opcode = operations[operationIndex]; + if (opcode === 0 /* Nop */) { + return; + } + else if (opcode === 10 /* Endfinally */) { + return writeEndfinally(); + } + var args = operationArguments[operationIndex]; + if (opcode === 1 /* Statement */) { + return writeStatement(args[0]); } - // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); - // If we're actually replacing the original statement, we need to signal this to the caller. - if (superCallExpression) { - return 1 /* ReplaceSuperCapture */; + var location = operationLocations[operationIndex]; + switch (opcode) { + case 2 /* Assign */: + return writeAssign(args[0], args[1], location); + case 3 /* Break */: + return writeBreak(args[0], location); + case 4 /* BreakWhenTrue */: + return writeBreakWhenTrue(args[0], args[1], location); + case 5 /* BreakWhenFalse */: + return writeBreakWhenFalse(args[0], args[1], location); + case 6 /* Yield */: + return writeYield(args[0], location); + case 7 /* YieldStar */: + return writeYieldStar(args[0], location); + case 8 /* Return */: + return writeReturn(args[0], location); + case 9 /* Throw */: + return writeThrow(args[0], location); } - return 0 /* NoReplacement */; - } - function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); } /** - * Visits a parameter declaration. + * Writes a statement to the current label's statement list. * - * @param node A ParameterDeclaration node. + * @param statement A statement to write. */ - function visitParameter(node) { - if (node.dotDotDotToken) { - // rest parameters are elided - return undefined; - } - else if (ts.isBindingPattern(node.name)) { - // Binding patterns are converted into a generated name and are - // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else if (node.initializer) { - // Initializers are elided - return ts.setOriginalNode(ts.createParameter(node.name, - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else { - return node; + function writeStatement(statement) { + if (statement) { + if (!statements) { + statements = [statement]; + } + else { + statements.push(statement); + } } } /** - * Gets a value indicating whether we need to add default value assignments for a - * function-like node. + * Writes an Assign operation to the current label's statement list. * - * @param node A function-like node. + * @param left The left-hand side of the assignment. + * @param right The right-hand side of the assignment. + * @param operationLocation The source map location for the operation. */ - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536 /* ContainsDefaultValueAssignments */) !== 0; + function writeAssign(left, right, operationLocation) { + writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); } /** - * Adds statements to the body of a function-like node if it contains parameters with - * binding patterns or initializers. + * Writes a Throw operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param node A function-like node. + * @param expression The value to throw. + * @param operationLocation The source map location for the operation. */ - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - 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; - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); - } - } + function writeThrow(expression, operationLocation) { + lastOperationWasAbrupt = true; + lastOperationWasCompletion = true; + writeStatement(ts.createThrow(expression, operationLocation)); } /** - * Adds statements to the body of a function-like node for parameters with binding patterns + * Writes a Return operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. + * @param expression The value to return. + * @param operationLocation The source map location for the operation. */ - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - // In cases where a binding pattern is simply '[]' or '{}', - // we usually don't want to emit a var declaration; however, in the presence - // of an initializer, we must emit that expression to preserve side effects. - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608 /* CustomPrologue */)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); - } + function writeReturn(expression, operationLocation) { + lastOperationWasAbrupt = true; + lastOperationWasCompletion = true; + writeStatement(ts.createReturn(ts.createArrayLiteral(expression + ? [createInstruction(2 /* Return */), expression] + : [createInstruction(2 /* Return */)]), operationLocation)); } /** - * Adds statements to the body of a function-like node for parameters with initializers. + * Writes a Break operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. + * @param label The label for the Break. + * @param operationLocation The source map location for the operation. */ - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); - statements.push(statement); + function writeBreak(label, operationLocation) { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral([ + createInstruction(3 /* Break */), + createLabel(label) + ]), operationLocation)); } /** - * Gets a value indicating whether we need to add statements to handle a rest parameter. + * Writes a BreakWhenTrue operation to the current label's statement list. * - * @param node A ParameterDeclaration node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` + * @param label The label for the Break. + * @param condition The condition for the Break. + * @param operationLocation The source map location for the operation. */ - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 /* Identifier */ && !inConstructorWithSynthesizedSuper; + function writeBreakWhenTrue(label, condition, operationLocation) { + writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + createInstruction(3 /* Break */), + createLabel(label) + ]), operationLocation))); } /** - * Adds statements to the body of a function-like node if it contains a rest parameter. + * Writes a BreakWhenFalse operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param node A function-like node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` + * @param label The label for the Break. + * @param condition The condition for the Break. + * @param operationLocation The source map location for the operation. */ - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - // `declarationName` is the name of the local declaration for the parameter. - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); - // `expressionName` is the name of the parameter used in expressions. - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, - /*type*/ undefined, ts.createArrayLiteral([])) - ]), - /*location*/ parameter), 8388608 /* CustomPrologue */)); - // for (var _i = restIndex; _i < arguments.length; _i++) { - // param[_i - restIndex] = arguments[_i]; - // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), - /*location*/ parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); - ts.startOnNewLine(forStatement); - statements.push(forStatement); + function writeBreakWhenFalse(label, condition, operationLocation) { + writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + createInstruction(3 /* Break */), + createLabel(label) + ]), operationLocation))); } /** - * Adds a statement to capture the `this` of a function declaration if it is needed. + * Writes a Yield operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param node A node. + * @param expression The expression to yield. + * @param operationLocation The source map location for the operation. */ - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 180 /* ArrowFunction */) { - captureThisForNode(statements, node, ts.createThis()); - } + function writeYield(expression, operationLocation) { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral(expression + ? [createInstruction(4 /* Yield */), expression] + : [createInstruction(4 /* Yield */)]), operationLocation)); } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + /** + * Writes a YieldStar instruction to the current label's statement list. + * + * @param expression The expression to yield. + * @param operationLocation The source map location for the operation. + */ + function writeYieldStar(expression, operationLocation) { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral([ + createInstruction(5 /* YieldStar */), + expression + ]), operationLocation)); } /** - * Adds statements to the class body function for a class to define the members of the - * class. + * Writes an Endfinally instruction to the current label's statement list. + */ + function writeEndfinally() { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral([ + createInstruction(7 /* Endfinally */) + ]))); + } + } + ts.transformGenerators = transformGenerators; + var _a; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableSubstitution(254 /* ShorthandPropertyAssignment */); + context.enableEmitNotification(256 /* SourceFile */); + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var bindingNameExportSpecifiersMap; + // Subset of exportSpecifiers that is a binding-name. + // This is to reduce amount of memory we have to keep around even after we done with module-transformer + var bindingNameExportSpecifiersForFileMap = ts.createMap(); + var hasExportStarsToExportValues; + return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. * - * @param statements The statements for the class body function. - * @param node The ClassExpression or ClassDeclaration node. + * @param node The SourceFile node. */ - function addClassMembers(statements, node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - switch (member.kind) { - case 198 /* SemicolonClassElement */: - statements.push(transformSemicolonClassElementToStatement(member)); - break; - case 147 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); - break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); - } - break; - case 148 /* Constructor */: - // Constructors are handled in visitClassExpression/visitClassDeclaration - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + // Collect information about the external module. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Perform the transformation. + var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule_1(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + return updated; } + return node; + var _a; } /** - * Transforms a SemicolonClassElement into a statement for a class body function. + * Transforms a SourceFile into a CommonJS module. * - * @param member The SemicolonClassElement node. + * @param node The SourceFile node. */ - function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = updateSourceFile(node, statements); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); + } + return updated; } /** - * Transforms a MethodDeclaration into a statement for a class body function. + * Transforms a SourceFile into an AMD module. * - * @param receiver The receiver for the member. - * @param member The MethodDeclaration node. + * @param node The SourceFile node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = ts.getCommentRange(member); - var sourceMapRange = ts.getSourceMapRange(member); - var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); - ts.setEmitFlags(func, 49152 /* NoComments */); - ts.setSourceMapRange(func, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), - /*location*/ member.name), func), - /*location*/ member); - ts.setOriginalNode(statement, member); - ts.setCommentRange(statement, commentRange); - // The location for the statement is used to emit comments only. - // No source map should be emitted for this statement to align with the - // old emitter. - ts.setEmitFlags(statement, 1536 /* NoSourceMap */); - return statement; + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); } /** - * Transforms a set of related of get/set accessors into a statement for a class body function. + * Transforms a SourceFile into a UMD module. * - * @param receiver The receiver for the member. - * @param accessors The set of related get/set accessors. + * @param node The SourceFile node. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*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 - // old emitter. - ts.setEmitFlags(statement, 49152 /* NoComments */); - return statement; + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16 /* UMDDefine */); + return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); } /** - * Transforms a set of related get/set accessors into an expression for either a class - * body function or an ObjectLiteralExpression with computed properties. + * Transforms a SourceFile into an AMD or UMD module. * - * @param receiver The receiver for the member. + * @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 transformAccessorsToExpression(receiver, _a, startsOnNewLine) { - var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - // 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); - ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); - ts.setSourceMapRange(propertyName, firstAccessor.name); - var properties = []; - if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - var getter = ts.createPropertyAssignment("get", getterFunction); - ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); - properties.push(getter); - } - if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - var setter = ts.createPropertyAssignment("set", setterFunction); - ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); - properties.push(setter); - } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); - var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - target, - propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // 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; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter("require"), + ts.createParameter("exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) ]); - if (startsOnNewLine) { - call.startsOnNewLine = true; - } - return call; } /** - * Visits an ArrowFunction and transforms it into a FunctionExpression. + * Transforms a SourceFile into an AMD or UMD module body. * - * @param node An ArrowFunction node. + * @param node The SourceFile node. */ - function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */) { - enableSubstitutionsForCapturedThis(); + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + // Visit each statement of the module body. + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + if (hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.setEmitFlags(body, 2 /* EmitExportStar */); } - var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); - ts.setEmitFlags(func, 256 /* CapturesThis */); - return func; - } - /** - * Visits a FunctionExpression node. - * - * @param node a FunctionExpression node. - */ - function visitFunctionExpression(node) { - return transformFunctionLikeToExpression(node, /*location*/ node, node.name); + return body; } - /** - * Visits a FunctionDeclaration node. - * - * @param node a FunctionDeclaration node. - */ - function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, transformFunctionBody(node), - /*location*/ node), - /*original*/ node); + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(exportEquals.expression, + /*location*/ exportEquals); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), + /*location*/ exportEquals); + ts.setEmitFlags(statement, 49152 /* NoComments */); + statements.push(statement); + } + } } /** - * Transforms a function-like node into a FunctionExpression. + * Visits a node at the top level of the source file. * - * @param node The function-like node to transform. - * @param location The source-map location for the new FunctionExpression. - * @param name The name of the new FunctionExpression. + * @param node The node. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function visitor(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), - /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** - * Transforms the body of a function-like node. + * Visits an ImportDeclaration node. * - * @param node A function-like node. + * @param node The ImportDeclaration node. */ - function transformFunctionBody(node) { - var multiLine = false; // indicates whether the block *must* be emitted as multiple lines - var singleLine = false; // indicates whether the block *may* be emitted as a single line - var statementsLocation; - var closeBraceLocation; + function visitImportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + statements.push(ts.createStatement(createRequireCall(node), + /*location*/ node)); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createConstDeclarationList(variables), + /*location*/ node)); + } } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); - // If we added any generated statements, this must be a multi-line block. - if (!multiLine && statements.length > 0) { - multiLine = true; + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node), + /*location*/ node) + ]))); } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - // If the original body was a multi-line block, this must be a multi-line block. - if (!multiLine && body.multiLine) { - multiLine = true; + addExportImportAssignments(statements, node); + return ts.singleOrMany(statements); + } + function visitImportEqualsDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } + // Set emitFlags on the name of the importEqualsDeclaration + // This is so the printer will not substitute the identifier + ts.setEmitFlags(node.name, 128 /* NoSubstitution */); + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), + /*location*/ node)); + } + else { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*location*/ undefined, + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); } } else { - ts.Debug.assert(node.kind === 180 /* ArrowFunction */); - // To align with the old emitter, we use a synthetic end position on the location - // for the statement list we synthesize when we down-level an arrow function with - // an expression function body. This prevents both comments and source maps from - // being emitted for the end position only. - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, node.name), + /*location*/ node)); } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); - ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); - statements.push(returnStatement); - // To align with the source map emit for the old emitter, we set a custom - // source map location for the close brace. - closeBraceLocation = body; } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - // If we added any final generated statements, this must be a multi-line block - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; + addExportImportAssignments(statements, node); + return statements; + } + function visitExportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32 /* SingleLine */); + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ]), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), + /*location*/ specifier)); + } + return ts.singleOrMany(statements); } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); + else { + // export * from "mod"; + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), + /*location*/ node); } - ts.setOriginalNode(block, node.body); - return block; } - /** - * Visits an ExpressionStatement that contains a destructuring assignment. - * - * @param node An ExpressionStatement node. - */ - function visitExpressionStatement(node) { - // If we are here it is most likely because our expression is a destructuring assignment. - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 187 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide as `export=` is handled in addExportEqualsIfNeeded + return undefined; } - return ts.visitEachChild(node, visitor, context); + var statements = []; + addExportDefault(statements, node.expression, /*location*/ node); + return statements; } - /** - * Visits a ParenthesizedExpression that may contain a destructuring assignment. - * - * @param node A ParenthesizedExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitParenthesizedExpression(node, needsDestructuringValue) { - // If we are here it is most likely because our expression is a destructuring assignment. - if (needsDestructuringValue) { - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); - case 187 /* BinaryExpression */: - return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); + function addExportDefault(statements, expression, location) { + tryAddExportDefaultCompat(statements); + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + } + function tryAddExportDefaultCompat(statements) { + var original = ts.getOriginalNode(currentSourceFile); + ts.Debug.assert(original.kind === 256 /* SourceFile */); + if (!original.symbol.exports["___esModule"]) { + if (languageVersion === 0 /* ES3 */) { + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); } } - return ts.visitEachChild(node, visitor, context); } - /** - * Visits a BinaryExpression that contains a destructuring assignment. - * - * @param node A BinaryExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitBinaryExpression(node, needsDestructuringValue) { - // If we are here it is because this is a destructuring assignment. - ts.Debug.assert(ts.isDestructuringAssignment(node)); - return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + function addExportImportAssignments(statements, node) { + if (ts.isImportEqualsDeclaration(node)) { + addExportMemberAssignments(statements, node.name); + } + else { + var names = ts.reduceEachChild(node, collectExportMembers, []); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); + } + } } - function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 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++) { - var decl = _a[_i]; - hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); - if (decl.initializer) { - var assignment = void 0; - if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); - } - else { - assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); - } - (assignments || (assignments = [])).push(assignment); - } + function collectExportMembers(names, node) { + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); } - if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24 /* CommaToken */, acc); }), node); + } + return ts.reduceEachChild(node, collectExportMembers, names); + } + function addExportMemberAssignments(statements, name) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), + /*location*/ specifier.name))); } - else { - // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + } + } + function addExportMemberAssignment(statements, node) { + if (ts.hasModifier(node, 512 /* Default */)) { + addExportDefault(statements, getDeclarationName(node), /*location*/ node); + } + else { + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + } + } + function visitVariableStatement(node) { + // If the variable is for a generated declaration, + // we should maintain it and just strip off the 'export' modifier if necessary. + var originalKind = ts.getOriginalNode(node).kind; + if (originalKind === 226 /* ModuleDeclaration */ || + originalKind === 225 /* EnumDeclaration */ || + originalKind === 222 /* ClassDeclaration */) { + if (!ts.hasModifier(node, 1 /* Export */)) { + return node; } + return ts.setOriginalNode(ts.createVariableStatement( + /*modifiers*/ undefined, node.declarationList), node); } - return ts.visitEachChild(node, visitor, context); + var resultStatements = []; + // If we're exporting these variables, then these just become assignments to 'exports.blah'. + // We only want to emit assignments for variables with initializers. + if (ts.hasModifier(node, 1 /* Export */)) { + var variables = ts.getInitializedVariables(node.declarationList); + if (variables.length > 0) { + var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + resultStatements.push(inlineAssignments); + } + } + else { + resultStatements.push(node); + } + // While we might not have been exported here, each variable might have been exported + // later on in an export specifier (e.g. `export {foo as blah, bar}`). + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + addExportMemberAssignmentsForBindingName(resultStatements, decl.name); + } + return resultStatements; } /** - * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). - * - * @param node A VariableDeclarationList node. + * Creates appropriate assignments for each binding identifier that is exported in an export specifier, + * and inserts it into 'resultStatements'. */ - function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + function addExportMemberAssignmentsForBindingName(resultStatements, name) { + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + addExportMemberAssignmentsForBindingName(resultStatements, element.name); + } + } } - 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 & 2097152 /* 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)); + else { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + var sourceFileId = ts.getOriginalNodeId(currentSourceFile); + if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { + bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + } + bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; + addExportMemberAssignments(resultStatements, name); + } } - return declarationList; } - /** - * Gets a value indicating whether we should emit an explicit initializer for a variable - * declaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. - */ - function shouldEmitExplicitInitializerForLetDeclaration(node) { - // Nested let bindings might need to be initialized explicitly to preserve - // ES6 semantic: - // - // { let x = 1; } - // { let x; } // x here should be undefined. not 1 - // - // Top level bindings never collide with anything and thus don't require - // explicit initialization. As for nested let bindings there are two cases: - // - // - Nested let bindings that were not renamed definitely should be - // initialized explicitly: - // - // { let x = 1; } - // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } - // - // Without explicit initialization code in /*1*/ can be executed even if - // some-condition is evaluated to false. - // - // - Renaming introduces fresh name that should not collide with any - // existing names, however renamed bindings sometimes also should be - // explicitly initialized. One particular case: non-captured binding - // declared inside loop body (but not in loop initializer): - // - // let x; - // for (;;) { - // let x; - // } - // - // In downlevel codegen inner 'x' will be renamed so it won't collide - // with outer 'x' however it will should be reset on every iteration as - // if it was declared anew. - // - // * Why non-captured binding? - // - Because if loop contains block scoped binding captured in some - // function then loop body will be rewritten to have a fresh scope - // on every iteration so everything will just work. - // - // * Why loop initializer is excluded? - // - Since we've introduced a fresh name it already will be undefined. - var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) - || (isCapturedInFunction - && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); - var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 208 /* ForOfStatement */ - && (!resolver.isDeclarationWithCollidingName(node) - || (isDeclaredInLoop - && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); - return emitExplicitInitializer; + function transformInitializedVariable(node) { + var name = node.name; + if (ts.isBindingPattern(name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); + } + else { + return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); + } + } + function visitFunctionDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + if (node.name) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.setOriginalNode(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + // Decorators end up creating a series of assignment expressions which overwrite + // the local binding that we export, so we need to defer from exporting decorated classes + // until the decoration assignments take place. We do this when visiting expression-statements. + if (node.name && !(node.decorators && node.decorators.length)) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitExpressionStatement(node) { + var original = ts.getOriginalNode(node); + var origKind = original.kind; + if (origKind === 225 /* EnumDeclaration */ || origKind === 226 /* ModuleDeclaration */) { + return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); + } + else if (origKind === 222 /* ClassDeclaration */) { + // The decorated assignment for a class name may need to be transformed. + var classDecl = original; + if (classDecl.name) { + var statements = [node]; + addExportMemberAssignments(statements, classDecl.name); + return statements; + } + } + return node; + } + function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { + var statements = [node]; + // Preserve old behavior for enums in which a variable statement is emitted after the body itself. + if (ts.hasModifier(original, 1 /* Export */) && + original.kind === 225 /* EnumDeclaration */ && + ts.isFirstDeclarationOfKind(original, 225 /* EnumDeclaration */)) { + addVarForExportedEnumOrNamespaceDeclaration(statements, original); + } + addExportMemberAssignments(statements, original.name); + return statements; } /** - * Visits a VariableDeclaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. + * Adds a trailing VariableStatement for an enum or module declaration. */ - function visitVariableDeclarationInLetDeclarationList(node) { - // For binding pattern names that lack initializers there is no point to emit - // explicit initializer since downlevel codegen for destructuring will fail - // in the absence of initializer so all binding elements will say uninitialized - var name = node.name; - if (ts.isBindingPattern(name)) { - return visitVariableDeclaration(node); + function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { + var transformedStatement = ts.createVariableStatement( + /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), + /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], + /*location*/ node); + ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); + statements.push(transformedStatement); + } + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256 /* SourceFile */) { + bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + bindingNameExportSpecifiersMap = undefined; } - if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { - var clone_8 = ts.getMutableClone(node); - clone_8.initializer = ts.createVoidZero(); - return clone_8; + else { + previousOnEmitNode(emitContext, node, emitCallback); } - return ts.visitEachChild(node, visitor, context); } /** - * Visits a VariableDeclaration node with a binding pattern. + * Hooks node substitutions. * - * @param node A VariableDeclaration node. + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. */ - function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. - if (ts.isBindingPattern(node.name)) { - var recordTempVariablesInLine = !enclosingVariableStatement - || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenVariableDestructuring(context, node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); } - return ts.visitEachChild(node, visitor, context); + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); + } + return node; } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, /*location*/ node); } - convertedLoopState.labels[node.label.text] = node.label.text; + return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 187 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); } - else { - result = ts.visitEachChild(node, visitor, context); + return node; + } + function substituteExpressionIdentifier(node) { + return trySubstituteExportedName(node) + || trySubstituteImportedName(node) + || node; + } + function substituteBinaryExpression(node) { + var left = node.left; + // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier + if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, node); + } + return nestedExportAssignment; + } } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + return node; + } + function substituteUnaryExpression(node) { + // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are + // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus + var operator = node.operator; + var operand = node.operand; + if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var transformedUnaryExpression = void 0; + if (node.kind === 187 /* PostfixUnaryExpression */) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), + /*location*/ node); + // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here + ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); + } + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, transformedUnaryExpression || node); + } + return nestedExportAssignment; + } } - return result; + return node; } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function trySubstituteExportedName(node) { + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 262144 /* LocalName */) === 0) { + var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); + if (container) { + if (container.kind === 256 /* SourceFile */) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), + /*location*/ node); + } + } + } + return undefined; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function trySubstituteImportedName(node) { + if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (ts.isImportClause(declaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(declaration)) { + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), + /*location*/ node); + } + } + } + return undefined; } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function getModuleMemberName(name) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), name, + /*location*/ name); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (ts.isDefined(moduleName)) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function createExportStatement(name, value, location) { + var statement = ts.createStatement(createExportAssignment(name, value)); + statement.startsOnNewLine = true; + if (location) { + ts.setSourceMapRange(statement, location); + } + return statement; } - function convertForOfToFor(node, convertedLoopBodyStatements) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (var _i = 0, _a = expr; _i < _a.length; _i++) { - // var v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - // In the case where the user wrote an identifier as the RHS, like this: - // - // for (let v of arr) { } - // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 /* Identifier */ - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); - ts.setOriginalNode(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); + function createExportAssignment(name, value) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(amdDependency.name)); } else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), - /*location*/ ts.moveRangeEnd(initializer, -1))); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, - /*needsValue*/ false, hoistVariableDeclaration, visitor))); + for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { + var importNode = externalImports_1[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(importAliasName)); } else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + unaliasedModuleNames.push(externalModuleName); } } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function updateSourceFile(node, statements) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + return updated; + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableEmitNotification(256 /* SourceFile */); + var exportFunctionForFileMap = []; + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStarsToExportValues; + var exportFunctionForFile; + var contextObjectForFile; + var exportedLocalNames; + var exportedFunctionDeclarations; + var enclosingBlockScopedContainer; + var currentParent; + var currentNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + currentNode = node; + // Perform the transformation. + var updated = transformSystemModuleWorker(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + exportFunctionForFile = undefined; + contextObjectForFile = undefined; + exportedLocalNames = undefined; + exportedFunctionDeclarations = undefined; + return updated; } - // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); - ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); - // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); - return forStatement; + return node; + } + function transformSystemModuleWorker(node) { + // System modules have the following shape: + // + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // + // The parameter 'exports' here is a callback '(name: string, value: T) => T' that + // is used to publish exported values. 'exports' returns its 'value' argument so in + // most cases expressions that mutate exported values can be rewritten as: + // + // expr -> exports('name', expr) + // + // The only exception in this rule is postfix unary operators, + // see comment to 'substitutePostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // Collect information about the external module and dependency groups. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Make sure that the name of the 'exports' function does not conflict with + // existing identifiers. + exportFunctionForFile = ts.createUniqueName("exports"); + contextObjectForFile = ts.createUniqueName("context"); + exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; + var dependencyGroups = collectDependencyGroups(externalImports); + var statements = []; + // Add the body of the module. + addSystemModuleBody(statements, node, dependencyGroups); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); + var body = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(exportFunctionForFile), + ts.createParameter(contextObjectForFile) + ], + /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); + // Write the call to `System.register` + // Clear the emit-helpers flag for later passes since we'll have already used it in the module body + // So the helper will be emit at the correct position instead of at the top of the source-file + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + /*typeArguments*/ undefined, moduleName + ? [moduleName, dependencies, body] + : [dependencies, body])) + ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); + var _a; } /** - * Visits an ObjectLiteralExpression with computed propety names. + * Adds the statements for the module body function for the source file. * - * @param node An ObjectLiteralExpression node. + * @param statements The output statements for the module body. + * @param node The source file for the module. + * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. */ - function visitObjectLiteralExpression(node) { - // We are here because a ComputedPropertyName was used somewhere in the expression. - var properties = node.properties; - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialProperties = numProperties; - for (var i = 0; i < numProperties; i++) { - var property = properties[i]; - if (property.transformFlags & 4194304 /* ContainsYield */ - || property.name.kind === 140 /* 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), 524288 /* 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); - } - function shouldConvertIterationStatementBody(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + function addSystemModuleBody(statements, node, dependencyGroups) { + // Shape of the body in system modules: + // + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // + // i.e: + // + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // + // Will be transformed to: + // + // function(exports) { + // var file_1; // local alias + // var y; + // function foo() { return y + file_1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file_1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + // We start a new lexical environment in this function body, but *not* in the + // body of the execute function. This allows us to emit temporary declarations + // only in the outer module body and not in the inner one. + startLexicalEnvironment(); + // Add any prologue directives. + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); + // var __moduleName = context_1 && context_1.id; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", + /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) + ]))); + // Visit the statements of the source file, emitting any transformations into + // the `executeStatements` array. We do this *before* we fill the `setters` array + // as we both emit transformations as well as aggregate some data used when creating + // setters. This allows us to reduce the number of times we need to loop through the + // statements of the source file. + var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); + // We emit the lexical environment (hoisted variables and function declarations) + // early to align roughly with our previous emit output. + // Two key differences in this approach are: + // - Temporary variables will appear at the top rather than at the bottom of the file + // - Calls to the exporter for exported function declarations are grouped after + // the declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Emit early exports for function declarations. + ts.addRange(statements, exportedFunctionDeclarations); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.createBlock(executeStatements, + /*location*/ undefined, + /*multiLine*/ true))) + ]), + /*multiLine*/ true))); } - /** - * Records constituents of name for the given variable to be hoisted in the outer scope. - */ - function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { - if (!state.hoistedLocalVariables) { - state.hoistedLocalVariables = []; + function addExportStarIfNeeded(statements) { + if (!hasExportStarsToExportValues) { + return; } - visit(node.name); - function visit(node) { - if (node.kind === 69 /* Identifier */) { - state.hoistedLocalVariables.push(node); - } - else { - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - visit(element.name); - } + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + // local names set should only be added if we have anything exported + if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { + var externalImport = externalImports_2[_i]; + if (externalImport.kind === 237 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; } } - } - } - function convertIterationStatementBodyIfNecessary(node, convert) { - if (!shouldConvertIterationStatementBody(node)) { - var saveAllowedNonLabeledJumps = void 0; - if (convertedLoopState) { - // we get here if we are trying to emit normal loop loop inside converted loop - // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is - saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; - } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); - if (convertedLoopState) { - convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return addExportStarFunction(statements, /*localNames*/ undefined); } - return result; - } - var functionName = ts.createUniqueName("_loop"); - var loopInitializer; - switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - var initializer = node.initializer; - if (initializer && initializer.kind === 219 /* VariableDeclarationList */) { - loopInitializer = initializer; - } - break; } - // variables that will be passed to the loop as parameters - var loopParameters = []; - // variables declared in the loop initializer that will be changed inside the loop - var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { - for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); + var exportedNames = []; + if (exportedLocalNames) { + for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { + var exportedLocalName = exportedLocalNames_1[_a]; + // write name of exported declaration, i.e 'export var x...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); } } - var outerConvertedLoopState = convertedLoopState; - convertedLoopState = { loopOutParameters: loopOutParameters }; - if (outerConvertedLoopState) { - // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. - // if outer converted loop has already accumulated some state - pass it through - if (outerConvertedLoopState.argumentsName) { - // outer loop has already used 'arguments' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; + for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { + var externalImport = externalImports_3[_b]; + if (externalImport.kind !== 237 /* ExportDeclaration */) { + continue; } - if (outerConvertedLoopState.thisName) { - // outer loop has already used 'this' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.thisName = outerConvertedLoopState.thisName; + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; } - if (outerConvertedLoopState.hoistedLocalVariables) { - // we've already collected some non-block scoped variable declarations in enclosing loop - // use the same storage in nested loop - convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; + for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { + var element = _d[_c]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); } } - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); - var currentState = convertedLoopState; - convertedLoopState = outerConvertedLoopState; - if (loopOutParameters.length) { - var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; - copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); - loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); - } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); - } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 - && (node.statement.transformFlags & 4194304 /* ContainsYield */) !== 0; - var loopBodyFlags = 0; - if (currentState.containsLexicalThis) { - loopBodyFlags |= 256 /* CapturesThis */; - } - if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 2097152 /* AsyncFunctionBody */; - } - var convertedLoopVariable = ts.createVariableStatement( + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, - /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, loopParameters, - /*type*/ undefined, loopBody), loopBodyFlags)) - ])); - var statements = [convertedLoopVariable]; - var extraVariableDeclarations; - // propagate state from the inner loop to the outer loop if necessary - if (currentState.argumentsName) { - // if alias for arguments is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.argumentsName = currentState.argumentsName; - } - else { - // this is top level converted loop and we need to create an alias for 'arguments' object - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, - /*type*/ undefined, ts.createIdentifier("arguments"))); - } - } - if (currentState.thisName) { - // if alias for this is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.thisName = currentState.thisName; - } - else { - // this is top level converted loop so we need to create an alias for 'this' here - // NOTE: - // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. - // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, - /*type*/ undefined, ts.createIdentifier("this"))); - } - } - if (currentState.hoistedLocalVariables) { - // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later - if (outerConvertedLoopState) { - // pass them to outer converted loop - outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; - } - else { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - // hoist collected variable declarations - for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { - var identifier = _c[_b]; - extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); + ts.createVariableDeclaration(exportedNamesStorageRef, + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + ]))); + return addExportStarFunction(statements, exportedNamesStorageRef); + } + /** + * Emits a setter callback for each dependency group. + * @param write The callback used to write each callback. + */ + function generateSetters(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + // derive a unique name for parameter from the first named entry in the group + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 231 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 230 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 237 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // + // emit as: + // + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + } + else { + // export * from 'foo' + // + // emit as: + // + // exportStar(foo_1_1); + statements.push(ts.createStatement(ts.createCall(exportStarFunction, + /*typeArguments*/ undefined, [parameterName]))); + } + break; } } + setters.push(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); } - // add extra variables to hold out parameters if necessary - if (loopOutParameters.length) { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { - var outParam = loopOutParameters_1[_d]; - extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); - } - } - // create variable statement to hold all introduced variable declarations - if (extraVariableDeclarations) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); - } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); - var loop; - if (convert) { - loop = convert(node, convertedLoopBodyStatements); - } - else { - loop = ts.getMutableClone(node); - // clean statement part - loop.statement = undefined; - // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); - // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); - // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); - } - statements.push(currentParent.kind === 214 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); - return statements; - } - function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56 /* EqualsToken */, source); + return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); } - function copyOutParameters(outParams, copyDirection, statements) { - for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { - var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + function visitSourceElement(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + default: + return visitNestedNode(node); } } - function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { - var outerConvertedLoopState = convertedLoopState; - var statements = []; - // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop - // simple loops are emitted as just 'loop()'; - // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && - !state.labeledNonLocalBreaks && - !state.labeledNonLocalContinues; - var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37 /* AsteriskToken */), call) : call; - if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - } - else { - var loopResultName = ts.createUniqueName("state"); - var stateVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); - statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { - var returnStatement = void 0; - if (outerConvertedLoopState) { - outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; - returnStatement = ts.createReturn(loopResultName); - } - else { - returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); - } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); - } - if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); - } - if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { - var caseClauses = []; - processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); - processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); - statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); - } + function visitNestedNode(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var currentGrandparent = currentParent; + currentParent = currentNode; + currentNode = node; + if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { + enclosingBlockScopedContainer = currentParent; } - return statements; + var result = visitNestedNodeWorker(node); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return result; } - function setLabeledJump(state, isBreak, labelText, labelMarker) { - if (isBreak) { - if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = ts.createMap(); - } - state.labeledNonLocalBreaks[labelText] = labelMarker; - } - else { - if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = ts.createMap(); - } - state.labeledNonLocalContinues[labelText] = labelMarker; + function visitNestedNodeWorker(node) { + switch (node.kind) { + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 207 /* ForStatement */: + return visitForStatement(node); + case 208 /* ForInStatement */: + return visitForInStatement(node); + case 209 /* ForOfStatement */: + return visitForOfStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 213 /* WithStatement */: + return visitWithStatement(node); + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 228 /* CaseBlock */: + return visitCaseBlock(node); + case 249 /* CaseClause */: + return visitCaseClause(node); + case 250 /* DefaultClause */: + return visitDefaultClause(node); + case 217 /* TryStatement */: + return visitTryStatement(node); + case 252 /* CatchClause */: + return visitCatchClause(node); + case 200 /* Block */: + return visitBlock(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + return node; } } - function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { - if (!table) { - return; - } - for (var labelText in table) { - var labelMarker = table[labelText]; - var statements = []; - // 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])) { - var label = ts.createIdentifier(labelText); - statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); - } - else { - setLabeledJump(outerLoop, isBreak, labelText, labelMarker); - statements.push(ts.createReturn(loopResultName)); - } - caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + function visitImportDeclaration(node) { + if (node.importClause && ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); } + return undefined; } - function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { - var name = decl.name; - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - processLoopVariableDeclaration(element, loopParameters, loopOutParameters); - } - } - } - else { - loopParameters.push(ts.createParameter(name)); - if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); - loopOutParameters.push({ originalName: name, outParamName: outParamName }); - } + function visitImportEqualsDeclaration(node) { + if (ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); } + // NOTE(rbuckton): Do we support export import = require('') in System? + return undefined; } - /** - * Adds the members of an object literal to an array of expressions. - * - * @param expressions An array of expressions. - * @param node An ObjectLiteralExpression node. - * @param receiver The receiver for members of the ObjectLiteralExpression. - * @param numInitialNonComputedProperties The number of initial properties without - * computed property names. - */ - function addObjectLiteralMembers(expressions, node, receiver, start) { - var properties = node.properties; - var numProperties = properties.length; - for (var i = start; i < numProperties; i++) { - var property = properties[i]; - switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); - } - break; - case 253 /* PropertyAssignment */: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 254 /* ShorthandPropertyAssignment */: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 147 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + var statements = []; + ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); + return statements; } + return undefined; } - /** - * Transforms a PropertyAssignment node into an expression. - * - * @param node The ObjectLiteralExpression that contains the PropertyAssignment. - * @param property The PropertyAssignment node. - * @param receiver The receiver for the assignment. - */ - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function visitExportSpecifier(specifier) { + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + } + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; } - return expression; + return createExportStatement(ts.createLiteral("default"), node.expression); } /** - * Transforms a ShorthandPropertyAssignment node into an expression. + * Visits a variable statement, hoisting declared names to the top-level module body. + * Each declaration is rewritten into an assignment expression. * - * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. - * @param property The ShorthandPropertyAssignment node. - * @param receiver The receiver for the assignment. + * @param node The variable statement to visit. */ - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function visitVariableStatement(node) { + // hoist only non-block scoped declarations or block scoped declarations parented by source file + var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || + enclosingBlockScopedContainer.kind === 256 /* SourceFile */; + if (!shouldHoist) { + return node; } - return expression; + var isExported = ts.hasModifier(node, 1 /* Export */); + var expressions = []; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, isExported); + if (visited) { + expressions.push(visited); + } + } + if (expressions.length) { + return ts.createStatement(ts.inlineExpressions(expressions), node); + } + return undefined; } /** - * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. + * Transforms a VariableDeclaration into one or more assignment expressions. * - * @param node The ObjectLiteralExpression that contains the MethodDeclaration. - * @param method The MethodDeclaration node. - * @param receiver The receiver for the assignment. + * @param node The VariableDeclaration to transform. + * @param isExported A value used to indicate whether the containing statement was exported. */ - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), - /*location*/ method); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function transformVariable(node, isExported) { + // Hoist any bound names within the declaration. + hoistBindingElement(node, isExported); + if (!node.initializer) { + // If the variable has no initializer, ignore it. + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + // If the variable has an IdentifierName, write out an assignment expression in its place. + return ts.createAssignment(name, node.initializer); + } + else { + // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } - return expression; } /** - * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a - * PropertyAssignment. + * Visits a FunctionDeclaration, hoisting it to the outer module body function. * - * @param node A MethodDeclaration node. + * @param node The function declaration to visit. */ - function visitMethodDeclaration(node) { - // We should only get here for methods on an object literal with regular identifier names. - // 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); - ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, - /*location*/ node); + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + // If the function is exported, ensure it has a name and rewrite the function without any export flags. + var name_38 = node.name || ts.getGeneratedNameForNode(node); + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + var newNode = ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name_38, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node); + // Record a declaration export in the outer module body function. + recordExportedFunctionDeclaration(node); + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name_38); + } + ts.setOriginalNode(newNode, node); + node = newNode; + } + // Hoist the function declaration to the outer module body function. + hoistFunctionDeclaration(node); + return undefined; } - /** - * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. - * - * @param node A ShorthandPropertyAssignment node. - */ - function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), - /*location*/ node); + function visitExpressionStatement(node) { + var originalNode = ts.getOriginalNode(node); + if ((originalNode.kind === 226 /* ModuleDeclaration */ || originalNode.kind === 225 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { + var name_39 = getDeclarationName(originalNode); + // We only need to hoistVariableDeclaration for EnumDeclaration + // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement + // which then call transformsVariable for each declaration in declarationList + if (originalNode.kind === 225 /* EnumDeclaration */) { + hoistVariableDeclaration(name_39); + } + return [ + node, + createExportStatement(name_39, name_39) + ]; + } + return node; } /** - * Visits a YieldExpression node. + * Visits a ClassDeclaration, hoisting its name to the outer module body function. * - * @param node A YieldExpression node. + * @param node The class declaration to visit. */ - function visitYieldExpression(node) { - // `yield` expressions are transformed using the generators transformer. - return ts.visitEachChild(node, visitor, context); + function visitClassDeclaration(node) { + // Hoist the name of the class declaration to the outer module body function. + var name = getDeclarationName(node); + hoistVariableDeclaration(name); + var statements = []; + // Rewrite the class declaration into an assignment of a class expression. + statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node)), + /*location*/ node)); + // If the class was exported, write a declaration export to the inner module body function. + if (ts.hasModifier(node, 1 /* Export */)) { + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name); + } + statements.push(createDeclarationExport(node)); + } + return statements; } - /** - * Visits an ArrayLiteralExpression that contains a spread element. - * - * @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); + function shouldHoistLoopInitializer(node) { + return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; } /** - * Visits a CallExpression that contains either a spread element or `super`. + * Visits the body of a ForStatement to hoist declarations. * - * @param node a CallExpression. + * @param node The statement to visit. */ - function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); - } - function visitImmediateSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); - } - function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - // We are here either because SuperKeyword was used somewhere in the expression, or - // because we contain a SpreadElementExpression. - var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); - } - var resultingCall; - if (node.transformFlags & 262144 /* ContainsSpreadElementExpression */) { - // [source] - // f(...a, b) - // x.m(...a, b) - // super(...a, b) - // super.m(...a, b) // in static - // super.m(...a, b) // in instance - // - // [output] - // f.apply(void 0, a.concat([b])) - // (_a = x).m.apply(_a, a.concat([b])) - // _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)); - } - else { - // [source] - // super(a) - // super.m(a) // in static - // super.m(a) // in instance - // - // [output] - // _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), + function visitForStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var expressions = []; + for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, /*isExported*/ false); + if (visited) { + expressions.push(visited); + } + } + ; + return ts.createFor(expressions.length + ? ts.inlineExpressions(expressions) + : ts.createSynthesizedNode(194 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), /*location*/ node); } - if (node.expression.kind === 95 /* SuperKeyword */) { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis - ? ts.createAssignment(ts.createIdentifier("_this"), initializer) - : initializer; + else { + return ts.visitEachChild(node, visitNestedNode, context); } - return resultingCall; } /** - * Visits a NewExpression that contains a spread element. + * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. * - * @param node A NewExpression node. + * @param node The decalaration list to transform. */ - function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 262144 /* ContainsSpreadElementExpression */) !== 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, []); + function transformForBinding(node) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + hoistBindingElement(firstDeclaration, /*isExported*/ false); + var name = firstDeclaration.name; + return ts.isIdentifier(name) + ? name + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } /** - * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * Visits the body of a ForInStatement to hoist declarations. * - * @param elements The array of Expression nodes. - * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. - * @param multiLine A value indicating whether the result should be emitted on multiple lines. + * @param node The statement to visit. */ - function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { - // [source] - // [a, ...b, c] - // - // [output] - // [a].concat(b, [c]) - // Map spans of spread expressions into their expressions and spans of other - // expressions into an array literal. - var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { - return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); - })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 /* ArrayLiteralExpression */ - ? ts.createArraySlice(segments[0]) - : segments[0]; + function visitForInStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); } - // Rewrite using the pattern .concat(, , ...) - return ts.createArrayConcat(segments.shift(), segments); - } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; - } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.map(chunk, visitExpressionOfSpreadElement); - } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); } /** - * Transforms the expression of a SpreadElementExpression node. + * Visits the body of a ForOfStatement to hoist declarations. * - * @param node A SpreadElementExpression node. + * @param node The statement to visit. */ - function visitExpressionOfSpreadElement(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); + function visitForOfStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } } /** - * Visits a template literal. + * Visits the body of a DoStatement to hoist declarations. * - * @param node A template literal. + * @param node The statement to visit. */ - function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); + function visitDoStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; } /** - * Visits a TaggedTemplateExpression node. + * Visits the body of a WhileStatement to hoist declarations. * - * @param node A TaggedTemplateExpression node. + * @param node The statement to visit. */ - function visitTaggedTemplateExpression(node) { - // Visit the tag expression - var tag = ts.visitNode(node.tag, visitor, ts.isExpression); - // Allocate storage for the template site object - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Build up the template arguments and the raw and cooked strings for the template. - var templateArguments = [temp]; - var cookedStrings = []; - var rawStrings = []; - var template = node.template; - if (ts.isNoSubstitutionTemplateLiteral(template)) { - cookedStrings.push(ts.createLiteral(template.text)); - rawStrings.push(getRawLiteral(template)); - } - else { - cookedStrings.push(ts.createLiteral(template.head.text)); - rawStrings.push(getRawLiteral(template.head)); - for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { - var templateSpan = _a[_i]; - cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); - rawStrings.push(getRawLiteral(templateSpan.literal)); - templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); - } + function visitWhileStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; } - // NOTE: The parentheses here is entirely optional as we are now able to auto- - // parenthesize when rebuilding the tree. This should be removed in a - // future version. It is here for now to match our existing emit. - return ts.createParen(ts.inlineExpressions([ - ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), - ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), - ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) - ])); + return node; } /** - * Creates an ES5 compatible literal from an ES6 template literal. + * Visits the body of a LabeledStatement to hoist declarations. * - * @param node The ES6 template literal. + * @param node The statement to visit. */ - function getRawLiteral(node) { - // Find original source text, since we need to emit the raw strings of the tagged template. - // The raw strings contain the (escaped) strings of what the user wrote. - // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - // Newline normalization: - // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's - // and LineTerminatorSequences are normalized to for both TV and TRV. - text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); + function visitLabeledStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; } /** - * Visits a TemplateExpression node. + * Visits the body of a WithStatement to hoist declarations. * - * @param node A TemplateExpression node. + * @param node The statement to visit. */ - function visitTemplateExpression(node) { - var expressions = []; - addTemplateHead(expressions, node); - addTemplateSpans(expressions, node); - // createAdd will check if each expression binds less closely than binary '+'. - // If it does, it wraps the expression in parentheses. Otherwise, something like - // `abc${ 1 << 2 }` - // becomes - // "abc" + 1 << 2 + "" - // which is really - // ("abc" + 1) << (2 + "") - // rather than - // "abc" + (1 << 2) + "" - var expression = ts.reduceLeft(expressions, ts.createAdd); - if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + function visitWithStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; } - return expression; + return node; } /** - * Gets a value indicating whether we need to include the head of a TemplateExpression. + * Visits the body of a SwitchStatement to hoist declarations. * - * @param node A TemplateExpression node. + * @param node The statement to visit. */ - function shouldAddTemplateHead(node) { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // There is always atleast one templateSpan in this code path, since - // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + function visitSwitchStatement(node) { + var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); + if (caseBlock !== node.caseBlock) { + var updated = ts.getMutableClone(node); + updated.caseBlock = caseBlock; + return updated; + } + return node; } /** - * Adds the head of a TemplateExpression to an array of expressions. + * Visits the body of a CaseBlock to hoist declarations. * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. + * @param node The node to visit. */ - function addTemplateHead(expressions, node) { - if (!shouldAddTemplateHead(node)) { - return; + function visitCaseBlock(node) { + var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); + if (clauses !== node.clauses) { + var updated = ts.getMutableClone(node); + updated.clauses = clauses; + return updated; } - expressions.push(ts.createLiteral(node.head.text)); + return node; } /** - * Visits and adds the template spans of a TemplateExpression to an array of expressions. + * Visits the body of a CaseClause to hoist declarations. * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. + * @param node The clause to visit. */ - function addTemplateSpans(expressions, node) { - for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { - var span_6 = _a[_i]; - expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); - // Only emit if the literal is non-empty. - // The binary '+' operator is left-associative, so the first string concatenation - // with the head will force the result up to this point to be a string. - // Emitting a '+ ""' has no semantic effect for middles and tails. - if (span_6.literal.text.length !== 0) { - expressions.push(ts.createLiteral(span_6.literal.text)); - } + function visitCaseClause(node) { + var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); + if (statements !== node.statements) { + var updated = ts.getMutableClone(node); + updated.statements = statements; + return updated; } + return node; } /** - * Visits the `super` keyword - */ - function visitSuperKeyword(node) { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 174 /* CallExpression */ - ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") - : ts.createIdentifier("_super"); - } - function visitSourceFileNode(node) { - var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; - var statements = []; - startLexicalEnvironment(); - ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); - ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); - ts.addRange(statements, endLexicalEnvironment()); - var clone = ts.getMutableClone(node); - clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); - return clone; - } - /** - * Called by the printer just before a node is printed. + * Visits the body of a DefaultClause to hoist declarations. * - * @param node The node to be printed. + * @param node The clause to visit. */ - 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; - } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + function visitDefaultClause(node) { + return ts.visitEachChild(node, visitNestedNode, context); } /** - * Enables a more costly code path for substitutions when we determine a source file - * contains block-scoped bindings (e.g. `let` or `const`). + * Visits the body of a TryStatement to hoist declarations. + * + * @param node The statement to visit. */ - function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(69 /* Identifier */); + function visitTryStatement(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + /** + * Visits the body of a CatchClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitCatchClause(node) { + var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); + if (block !== node.block) { + var updated = ts.getMutableClone(node); + updated.block = block; + return updated; } + return node; } /** - * Enables a more costly code path for substitutions when we determine a source file - * contains a captured `this`. + * Visits the body of a Block to hoist declarations. + * + * @param node The block to visit. */ - function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(97 /* ThisKeyword */); - context.enableEmitNotification(148 /* Constructor */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(180 /* ArrowFunction */); - context.enableEmitNotification(179 /* FunctionExpression */); - context.enableEmitNotification(220 /* FunctionDeclaration */); + function visitBlock(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + // + // Substitutions + // + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256 /* SourceFile */) { + exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + exportFunctionForFile = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -52856,168 +53267,445 @@ var ts; if (emitContext === 1 /* Expression */) { return substituteExpression(node); } - if (ts.isIdentifier(node)) { - return substituteIdentifier(node); + return node; + } + /** + * Substitute the expression, if necessary. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + return substituteUnaryExpression(node); } return node; } /** - * Hooks substitutions for non-expression identifiers. + * Substitution for identifiers exported at the top level of a module. */ - function substituteIdentifier(node) { - // Only substitute the identifier if we have enabled substitutions for block-scoped - // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var original = ts.getParseTreeNode(node, ts.isIdentifier); - if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + function substituteExpressionIdentifier(node) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + var importBinding = createImportBinding(importDeclaration); + if (importBinding) { + return importBinding; + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind)) { + return substituteAssignmentExpression(node); + } + return node; + } + function substituteAssignmentExpression(node) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var left = node.left; + switch (left.kind) { + case 70 /* Identifier */: + var exportDeclaration = resolver.getReferencedExportContainer(left); + if (exportDeclaration) { + return createExportExpression(left, node); + } + break; + case 172 /* ObjectLiteralExpression */: + case 171 /* ArrayLiteralExpression */: + if (hasExportedReferenceInDestructuringPattern(left)) { + return substituteDestructuring(node); + } + break; + } + return node; + } + function isExportedBinding(name) { + var container = resolver.getReferencedExportContainer(name); + return container && container.kind === 256 /* SourceFile */; + } + function hasExportedReferenceInDestructuringPattern(node) { + switch (node.kind) { + case 70 /* Identifier */: + return isExportedBinding(node); + case 172 /* ObjectLiteralExpression */: + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (hasExportedReferenceInObjectDestructuringElement(property)) { + return true; + } + } + break; + case 171 /* ArrayLiteralExpression */: + for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { + var element = _c[_b]; + if (hasExportedReferenceInArrayDestructuringElement(element)) { + return true; + } + } + break; + } + return false; + } + function hasExportedReferenceInObjectDestructuringElement(node) { + if (ts.isShorthandPropertyAssignment(node)) { + return isExportedBinding(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringElement(node.initializer); + } + else { + return false; + } + } + function hasExportedReferenceInArrayDestructuringElement(node) { + if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else { + return hasExportedReferenceInDestructuringElement(node); + } + } + function hasExportedReferenceInDestructuringElement(node) { + if (ts.isBinaryExpression(node)) { + var left = node.left; + return node.operatorToken.kind === 57 /* EqualsToken */ + && isDestructuringPattern(left) + && hasExportedReferenceInDestructuringPattern(left); + } + else if (ts.isIdentifier(node)) { + return isExportedBinding(node); + } + else if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else if (isDestructuringPattern(node)) { + return hasExportedReferenceInDestructuringPattern(node); + } + else { + return false; + } + } + function isDestructuringPattern(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; + } + function substituteDestructuring(node) { + return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); + } + function substituteUnaryExpression(node) { + var operand = node.operand; + var operator = node.operator; + var substitute = ts.isIdentifier(operand) && + (node.kind === 187 /* PostfixUnaryExpression */ || + (node.kind === 186 /* PrefixUnaryExpression */ && (operator === 42 /* PlusPlusToken */ || operator === 43 /* MinusMinusToken */))); + if (substitute) { + var exportDeclaration = resolver.getReferencedExportContainer(operand); + if (exportDeclaration) { + var expr = ts.createPrefix(node.operator, operand, node); + ts.setEmitFlags(expr, 128 /* NoSubstitution */); + var call = createExportExpression(operand, expr); + if (node.kind === 186 /* PrefixUnaryExpression */) { + return call; + } + else { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + return operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(call, ts.createLiteral(1)) + : ts.createAdd(call, ts.createLiteral(1)); + } } } return node; } /** - * Determines whether a name is the name of a declaration with a colliding name. - * NOTE: This function expects to be called with an original source tree node. - * - * @param node An original source tree node. + * Gets a name to use for a DeclarationStatement. + * @param node The declaration statement. */ - function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 218 /* VariableDeclaration */: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function addExportStarFunction(statements, localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); } - return false; + statements.push(ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, exportStarFunction, + /*typeParameters*/ undefined, [ts.createParameter(m)], + /*type*/ undefined, ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, + /*type*/ undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, /*type*/ undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ])), + ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [exports])) + ], + /*location*/ undefined, + /*multiline*/ true))); + return exportStarFunction; } /** - * Substitutes an expression. - * - * @param node An Expression node. + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. */ - function substituteExpression(node) { + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; + return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); + } + /** + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. + */ + function createExportStatement(name, value) { + return ts.createStatement(createExportExpression(name, value)); + } + /** + * Creates a call to the current file's export function to export a declaration. + * @param node The declaration to export. + */ + function createDeclarationExport(node) { + var declarationName = getDeclarationName(node); + var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; + return createExportStatement(exportName, declarationName); + } + function createImportBinding(importDeclaration) { + var importAlias; + var name; + if (ts.isImportClause(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); + name = ts.createIdentifier("default"); + } + else if (ts.isImportSpecifier(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); + name = importDeclaration.propertyName || importDeclaration.name; + } + else { + return undefined; + } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + } + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } + } + return dependencyGroups; + } + function getNameOfDependencyGroup(dependencyGroup) { + return dependencyGroup.name; + } + function recordExportName(name) { + if (!exportedLocalNames) { + exportedLocalNames = []; + } + exportedLocalNames.push(name); + } + function recordExportedFunctionDeclaration(node) { + if (!exportedFunctionDeclarations) { + exportedFunctionDeclarations = []; + } + exportedFunctionDeclarations.push(createDeclarationExport(node)); + } + function hoistBindingElement(node, isExported) { + if (ts.isOmittedExpression(node)) { + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + if (isExported) { + recordExportName(name); + } + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + } + } + function hoistExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ true); + } + function hoistNonExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ false); + } + function updateSourceFile(node, statements, nodeEmitFlags) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + ts.setEmitFlags(updated, nodeEmitFlags); + return updated; + } + } + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 97 /* ThisKeyword */: - return substituteThisKeyword(node); + case 230 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 236 /* ExportAssignment */: + return visitExportAssignment(node); } return node; } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(253 /* PropertyAssignment */); + return transformSourceFile; /** - * Substitutes an expression identifier. + * Transforms an ES5 source file to ES3. * - * @param node An Identifier node. + * @param node A SourceFile */ - function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); - } - } + function transformSourceFile(node) { return node; } /** - * Substitutes `this` when contained within an arrow function. + * Hooks node substitutions. * - * @param node The ThisKeyword node. + * @param emitContext The context for the emitter. + * @param node The node to substitute. */ - function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); } return node; } /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". + * Substitutes a PropertyAccessExpression whose name is a reserved word. * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + * @param node A PropertyAccessExpression */ - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, /*location*/ node); + } + return node; } /** - * Gets the name of a declaration, without source map or comments. + * Substitutes a PropertyAssignment whose name is a reserved word. * - * @param node The declaration. - * @param allowComments Allow comments for the name. + * @param node A PropertyAssignment */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_39 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_39, emitFlags); - } - return name_39; + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); } - return ts.getGeneratedNameForNode(node); - } - function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); - return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + return node; } - function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { - if (!constructor || !hasExtendsClause) { - return false; - } - var parameter = ts.singleOrUndefined(constructor.parameters); - if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { - return false; - } - var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202 /* ExpressionStatement */) { - return false; - } - var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174 /* CallExpression */) { - return false; - } - var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95 /* SuperKeyword */) { - return false; - } - var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191 /* SpreadElementExpression */) { - return false; + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.createLiteral(name, /*location*/ name); } - var expression = callArgument.expression; - return ts.isIdentifier(expression) && expression === parameter.name; + return undefined; } } - ts.transformES6 = transformES6; + ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /// -/// -/// +/// +/// +/// /// +/// /// /// -/// +/// /* @internal */ var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, @@ -53039,11 +53727,19 @@ var ts; if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); - if (languageVersion < 2 /* ES6 */) { - transformers.push(ts.transformES6); + if (languageVersion < 4 /* ES2017 */) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3 /* ES2016 */) { + transformers.push(ts.transformES2016); + } + if (languageVersion < 2 /* ES2015 */) { + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1 /* ES5 */) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -53073,7 +53769,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -53274,7 +53970,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; /** * Initialize the SourceMapWriter for a new output file. @@ -53548,7 +54244,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } /** @@ -53625,7 +54321,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -53669,7 +54365,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 === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -53756,7 +54452,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -53775,7 +54471,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { writer.write(" "); @@ -53799,7 +54495,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); @@ -53923,7 +54619,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -53979,7 +54675,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 231 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -54013,7 +54709,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -54053,10 +54749,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218 /* VariableDeclaration */) { + if (declaration.kind === 219 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 /* NamedImports */ || declaration.kind === 234 /* ImportSpecifier */ || declaration.kind === 231 /* ImportClause */) { + else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -54074,7 +54770,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 === 230 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 231 /* 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; @@ -54084,12 +54780,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -54206,53 +54902,53 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 166 /* ThisType */: + case 167 /* LiteralType */: return writeTextOfNode(currentText, type); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(type); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(type); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(type); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(type); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(type); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenType(type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(type); - case 69 /* Identifier */: + case 70 /* Identifier */: return emitEntityName(type); - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitEntityName(type); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 139 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 140 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 140 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -54261,14 +54957,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 229 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 230 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 172 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 173 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -54354,7 +55050,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -54377,12 +55073,12 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -54396,7 +55092,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 /* ImportEqualsDeclaration */ || + else if (node.kind === 230 /* ImportEqualsDeclaration */ || (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { @@ -54409,7 +55105,7 @@ var ts; }); } else { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -54427,23 +55123,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return writeVariableStatement(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return writeClassDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -54460,7 +55156,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 222 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -54502,7 +55198,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -54512,7 +55208,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -54536,7 +55232,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 233 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -54557,13 +55253,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 !== 225 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 229 /* ImportEqualsDeclaration */) { + if (parent.kind === 230 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225 /* ModuleDeclaration */) { + else if (parent.kind === 226 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -54633,7 +55329,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226 /* ModuleBlock */) { + while (node.body && node.body.kind !== 227 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -54667,7 +55363,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -54703,7 +55399,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 148 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -54714,50 +55410,50 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 159 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 147 /* MethodDeclaration */ || - node.parent.kind === 146 /* MethodSignature */ || - node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.kind === 151 /* CallSignature */ || - node.parent.kind === 152 /* ConstructSignature */); + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 160 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 148 /* MethodDeclaration */ || + node.parent.kind === 147 /* MethodSignature */ || + node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.kind === 152 /* CallSignature */ || + node.parent.kind === 153 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: 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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* 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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -54785,17 +55481,17 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 94 /* NullKeyword */) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 221 /* ClassDeclaration */) { + if (node.parent.parent.kind === 222 /* 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 : @@ -54879,7 +55575,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 !== 218 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -54890,11 +55586,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */ || - (node.kind === 142 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */ || + (node.kind === 143 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) && node.parent.kind === 159 /* TypeLiteral */) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) && node.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -54907,14 +55603,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* 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 : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) { + else if (node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -54923,7 +55619,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* 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 : @@ -54955,7 +55651,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193 /* OmittedExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { elements.push(element); } } @@ -55025,7 +55721,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 149 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -55038,7 +55734,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 /* GetAccessor */ + return accessor.kind === 150 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -55047,7 +55743,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 151 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -55097,17 +55793,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 /* MethodDeclaration */ || node.kind === 148 /* Constructor */) { + else if (node.kind === 148 /* MethodDeclaration */ || node.kind === 149 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148 /* Constructor */) { + else if (node.kind === 149 /* Constructor */) { write("constructor"); } else { @@ -55127,17 +55823,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 152 /* ConstructSignature */ || node.kind === 157 /* ConstructorType */) { + if (node.kind === 153 /* ConstructSignature */ || node.kind === 158 /* ConstructorType */) { write("new "); } - else if (node.kind === 156 /* FunctionType */) { + else if (node.kind === 157 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -55152,22 +55848,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 156 /* FunctionType */ || node.kind === 157 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 157 /* FunctionType */ || node.kind === 158 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 149 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -55181,26 +55877,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55208,7 +55904,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* 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 : @@ -55222,7 +55918,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220 /* FunctionDeclaration */: + case 221 /* 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 : @@ -55257,9 +55953,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.parent.kind === 159 /* TypeLiteral */) { + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -55275,24 +55971,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55300,7 +55996,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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* 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 : @@ -55313,7 +56009,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 220 /* FunctionDeclaration */: + case 221 /* 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 : @@ -55325,12 +56021,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 167 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -55341,7 +56037,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193 /* OmittedExpression */) { + if (bindingElement.kind === 194 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -55350,7 +56046,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 169 /* BindingElement */) { + else if (bindingElement.kind === 170 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -55373,7 +56069,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 70 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -55389,38 +56085,38 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 222 /* InterfaceDeclaration */: - case 221 /* ClassDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 223 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return writeFunctionDeclaration(node); - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return emitPropertyDeclaration(node); case 255 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); case 256 /* SourceFile */: return emitSourceFile(node); @@ -55448,7 +56144,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path if (isBundledEmit && !addBundledFileReference) { return; @@ -55502,7 +56198,7 @@ var ts; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); @@ -55817,7 +56513,7 @@ var ts; var kind = node.kind; switch (kind) { // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); } } @@ -55831,199 +56527,213 @@ var ts; var kind = node.kind; switch (kind) { // Pseudo-literals - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 82 /* ExportKeyword */: - case 103 /* VoidKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 104 /* VoidKeyword */: // Strict mode reserved words - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 113 /* StaticKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 114 /* StaticKeyword */: // Contextual keywords - case 115 /* AbstractKeyword */: - case 117 /* AnyKeyword */: - case 118 /* AsyncKeyword */: - case 120 /* BooleanKeyword */: - case 122 /* DeclareKeyword */: - case 130 /* NumberKeyword */: - case 128 /* ReadonlyKeyword */: - case 132 /* StringKeyword */: - case 133 /* SymbolKeyword */: - case 137 /* GlobalKeyword */: + case 116 /* AbstractKeyword */: + case 117 /* AsKeyword */: + case 118 /* AnyKeyword */: + case 119 /* AsyncKeyword */: + case 120 /* AwaitKeyword */: + case 121 /* BooleanKeyword */: + case 122 /* ConstructorKeyword */: + case 123 /* DeclareKeyword */: + case 124 /* GetKeyword */: + case 125 /* IsKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 128 /* NeverKeyword */: + case 129 /* ReadonlyKeyword */: + case 130 /* RequireKeyword */: + case 131 /* NumberKeyword */: + case 132 /* SetKeyword */: + case 133 /* StringKeyword */: + case 134 /* SymbolKeyword */: + case 135 /* TypeKeyword */: + case 136 /* UndefinedKeyword */: + case 137 /* FromKeyword */: + case 138 /* GlobalKeyword */: + case 139 /* OfKeyword */: writeTokenText(kind); return; // Parse tree nodes // Names - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitQualifiedName(node); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return emitTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return emitParameter(node); - case 143 /* Decorator */: + case 144 /* Decorator */: return emitDecorator(node); // Type members - case 144 /* PropertySignature */: + case 145 /* PropertySignature */: return emitPropertySignature(node); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 146 /* MethodSignature */: + case 147 /* MethodSignature */: return emitMethodSignature(node); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return emitConstructor(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 151 /* CallSignature */: + case 152 /* CallSignature */: return emitCallSignature(node); - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return emitConstructSignature(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return emitIndexSignature(node); // Types - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(node); - case 156 /* FunctionType */: + case 157 /* FunctionType */: return emitFunctionType(node); - case 157 /* ConstructorType */: + case 158 /* ConstructorType */: return emitConstructorType(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(node); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(node); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenthesizedType(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 165 /* ThisType */: - return emitThisType(node); - case 166 /* LiteralType */: + case 166 /* ThisType */: + return emitThisType(); + case 167 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return emitBindingElement(node); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return emitTemplateSpan(node); - case 198 /* SemicolonClassElement */: - return emitSemicolonClassElement(node); + case 199 /* SemicolonClassElement */: + return emitSemicolonClassElement(); // Statements - case 199 /* Block */: + case 200 /* Block */: return emitBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitVariableStatement(node); - case 201 /* EmptyStatement */: - return emitEmptyStatement(node); - case 202 /* ExpressionStatement */: + case 202 /* EmptyStatement */: + return emitEmptyStatement(); + case 203 /* ExpressionStatement */: return emitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return emitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return emitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return emitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return emitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return emitForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return emitForOfStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return emitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return emitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return emitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return emitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return emitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return emitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return emitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return emitTryStatement(node); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return emitClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return emitModuleBlock(node); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return emitCaseBlock(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return emitImportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return emitImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return emitNamespaceImport(node); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return emitNamedImports(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return emitImportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 237 /* NamedExports */: + case 238 /* NamedExports */: return emitNamedExports(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return emitExportSpecifier(node); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return; // Module references - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 244 /* JsxText */: + case 10 /* JsxText */: return emitJsxText(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return emitJsxOpeningElement(node); case 245 /* JsxClosingElement */: return emitJsxClosingElement(node); @@ -56070,77 +56780,77 @@ var ts; case 8 /* NumericLiteral */: return emitNumericLiteral(node); case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 99 /* TrueKeyword */: - case 97 /* ThisKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 100 /* TrueKeyword */: + case 98 /* ThisKeyword */: writeTokenText(kind); return; // Expressions - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return emitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emitNewExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return emitFunctionExpression(node); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return emitArrowFunction(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return emitDeleteExpression(node); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return emitVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return emitAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return emitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return emitConditionalExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return emitTemplateExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return emitYieldExpression(node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return emitClassExpression(node); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return; - case 195 /* AsExpression */: + case 196 /* AsExpression */: return emitAsExpression(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return emitJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes case 288 /* PartiallyEmittedExpression */: @@ -56193,7 +56903,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -56269,7 +56979,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 150 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -56297,7 +57007,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } // @@ -56354,7 +57064,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -56428,7 +57138,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -56446,7 +57156,7 @@ var ts; if (expression.kind === 8 /* NumericLiteral */) { // check if numeric literal was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -56465,11 +57175,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { @@ -56541,16 +57253,16 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 185 /* PrefixUnaryExpression */ - && ((node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) - || (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */))); + return operand.kind === 186 /* PrefixUnaryExpression */ + && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) + || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 25 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -56617,16 +57329,16 @@ var ts; // // Statements // - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); write(" "); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } else { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } function emitBlockStatements(node) { @@ -56642,7 +57354,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -56650,16 +57362,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88 /* IfKeyword */, node.pos, node); + var openParenPos = writeToken(89 /* IfKeyword */, node.pos, node); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, node); + writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end, node); + writeToken(19 /* CloseParenToken */, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 203 /* IfStatement */) { + writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); + if (node.elseStatement.kind === 204 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -56688,9 +57400,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, /*contextNode*/ node); + writeToken(18 /* OpenParenToken */, openParenPos, /*contextNode*/ node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -56700,28 +57412,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { emit(node); } else { @@ -56730,17 +57442,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75 /* ContinueKeyword */, node.pos); + writeToken(76 /* ContinueKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70 /* BreakKeyword */, node.pos); + writeToken(71 /* BreakKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + writeToken(95 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -56751,11 +57463,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96 /* SwitchKeyword */, node.pos); + var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); write(" "); emit(node.caseBlock); } @@ -56780,7 +57492,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76 /* DebuggerKeyword */, node.pos); + writeToken(77 /* DebuggerKeyword */, node.pos); write(";"); } // @@ -56788,6 +57500,7 @@ var ts; // function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -56814,13 +57527,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304 /* ReuseTempVariableScope */) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -56843,7 +57556,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { // We must emit a function body as a single-line body in the following case: // * The body has NodeEmitFlags.SingleLine specified. // We must emit a function body as a multi-line body in the following cases: @@ -56873,14 +57586,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16 /* CloseBraceToken */, body.statements.end, body); + writeToken(17 /* CloseBraceToken */, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -56959,7 +57672,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225 /* ModuleDeclaration */) { + while (body.kind === 226 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -56982,9 +57695,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15 /* OpenBraceToken */, node.pos); + writeToken(16 /* OpenBraceToken */, node.pos); emitList(node, node.clauses, 65 /* CaseBlockClauses */); - writeToken(16 /* CloseBraceToken */, node.clauses.end); + writeToken(17 /* CloseBraceToken */, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -56995,7 +57708,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57121,7 +57834,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57164,11 +57877,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72 /* CatchKeyword */, node.pos); + var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emit(node.variableDeclaration); - writeToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -57279,7 +57992,7 @@ var ts; var helpersEmitted = false; // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { + if ((languageVersion < 2 /* ES2015 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; helpersEmitted = true; @@ -57301,9 +58014,12 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */) { + // Only emit __awaiter function when target ES5/ES6. + // Only emit __generator function when target ES5. + // For target ES2017 and above, we can emit async/await as is. + if ((languageVersion < 4 /* ES2017 */) && (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */)) { writeLines(awaiterHelper); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { writeLines(generatorHelper); } awaiterEmitted = true; @@ -57630,7 +58346,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -57755,19 +58471,19 @@ var ts; */ function generateNameForNode(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 230 /* ImportDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: - case 235 /* ExportAssignment */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 236 /* ExportAssignment */: return generateNameForExportDefault(); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58440,7 +59156,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -58530,7 +59246,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -58563,14 +59279,14 @@ var ts; // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -58580,16 +59296,16 @@ var ts; return false; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -58598,29 +59314,29 @@ var ts; break; case 251 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 106 /* ImplementsKeyword */) { + if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -58628,20 +59344,20 @@ var ts; return true; } break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -58649,7 +59365,7 @@ var ts; return true; } break; - case 142 /* Parameter */: + case 143 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -58665,12 +59381,12 @@ var ts; return true; } break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113 /* StaticKeyword */) { + if (modifier.kind !== 114 /* StaticKeyword */) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -58680,14 +59396,14 @@ var ts; return true; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 143 /* Decorator */: + case 144 /* Decorator */: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, 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)); } @@ -58715,19 +59431,19 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 128 /* ReadonlyKeyword */: - case 122 /* DeclareKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 123 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 113 /* StaticKeyword */: - case 82 /* ExportKeyword */: - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 115 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 83 /* ExportKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 116 /* AbstractKeyword */: } } } @@ -58761,7 +59477,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, /*isReference*/ true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -58802,9 +59518,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -58819,7 +59535,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225 /* ModuleDeclaration */: + case 226 /* 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. @@ -58859,7 +59575,7 @@ var ts; /** * 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration) */ - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -58867,7 +59583,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -58877,13 +59593,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -58908,7 +59624,7 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -58921,16 +59637,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -58959,13 +59675,12 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } // always process imported modules to record module name resolutions - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -58975,10 +59690,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, /*isReference*/ true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -59004,7 +59719,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -59019,7 +59734,7 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } } } @@ -59045,7 +59760,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -59071,7 +59786,7 @@ var ts; } else if (shouldAddFile) { findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), - /*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -59200,7 +59915,7 @@ var ts; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES6 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -59209,7 +59924,7 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span_7.start, span_7.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span_8 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_8.start, span_8.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -59250,7 +59965,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -59261,12 +59976,12 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } // Report error if multiple files write into same file if (emitFilesSeen.contains(emitFilePath)) { // Already seen the same emit file - report error - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -59274,7 +59989,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -59294,24 +60009,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -59326,7 +60041,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -59336,15 +60051,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -59353,7 +60068,7 @@ var ts; "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -59362,18 +60077,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -59384,11 +60099,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -59397,12 +60112,12 @@ var ts; "lf": 1 /* LineFeed */ }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -59411,7 +60126,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -59420,60 +60135,60 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, // for correct behaviour, please use outFile - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -59496,30 +60211,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -59530,7 +60245,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -59544,23 +60259,25 @@ var ts; type: ts.createMap({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, - "es6": 2 /* ES6 */, - "es2015": 2 /* ES2015 */ + "es6": 2 /* ES2015 */, + "es2015": 2 /* ES2015 */, + "es2016": 3 /* ES2016 */, + "es2017": 4 /* ES2017 */, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -59577,10 +60294,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -59710,7 +60427,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -59738,7 +60455,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -59762,7 +60479,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; /* @internal */ @@ -59784,10 +60501,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -60592,7 +61306,7 @@ var ts; StringScriptSnapshot.prototype.getLength = function () { return this.text.length; }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + StringScriptSnapshot.prototype.getChangeRange = function () { // Text-based snapshots do not support incremental parsing. Return undefined // to signal that to the caller. return undefined; @@ -60814,7 +61528,7 @@ var ts; /* @internal */ var ts; (function (ts) { - ts.scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); ts.emptyArray = []; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -60826,33 +61540,33 @@ var ts; var SemanticMeaning = ts.SemanticMeaning; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 252 /* CatchClause */: return 1 /* Value */; - case 141 /* TypeParameter */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 159 /* TypeLiteral */: + case 142 /* TypeParameter */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 160 /* TypeLiteral */: return 2 /* Type */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -60862,12 +61576,12 @@ var ts; else { return 4 /* Namespace */; } - case 233 /* NamedImports */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: - case 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 234 /* NamedImports */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value case 256 /* SourceFile */: @@ -60877,7 +61591,7 @@ var ts; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent.kind === 236 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -60898,19 +61612,19 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69 /* Identifier */); + ts.Debug.assert(node.kind === 70 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 139 /* QualifiedName */ && + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 229 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 230 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 139 /* QualifiedName */) { + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -60921,27 +61635,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 139 /* QualifiedName */) { - while (root.parent && root.parent.kind === 139 /* QualifiedName */) { + if (root.parent.kind === 140 /* QualifiedName */) { + while (root.parent && root.parent.kind === 140 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 155 /* TypeReference */ && !isLastClause; + return root.parent.kind === 156 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 172 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 172 /* PropertyAccessExpression */) { + if (root.parent.kind === 173 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 173 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 195 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 221 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 222 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 222 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 223 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -60949,17 +61663,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 155 /* TypeReference */ || - (node.parent.kind === 194 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 165 /* ThisType */; + return node.parent.kind === 156 /* TypeReference */ || + (node.parent.kind === 195 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || + node.kind === 166 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 175 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -60972,7 +61686,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 214 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -60981,14 +61695,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 69 /* Identifier */ && - (node.parent.kind === 210 /* BreakStatement */ || node.parent.kind === 209 /* ContinueStatement */) && + return node.kind === 70 /* Identifier */ && + (node.parent.kind === 211 /* BreakStatement */ || node.parent.kind === 210 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 69 /* Identifier */ && - node.parent.kind === 214 /* LabeledStatement */ && + return node.kind === 70 /* Identifier */ && + node.parent.kind === 215 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -60996,38 +61710,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 226 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 226 /* ModuleDeclaration */: return node.parent.name === node; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return true; } } @@ -61077,16 +61791,16 @@ var ts; } switch (node.kind) { case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return node; } } @@ -61096,42 +61810,42 @@ var ts; switch (node.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 222 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 223 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 224 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 218 /* VariableDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 224 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 225 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 219 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 149 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 150 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 150 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 151 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 153 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 152 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 151 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 148 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 141 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 154 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 153 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 152 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 149 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 142 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 142 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229 /* ImportEqualsDeclaration */: - case 234 /* ImportSpecifier */: - case 231 /* ImportClause */: - case 238 /* ExportSpecifier */: - case 232 /* NamespaceImport */: + case 143 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230 /* ImportEqualsDeclaration */: + case 235 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 239 /* ExportSpecifier */: + case 233 /* NamespaceImport */: return ts.ScriptElementKind.alias; case 279 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; @@ -61148,7 +61862,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 167 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -61158,12 +61872,12 @@ var ts; ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 69 /* Identifier */: + case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143 /* Parameter */; default: return false; } @@ -61208,42 +61922,42 @@ var ts; return false; } switch (n.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 167 /* ObjectBindingPattern */: - case 159 /* TypeLiteral */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 227 /* CaseBlock */: - case 233 /* NamedImports */: - case 237 /* NamedExports */: - return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 168 /* ObjectBindingPattern */: + case 160 /* TypeLiteral */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 228 /* CaseBlock */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: + return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); case 252 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 175 /* NewExpression */: + case 176 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 174 /* CallExpression */: - case 178 /* ParenthesizedExpression */: - case 164 /* ParenthesizedType */: - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 175 /* CallExpression */: + case 179 /* ParenthesizedExpression */: + case 165 /* ParenthesizedType */: + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 181 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -61252,68 +61966,68 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 225 /* ModuleDeclaration */: + return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); + case 226 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 203 /* IfStatement */: + case 204 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23 /* SemicolonToken */); - case 170 /* ArrayLiteralExpression */: - case 168 /* ArrayBindingPattern */: - case 173 /* ElementAccessExpression */: - case 140 /* ComputedPropertyName */: - case 161 /* TupleType */: - return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 153 /* IndexSignature */: + hasChildOfKind(n, 24 /* SemicolonToken */); + case 171 /* ArrayLiteralExpression */: + case 169 /* ArrayBindingPattern */: + case 174 /* ElementAccessExpression */: + case 141 /* ComputedPropertyName */: + case 162 /* TupleType */: + return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); + case 154 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); case 249 /* CaseClause */: case 250 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 182 /* TypeOfExpression */: - case 181 /* DeleteExpression */: - case 183 /* VoidExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: + case 183 /* TypeOfExpression */: + case 182 /* DeleteExpression */: + case 184 /* VoidExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 236 /* ExportDeclaration */: - case 230 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -61331,7 +62045,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 24 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -61504,7 +62218,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61512,7 +62226,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61526,10 +62240,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 244 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 10 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 244 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 10 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -61592,25 +62306,25 @@ var ts; if (!token) { return false; } - if (token.kind === 244 /* JsxText */) { + if (token.kind === 10 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 244 /* JsxText */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 16 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
|
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { return true; } return false; @@ -61667,9 +62381,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -61722,21 +62436,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 /* TypeReference */ || node.kind === 174 /* CallExpression */) { + if (node.kind === 156 /* TypeReference */ || node.kind === 175 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 221 /* ClassDeclaration */ || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 138 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 139 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 69 /* Identifier */ || ts.isKeyword(kind); + return kind === 70 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -61748,7 +62462,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 10 /* RegularExpressionLiteral */ + || kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -61756,7 +62470,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; + return 16 /* FirstPunctuation */ <= kind && kind <= 69 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -61766,9 +62480,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: return true; } return false; @@ -61791,18 +62505,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 /* ArrayLiteralExpression */ || - node.kind === 171 /* ObjectLiteralExpression */) { + if (node.kind === 171 /* ArrayLiteralExpression */ || + node.kind === 172 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 187 /* BinaryExpression */ && + if (node.parent.kind === 188 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 208 /* ForOfStatement */ && + if (node.parent.kind === 209 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -61843,7 +62557,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -61896,7 +62610,7 @@ var ts; } } function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3 /* Variable */) { @@ -61945,7 +62659,7 @@ var ts; } } ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { + function displayPart(text, kind) { return { text: text, kind: ts.SymbolDisplayPartKind[kind] @@ -62023,7 +62737,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140 /* ComputedPropertyName */) { + location.parent.kind === 141 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -62035,7 +62749,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 234 /* ImportSpecifier */ || location.parent.kind === 238 /* ExportSpecifier */) && + (location.parent.kind === 235 /* ImportSpecifier */ || location.parent.kind === 239 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -62081,7 +62795,7 @@ var ts; var options = { fileName: "config.js", compilerOptions: { - target: 2 /* ES6 */, + target: 2 /* ES2015 */, removeComments: true }, reportDiagnostics: true @@ -62107,24 +62821,24 @@ var ts; (function (ts) { /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[69 /* Identifier */] = true; + noRegexTable[70 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; - noRegexTable[10 /* RegularExpressionLiteral */] = true; - noRegexTable[97 /* ThisKeyword */] = true; - noRegexTable[41 /* PlusPlusToken */] = true; - noRegexTable[42 /* MinusMinusToken */] = true; - noRegexTable[18 /* CloseParenToken */] = true; - noRegexTable[20 /* CloseBracketToken */] = true; - noRegexTable[16 /* CloseBraceToken */] = true; - noRegexTable[99 /* TrueKeyword */] = true; - noRegexTable[84 /* FalseKeyword */] = true; + noRegexTable[11 /* RegularExpressionLiteral */] = true; + noRegexTable[98 /* ThisKeyword */] = true; + noRegexTable[42 /* PlusPlusToken */] = true; + noRegexTable[43 /* MinusMinusToken */] = true; + noRegexTable[19 /* CloseParenToken */] = true; + noRegexTable[21 /* CloseBracketToken */] = true; + noRegexTable[17 /* CloseBraceToken */] = true; + noRegexTable[100 /* TrueKeyword */] = true; + noRegexTable[85 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -62149,10 +62863,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 123 /* GetKeyword */ || - keyword2 === 131 /* SetKeyword */ || - keyword2 === 121 /* ConstructorKeyword */ || - keyword2 === 113 /* StaticKeyword */) { + if (keyword2 === 124 /* GetKeyword */ || + keyword2 === 132 /* SetKeyword */ || + keyword2 === 122 /* ConstructorKeyword */ || + keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -62251,7 +62965,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(12 /* TemplateHead */); + templateStack.push(13 /* TemplateHead */); break; } scanner.setText(text); @@ -62282,71 +62996,71 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { - token = 10 /* RegularExpressionLiteral */; + if ((token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11 /* RegularExpressionLiteral */) { + token = 11 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 69 /* Identifier */; + else if (lastNonTriviaToken === 22 /* DotToken */ && isKeyword(token)) { + token = 70 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 69 /* Identifier */; + token = 70 /* Identifier */; } - else if (lastNonTriviaToken === 69 /* Identifier */ && - token === 25 /* LessThanToken */) { + else if (lastNonTriviaToken === 70 /* Identifier */ && + token === 26 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 28 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 117 /* AnyKeyword */ || - token === 132 /* StringKeyword */ || - token === 130 /* NumberKeyword */ || - token === 120 /* BooleanKeyword */ || - token === 133 /* SymbolKeyword */) { + else if (token === 118 /* AnyKeyword */ || + token === 133 /* StringKeyword */ || + token === 131 /* NumberKeyword */ || + token === 121 /* BooleanKeyword */ || + token === 134 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 69 /* Identifier */; + token = 70 /* Identifier */; } } - else if (token === 12 /* TemplateHead */) { + else if (token === 13 /* TemplateHead */) { templateStack.push(token); } - else if (token === 15 /* OpenBraceToken */) { + else if (token === 16 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12 /* TemplateHead */) { + if (lastTemplateStackToken === 13 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 14 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 16 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -62387,10 +63101,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 11 /* NoSubstitutionTemplateLiteral */) { + else if (token === 12 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -62398,7 +63112,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -62428,43 +63142,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - case 46 /* AmpersandToken */: - case 48 /* CaretToken */: - case 47 /* BarToken */: - case 51 /* AmpersandAmpersandToken */: - case 52 /* BarBarToken */: - case 67 /* BarEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 56 /* EqualsToken */: - case 24 /* CommaToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: + case 47 /* AmpersandToken */: + case 49 /* CaretToken */: + case 48 /* BarToken */: + case 52 /* AmpersandAmpersandToken */: + case 53 /* BarBarToken */: + case 68 /* BarEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 57 /* EqualsToken */: + case 25 /* CommaToken */: return true; default: return false; @@ -62472,19 +63186,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 138 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 139 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -62493,7 +63207,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { + else if (token >= 16 /* FirstPunctuation */ && token <= 69 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -62501,7 +63215,7 @@ var ts; return 4 /* numericLiteral */; case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -62510,7 +63224,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 69 /* Identifier */: + case 70 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -62541,10 +63255,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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -62595,7 +63309,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 /* ModuleDeclaration */ && + return declaration.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -62605,7 +63319,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 70 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -62674,8 +63388,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -62839,10 +63553,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 244 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -62855,7 +63569,7 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } @@ -62865,7 +63579,7 @@ var ts; return 20 /* jsxCloseTagName */; } break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } @@ -62887,7 +63601,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { + if (tokenKind === 26 /* LessThanToken */ || tokenKind === 28 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -62896,19 +63610,19 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 56 /* EqualsToken */) { + if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 218 /* VariableDeclaration */ || - token.parent.kind === 145 /* PropertyDeclaration */ || - token.parent.kind === 142 /* Parameter */ || + if (token.parent.kind === 219 /* VariableDeclaration */ || + token.parent.kind === 146 /* PropertyDeclaration */ || + token.parent.kind === 143 /* Parameter */ || token.parent.kind === 246 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 187 /* BinaryExpression */ || - token.parent.kind === 185 /* PrefixUnaryExpression */ || - token.parent.kind === 186 /* PostfixUnaryExpression */ || - token.parent.kind === 188 /* ConditionalExpression */) { + if (token.parent.kind === 188 /* BinaryExpression */ || + token.parent.kind === 186 /* PrefixUnaryExpression */ || + token.parent.kind === 187 /* PostfixUnaryExpression */ || + token.parent.kind === 189 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -62920,7 +63634,7 @@ var ts; else if (tokenKind === 9 /* StringLiteral */) { return token.parent.kind === 246 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } - else if (tokenKind === 10 /* RegularExpressionLiteral */) { + else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -62928,38 +63642,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 244 /* JsxText */) { + else if (tokenKind === 10 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 69 /* Identifier */) { + else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 142 /* Parameter */: + case 143 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -62989,6 +63703,7 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); +/// /* @internal */ var ts; (function (ts) { @@ -63028,7 +63743,7 @@ var ts; name: tagName.text, kind: undefined, kindModifiers: undefined, - sortText: "0" + sortText: "0", }); } else { @@ -63085,7 +63800,7 @@ var ts; name: displayName, kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" + sortText: "0", }; } function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { @@ -63113,7 +63828,7 @@ var ts; return undefined; } if (node.parent.kind === 253 /* PropertyAssignment */ && - node.parent.parent.kind === 171 /* ObjectLiteralExpression */ && + node.parent.parent.kind === 172 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -63138,7 +63853,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 230 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 231 /* 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*/"); @@ -63151,7 +63866,7 @@ var ts; // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" @@ -63168,7 +63883,7 @@ var ts; } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { var candidates = []; var entries = []; typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); @@ -63531,7 +64246,7 @@ var ts; if (typeRoots) { for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -63540,12 +64255,12 @@ var ts; for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { var packageJson = _d[_c]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { + function getCompletionEntriesFromDirectories(host, directory, span, result) { if (host.getDirectories && tryDirectoryExists(host, directory)) { var directories = tryGetDirectories(host, directory); if (directories) { @@ -63769,12 +64484,12 @@ var ts; return undefined; } var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21 /* DotToken */) { - if (parent_17.kind === 172 /* PropertyAccessExpression */) { + if (kind === 22 /* DotToken */) { + if (parent_17.kind === 173 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139 /* QualifiedName */) { + else if (parent_17.kind === 140 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -63785,11 +64500,11 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 25 /* LessThanToken */) { + if (kind === 26 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -63830,7 +64545,6 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; @@ -63839,7 +64553,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -63895,10 +64609,9 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 242 /* JsxSelfClosingElement */) || (jsxContainer.kind === 243 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -63942,6 +64655,13 @@ var ts; previousToken.getStart() : position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 /* SourceFile */ || + scopeNode.kind === 190 /* TemplateExpression */ || + scopeNode.kind === 248 /* JsxExpression */ || + ts.isStatement(scopeNode); + } /// TODO filter meaning based on the current context var symbolMeanings = 793064 /* Type */ | 107455 /* Value */ | 1920 /* Namespace */ | 8388608 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); @@ -63968,15 +64688,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 244 /* JsxText */) { + if (contextToken.kind === 10 /* JsxText */) { return true; } - if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 243 /* JsxOpeningElement */) { + if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 242 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241 /* JsxElement */; + if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 243 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242 /* JsxElement */; } } return false; @@ -63985,41 +64705,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 174 /* CallExpression */ // func( a, | - || containingNodeKind === 148 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 175 /* NewExpression */ // new C(a, | - || containingNodeKind === 170 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 187 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 156 /* FunctionType */; // var x: (s: string, list| - case 17 /* OpenParenToken */: - return containingNodeKind === 174 /* CallExpression */ // func( | - || containingNodeKind === 148 /* Constructor */ // constructor( | - || containingNodeKind === 175 /* NewExpression */ // new C(a| - || containingNodeKind === 178 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 164 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 19 /* OpenBracketToken */: - return containingNodeKind === 170 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 153 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 140 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 125 /* ModuleKeyword */: // module | - case 126 /* NamespaceKeyword */: + case 25 /* CommaToken */: + return containingNodeKind === 175 /* CallExpression */ // func( a, | + || containingNodeKind === 149 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 176 /* NewExpression */ // new C(a, | + || containingNodeKind === 171 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 188 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 157 /* FunctionType */; // var x: (s: string, list| + case 18 /* OpenParenToken */: + return containingNodeKind === 175 /* CallExpression */ // func( | + || containingNodeKind === 149 /* Constructor */ // constructor( | + || containingNodeKind === 176 /* NewExpression */ // new C(a| + || containingNodeKind === 179 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 165 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 20 /* OpenBracketToken */: + return containingNodeKind === 171 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 154 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 141 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 126 /* ModuleKeyword */: // module | + case 127 /* NamespaceKeyword */: return true; - case 21 /* DotToken */: - return containingNodeKind === 225 /* ModuleDeclaration */; // module A.| - case 15 /* OpenBraceToken */: - return containingNodeKind === 221 /* ClassDeclaration */; // class A{ | - case 56 /* EqualsToken */: - return containingNodeKind === 218 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 187 /* BinaryExpression */; // x = a| - case 12 /* TemplateHead */: - return containingNodeKind === 189 /* TemplateExpression */; // `aa ${| - case 13 /* TemplateMiddle */: - return containingNodeKind === 197 /* TemplateSpan */; // `aa ${10} dd ${| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; // class A{ public | + case 22 /* DotToken */: + return containingNodeKind === 226 /* ModuleDeclaration */; // module A.| + case 16 /* OpenBraceToken */: + return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + case 57 /* EqualsToken */: + return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 188 /* BinaryExpression */; // x = a| + case 13 /* TemplateHead */: + return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + case 14 /* TemplateMiddle */: + return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -64033,7 +64753,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 10 /* RegularExpressionLiteral */ + || contextToken.kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -64046,7 +64766,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 10 /* RegularExpressionLiteral */; + || contextToken.kind === 11 /* RegularExpressionLiteral */; } } return false; @@ -64062,7 +64782,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 171 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -64072,7 +64792,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 167 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -64083,11 +64803,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 143 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 147 /* MethodDeclaration */ || rootDeclaration.parent.kind === 150 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 148 /* MethodDeclaration */ || rootDeclaration.parent.kind === 151 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -64129,9 +64849,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 /* NamedImports */ ? - 230 /* ImportDeclaration */ : - 236 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 234 /* NamedImports */ ? + 231 /* ImportDeclaration */ : + 237 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -64154,10 +64874,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // const x = { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // const x = { | + case 25 /* CommaToken */: var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { + if (parent_18 && (parent_18.kind === 172 /* ObjectLiteralExpression */ || parent_18.kind === 168 /* ObjectBindingPattern */)) { return parent_18; } break; @@ -64172,11 +64892,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // import { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // import { | + case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return contextToken.parent; } } @@ -64187,12 +64907,12 @@ var ts; if (contextToken) { var parent_19 = contextToken.parent; switch (contextToken.kind) { - case 26 /* LessThanSlashToken */: - case 39 /* SlashToken */: - case 69 /* Identifier */: + case 27 /* LessThanSlashToken */: + case 40 /* SlashToken */: + case 70 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { + if (parent_19 && (parent_19.kind === 243 /* JsxSelfClosingElement */ || parent_19.kind === 244 /* JsxOpeningElement */)) { return parent_19; } else if (parent_19.kind === 246 /* JsxAttribute */) { @@ -64207,7 +64927,7 @@ var ts; return parent_19.parent; } break; - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: if (parent_19 && parent_19.kind === 248 /* JsxExpression */ && parent_19.parent && @@ -64224,16 +64944,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return true; } return false; @@ -64244,67 +64964,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 218 /* VariableDeclaration */ || - containingNodeKind === 219 /* VariableDeclarationList */ || - containingNodeKind === 200 /* VariableStatement */ || - containingNodeKind === 224 /* EnumDeclaration */ || + case 25 /* CommaToken */: + return containingNodeKind === 219 /* VariableDeclaration */ || + containingNodeKind === 220 /* VariableDeclarationList */ || + containingNodeKind === 201 /* VariableStatement */ || + containingNodeKind === 225 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 168 /* ArrayBindingPattern */ || - containingNodeKind === 223 /* TypeAliasDeclaration */; // type Map, K, | - case 21 /* DotToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [.| - case 54 /* ColonToken */: - return containingNodeKind === 169 /* BindingElement */; // var {x :html| - case 19 /* OpenBracketToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [x| - case 17 /* OpenParenToken */: + containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 169 /* ArrayBindingPattern */ || + containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + case 22 /* DotToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + case 55 /* ColonToken */: + return containingNodeKind === 170 /* BindingElement */; // var {x :html| + case 20 /* OpenBracketToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + case 18 /* OpenParenToken */: return containingNodeKind === 252 /* CatchClause */ || isFunction(containingNodeKind); - case 15 /* OpenBraceToken */: - return containingNodeKind === 224 /* EnumDeclaration */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* TypeLiteral */; // const x : { | - case 23 /* SemicolonToken */: - return containingNodeKind === 144 /* PropertySignature */ && + case 16 /* OpenBraceToken */: + return containingNodeKind === 225 /* EnumDeclaration */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* TypeLiteral */; // const x : { | + case 24 /* SemicolonToken */: + return containingNodeKind === 145 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 159 /* TypeLiteral */); // const x : { a; | - case 25 /* LessThanToken */: - return containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 223 /* TypeAliasDeclaration */ || + (contextToken.parent.parent.kind === 223 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 160 /* TypeLiteral */); // const x : { a; | + case 26 /* LessThanToken */: + return containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 224 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 113 /* StaticKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; - case 22 /* DotDotDotToken */: - return containingNodeKind === 142 /* Parameter */ || + case 114 /* StaticKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; + case 23 /* DotDotDotToken */: + return containingNodeKind === 143 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168 /* ArrayBindingPattern */); // var [...z| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 142 /* Parameter */; - case 116 /* AsKeyword */: - return containingNodeKind === 234 /* ImportSpecifier */ || - containingNodeKind === 238 /* ExportSpecifier */ || - containingNodeKind === 232 /* NamespaceImport */; - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 107 /* InterfaceKeyword */: - case 87 /* FunctionKeyword */: - case 102 /* VarKeyword */: - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - case 89 /* ImportKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 114 /* YieldKeyword */: - case 134 /* TypeKeyword */: + contextToken.parent.parent.kind === 169 /* ArrayBindingPattern */); // var [...z| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 143 /* Parameter */; + case 117 /* AsKeyword */: + return containingNodeKind === 235 /* ImportSpecifier */ || + containingNodeKind === 239 /* ExportSpecifier */ || + containingNodeKind === 233 /* NamespaceImport */; + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 108 /* InterfaceKeyword */: + case 88 /* FunctionKeyword */: + case 103 /* VarKeyword */: + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + case 90 /* ImportKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 115 /* YieldKeyword */: + case 135 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -64376,8 +65096,8 @@ var ts; // Ignore omitted expressions for missing members if (m.kind !== 253 /* PropertyAssignment */ && m.kind !== 254 /* ShorthandPropertyAssignment */ && - m.kind !== 169 /* BindingElement */ && - m.kind !== 147 /* MethodDeclaration */) { + m.kind !== 170 /* BindingElement */ && + m.kind !== 148 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -64385,9 +65105,9 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 169 /* BindingElement */ && m.propertyName) { + if (m.kind === 170 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 69 /* Identifier */) { + if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; } } @@ -64465,7 +65185,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 138 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 139 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -64540,10 +65260,10 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 97 /* ThisKeyword */ || - node.kind === 165 /* ThisType */ || - node.kind === 95 /* SuperKeyword */ || + if (node.kind === 70 /* Identifier */ || + node.kind === 98 /* ThisKeyword */ || + node.kind === 166 /* ThisType */ || + node.kind === 96 /* SuperKeyword */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); @@ -64594,77 +65314,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 88 /* IfKeyword */: - case 80 /* ElseKeyword */: - if (hasKind(node.parent, 203 /* IfStatement */)) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 204 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 211 /* ReturnStatement */)) { + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 212 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 215 /* ThrowStatement */)) { + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 216 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 216 /* TryStatement */)) { + case 73 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 100 /* TryKeyword */: - case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 216 /* TryStatement */)) { + case 101 /* TryKeyword */: + case 86 /* FinallyKeyword */: + if (hasKind(parent(node), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 213 /* SwitchStatement */)) { + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 71 /* CaseKeyword */: - case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 213 /* SwitchStatement */)) { + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 70 /* BreakKeyword */: - case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 210 /* BreakStatement */) || hasKind(node.parent, 209 /* ContinueStatement */)) { + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 211 /* BreakStatement */) || hasKind(node.parent, 210 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 86 /* ForKeyword */: - if (hasKind(node.parent, 206 /* ForStatement */) || - hasKind(node.parent, 207 /* ForInStatement */) || - hasKind(node.parent, 208 /* ForOfStatement */)) { + case 87 /* ForKeyword */: + if (hasKind(node.parent, 207 /* ForStatement */) || + hasKind(node.parent, 208 /* ForInStatement */) || + hasKind(node.parent, 209 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 104 /* WhileKeyword */: - case 79 /* DoKeyword */: - if (hasKind(node.parent, 205 /* WhileStatement */) || hasKind(node.parent, 204 /* DoStatement */)) { + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 206 /* WhileStatement */) || hasKind(node.parent, 205 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 148 /* Constructor */)) { + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 149 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - if (hasKind(node.parent, 149 /* GetAccessor */) || hasKind(node.parent, 150 /* SetAccessor */)) { + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + if (hasKind(node.parent, 150 /* GetAccessor */) || hasKind(node.parent, 151 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 201 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -64680,10 +65400,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* ThrowStatement */) { + if (node.kind === 216 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 216 /* TryStatement */) { + else if (node.kind === 217 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -64716,7 +65436,7 @@ var ts; } // 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_20.kind === 216 /* TryStatement */) { + if (parent_20.kind === 217 /* TryStatement */) { var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -64731,7 +65451,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 /* BreakStatement */ || node.kind === 209 /* ContinueStatement */) { + if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -64746,16 +65466,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 213 /* SwitchStatement */: - if (statement.kind === 209 /* ContinueStatement */) { + case 214 /* SwitchStatement */: + if (statement.kind === 210 /* ContinueStatement */) { continue; } // Fall through. - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -64774,24 +65494,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 === 221 /* ClassDeclaration */ || - container.kind === 192 /* ClassExpression */ || - (declaration.kind === 142 /* Parameter */ && hasKind(container, 148 /* Constructor */)))) { + if (!(container.kind === 222 /* ClassDeclaration */ || + container.kind === 193 /* ClassExpression */ || + (declaration.kind === 143 /* Parameter */ && hasKind(container, 149 /* Constructor */)))) { return undefined; } } - else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || container.kind === 192 /* ClassExpression */)) { + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || container.kind === 193 /* ClassExpression */)) { return undefined; } } - else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 226 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { return undefined; } } - else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || declaration.kind === 221 /* ClassDeclaration */)) { + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { return undefined; } } @@ -64803,7 +65523,7 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { @@ -64813,17 +65533,17 @@ var ts; nodes = container.statements; } break; - case 148 /* Constructor */: + case 149 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* 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 & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 /* Constructor */ && member; + return member.kind === 149 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -64844,19 +65564,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 112 /* PublicKeyword */: + case 113 /* PublicKeyword */: return 4 /* Public */; - case 110 /* PrivateKeyword */: + case 111 /* PrivateKeyword */: return 8 /* Private */; - case 111 /* ProtectedKeyword */: + case 112 /* ProtectedKeyword */: return 16 /* Protected */; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: return 32 /* Static */; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: return 2 /* Ambient */; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: return 128 /* Abstract */; default: ts.Debug.fail(); @@ -64876,13 +65596,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 131 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 132 /* SetKeyword */); }); } } } @@ -64891,19 +65611,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { + 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 === 204 /* DoStatement */) { + if (loopNode.kind === 205 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { break; } } @@ -64912,7 +65632,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -64921,13 +65641,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -64935,14 +65655,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); } }); }); @@ -64950,13 +65670,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -64967,13 +65687,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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 (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -64981,36 +65701,36 @@ 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, 199 /* Block */))) { + if (!(func && hasKind(func.body, 200 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 203 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 204 /* 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) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 89 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 203 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -65019,7 +65739,7 @@ var ts; // 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 (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 80 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 81 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -65053,7 +65773,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 215 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -65191,10 +65911,10 @@ var ts; break; } // Fallthrough - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: case 9 /* StringLiteral */: return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); } @@ -65219,7 +65939,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 95 /* SuperKeyword */) { + if (node.kind === 96 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } } @@ -65255,7 +65975,7 @@ var ts; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - var internedName = getInternedName(symbol, node, declarations); + var internedName = getInternedName(symbol, node); for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; cancellationToken.throwIfCancellationRequested(); @@ -65287,12 +66007,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 231 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 232 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 /* ImportSpecifier */ || - declaration.kind === 238 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 /* ImportSpecifier */ || + declaration.kind === 239 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -65300,7 +66020,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 234 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 235 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -65315,20 +66035,20 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 167 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } return undefined; } - function getInternedName(symbol, location, declarations) { + function getInternedName(symbol, location) { // 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 (ts.isImportOrExportSpecifierName(location)) { @@ -65352,14 +66072,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 179 /* FunctionExpression */ || valueDeclaration.kind === 192 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 180 /* FunctionExpression */ || valueDeclaration.kind === 193 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class 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, 221 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 222 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -65421,8 +66141,8 @@ var ts; // 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). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4 /* Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -65462,7 +66182,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -65526,14 +66246,14 @@ var ts; var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 121 /* ConstructorKeyword */, parents, inheritsFromCache); + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); if (relatedSymbol) { addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - else if (searchLocation.kind === 121 /* ConstructorKeyword */) { + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); } } @@ -65594,17 +66314,17 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121 /* ConstructorKeyword */); + ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 147 /* MethodDeclaration */) { + if (decl && decl.kind === 148 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -65624,10 +66344,10 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 95 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { result.push(node); } @@ -65665,7 +66385,7 @@ var ts; if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { result.push(getReferenceEntryFromNode(refNode.parent)); } - else if (refNode.kind === 69 /* Identifier */) { + else if (refNode.kind === 70 /* Identifier */) { if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); @@ -65684,7 +66404,7 @@ var ts; maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); } else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199 /* Block */) { + if (parent_21.body.kind === 200 /* Block */) { ts.forEachReturnStatement(parent_21.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); @@ -65736,12 +66456,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ + if (node.kind === 195 /* ExpressionWithTypeArguments */ && node.parent.kind === 251 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 69 /* Identifier */ || node.kind === 172 /* PropertyAccessExpression */) { + else if (node.kind === 70 /* Identifier */ || node.kind === 173 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -65752,14 +66472,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { return isImplementationExpression(node.expression); } - return node.kind === 180 /* ArrowFunction */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 171 /* ObjectLiteralExpression */ || - node.kind === 192 /* ClassExpression */ || - node.kind === 170 /* ArrayLiteralExpression */; + return node.kind === 181 /* ArrowFunction */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 172 /* ObjectLiteralExpression */ || + node.kind === 193 /* ClassExpression */ || + node.kind === 171 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -65808,7 +66528,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -65836,13 +66556,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65855,7 +66575,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* SuperKeyword */) { + if (!node || node.kind !== 96 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -65874,17 +66594,17 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65893,8 +66613,8 @@ var ts; return undefined; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 180 /* 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. @@ -65937,20 +66657,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* 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) { @@ -66060,7 +66780,7 @@ var ts; // 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 === 142 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -66115,7 +66835,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -66199,7 +66919,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -66281,7 +67001,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 218 /* VariableDeclaration */) { + else if (node.kind === 219 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -66291,18 +67011,18 @@ var ts; } else { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 219 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 201 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 220 /* VariableDeclarationList */); return node.parent.parent; } } @@ -66336,17 +67056,17 @@ var ts; FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 69 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 70 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 186 /* PostfixUnaryExpression */ || parent.kind === 185 /* PrefixUnaryExpression */) { + if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 187 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; + return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } } return false; @@ -66366,11 +67086,11 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 140 /* ComputedPropertyName */) { + if (node.parent.kind === 141 /* ComputedPropertyName */) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } // intential fall through - case 69 /* Identifier */: + case 70 /* Identifier */: return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -66379,9 +67099,9 @@ var ts; switch (node.kind) { case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return true; } return false; @@ -66454,9 +67174,9 @@ var ts; // (1) when the aliased symbol was declared in the location(parent). // (2) when the aliased symbol is originating from a named import. // - if (node.kind === 69 /* Identifier */ && + if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 234 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 233 /* NamedImports */))) { + (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -66523,7 +67243,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (ts.isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { + if (ts.isNewExpressionTarget(location) || location.kind === 122 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -66548,8 +67268,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 148 /* Constructor */) || - (!selectConstructors && (d.kind === 220 /* FunctionDeclaration */ || d.kind === 147 /* MethodDeclaration */ || d.kind === 146 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 149 /* Constructor */) || + (!selectConstructors && (d.kind === 221 /* FunctionDeclaration */ || d.kind === 148 /* MethodDeclaration */ || d.kind === 147 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -66634,7 +67354,7 @@ var ts; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; } - else if (node.kind === 95 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 96 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = typeChecker.getSymbolAtLocation(node); @@ -66702,7 +67422,7 @@ var ts; "version" ]; var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + function getJsDocCommentsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter @@ -66752,7 +67472,7 @@ var ts; name: tagName, kind: ts.ScriptElementKind.keyword, kindModifiers: "", - sortText: "0" + sortText: "0", }; })); } @@ -66795,19 +67515,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: - case 221 /* ClassDeclaration */: - case 200 /* VariableStatement */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: + case 222 /* ClassDeclaration */: + case 201 /* VariableStatement */: break findOwner; case 256 /* SourceFile */: return undefined; - case 225 /* ModuleDeclaration */: + case 226 /* 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 === 225 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 226 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -66823,7 +67543,7 @@ var ts; var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 69 /* Identifier */ ? + var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : "param" + i; docParams += indentationStr + " * @param " + paramName + newLine; @@ -66848,7 +67568,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 200 /* VariableStatement */) { + if (commentOwner.kind === 201 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -66866,17 +67586,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 179 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return rightHandSide.parameters; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { return member.parameters; } } @@ -66911,7 +67631,7 @@ var ts; * @param typingOptions are used to customize the typing inference process * @param compilerOptions are used as a source for typing inference */ - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { // A typing name to typing file path mapping var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { @@ -67079,8 +67799,6 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -67121,7 +67839,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 === 231 /* ImportClause */ || decl.kind === 234 /* ImportSpecifier */ || decl.kind === 229 /* ImportEqualsDeclaration */) { + if (decl.kind === 232 /* ImportClause */ || decl.kind === 235 /* ImportSpecifier */ || decl.kind === 230 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -67149,7 +67867,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -67163,7 +67881,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 140 /* ComputedPropertyName */) { + else if (declaration.name.kind === 141 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -67184,7 +67902,7 @@ var ts; } return true; } - if (expression.kind === 172 /* PropertyAccessExpression */) { + if (expression.kind === 173 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -67197,7 +67915,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -67230,8 +67948,8 @@ var ts; // We first sort case insensitively. So "Aaa" will come before "bar". // Then we sort case sensitively, so "aaa" will come before "Aaa". return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem) { var declaration = rawItem.declaration; @@ -67350,7 +68068,7 @@ var ts; return; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -67362,21 +68080,21 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 147 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -67388,7 +68106,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -67399,8 +68117,8 @@ var ts; } } break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var decl = node; var name_50 = decl.name; if (ts.isBindingPattern(name_50)) { @@ -67414,12 +68132,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -67429,9 +68147,9 @@ var ts; } endNode(); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -67439,15 +68157,15 @@ var ts; } endNode(); break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 238 /* ExportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 153 /* IndexSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 223 /* TypeAliasDeclaration */: + case 239 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 154 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 224 /* TypeAliasDeclaration */: addLeafNode(node); break; default: @@ -67504,14 +68222,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 !== 225 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 226 /* 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 !== 225 /* ModuleDeclaration */) { + if (a.body.kind !== 226 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -67546,11 +68264,9 @@ var ts; return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { // This isn't perfect, but it passes all of our tests. for (var i = 0; i < Math.min(a.length, b.length); i++) { var chA = a.charAt(i), chB = b.charAt(i); @@ -67560,7 +68276,7 @@ var ts; if (chA === "'" && chB === "\"") { return -1; } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } @@ -67573,7 +68289,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -67581,9 +68297,9 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: return getFunctionOrClassName(node); case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67592,7 +68308,7 @@ var ts; } } function getItemName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -67608,22 +68324,22 @@ var ts; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } return getFunctionOrClassName(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return "constructor"; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return "new()"; - case 151 /* CallSignature */: + case 152 /* CallSignature */: return "()"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "[]"; case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67637,10 +68353,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { return nameIdentifier.text; } } @@ -67666,24 +68382,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: case 279 /* JSDocTypedefTag */: return true; - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 218 /* VariableDeclaration */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 219 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -67693,10 +68409,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -67705,7 +68421,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 218 /* VariableDeclaration */ && childKind !== 169 /* BindingElement */; + return childKind !== 219 /* VariableDeclaration */ && childKind !== 170 /* BindingElement */; }); } } @@ -67763,7 +68479,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 === 225 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -67774,10 +68490,10 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 225 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 226 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 140 /* ComputedPropertyName */; + return !member.name || member.name.kind === 141 /* ComputedPropertyName */; } function getNodeSpan(node) { return node.kind === 256 /* SourceFile */ @@ -67788,11 +68504,11 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 218 /* VariableDeclaration */) { + else if (node.parent.kind === 219 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 187 /* BinaryExpression */ && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + else if (node.parent.kind === 188 /* BinaryExpression */ && + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left); } else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { @@ -67806,7 +68522,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */ || node.kind === 192 /* ClassExpression */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -67882,7 +68598,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -67894,26 +68610,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + 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_22.kind === 204 /* DoStatement */ || - parent_22.kind === 207 /* ForInStatement */ || - parent_22.kind === 208 /* ForOfStatement */ || - parent_22.kind === 206 /* ForStatement */ || - parent_22.kind === 203 /* IfStatement */ || - parent_22.kind === 205 /* WhileStatement */ || - parent_22.kind === 212 /* WithStatement */ || + if (parent_22.kind === 205 /* DoStatement */ || + parent_22.kind === 208 /* ForInStatement */ || + parent_22.kind === 209 /* ForOfStatement */ || + parent_22.kind === 207 /* ForStatement */ || + parent_22.kind === 204 /* IfStatement */ || + parent_22.kind === 206 /* WhileStatement */ || + parent_22.kind === 213 /* WithStatement */ || parent_22.kind === 252 /* CatchClause */) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 216 /* TryStatement */) { + if (parent_22.kind === 217 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_22; if (tryStatement.tryBlock === n) { @@ -67921,7 +68637,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -67940,25 +68656,25 @@ var ts; break; } // Fallthrough. - case 226 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 227 /* 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 227 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 228 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 170 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 171 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -68313,7 +69029,7 @@ var ts; if (ch >= 65 /* A */ && ch <= 90 /* Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68326,7 +69042,7 @@ var ts; if (ch >= 97 /* a */ && ch <= 122 /* z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68547,10 +69263,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { braceNesting++; } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { braceNesting--; } return token; @@ -68601,10 +69317,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 122 /* DeclareKeyword */) { + if (token === 123 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 125 /* ModuleKeyword */) { + if (token === 126 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -68619,7 +69335,7 @@ var ts; */ function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 89 /* ImportKeyword */) { + if (token === 90 /* ImportKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import "mod"; @@ -68627,9 +69343,9 @@ var ts; return true; } else { - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -68637,12 +69353,12 @@ var ts; return true; } } - else if (token === 56 /* EqualsToken */) { + else if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 24 /* CommaToken */) { + else if (token === 25 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -68651,16 +69367,16 @@ var ts; return true; } } - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -68670,13 +69386,13 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 116 /* AsKeyword */) { + if (token === 117 /* AsKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -68694,19 +69410,19 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 82 /* ExportKeyword */) { + if (token === 83 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -68716,9 +69432,9 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -68726,11 +69442,11 @@ var ts; } } } - else if (token === 89 /* ImportKeyword */) { + else if (token === 90 /* ImportKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 56 /* EqualsToken */) { + if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -68743,9 +69459,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129 /* RequireKeyword */) { + if (token === 130 /* RequireKeyword */) { token = nextToken(); - if (token === 17 /* OpenParenToken */) { + if (token === 18 /* OpenParenToken */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // require("mod"); @@ -68758,16 +69474,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 69 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 70 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 17 /* OpenParenToken */) { + if (token !== 18 /* OpenParenToken */) { return true; } token = nextToken(); if (token === 9 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 24 /* CommaToken */) { + if (token === 25 /* CommaToken */) { token = nextToken(); } else { @@ -68776,14 +69492,14 @@ var ts; } } // should be start of dependency list - if (token !== 19 /* OpenBracketToken */) { + if (token !== 20 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); var i = 0; // scan until ']' or EOF - while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 21 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); @@ -68873,7 +69589,7 @@ var ts; var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node)) { @@ -69134,15 +69850,15 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 175 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 69 /* Identifier */ + var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 172 /* PropertyAccessExpression */ + : expression.kind === 173 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -69175,7 +69891,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 /* CallExpression */ || node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 175 /* CallExpression */ || node.parent.kind === 176 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -69191,8 +69907,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 25 /* LessThanToken */ || - node.kind === 17 /* OpenParenToken */) { + if (node.kind === 26 /* LessThanToken */ || + node.kind === 18 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -69229,27 +69945,27 @@ var ts; } return undefined; } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 177 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 197 /* TemplateSpan */ && node.parent.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 198 /* TemplateSpan */ && node.parent.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -69277,7 +69993,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 24 /* CommaToken */) { + if (child.kind !== 25 /* CommaToken */) { argumentIndex++; } } @@ -69296,8 +70012,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -69327,7 +70043,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 12 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -69365,7 +70081,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -69435,10 +70151,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(28 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -69449,10 +70165,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -69462,7 +70178,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -69516,7 +70232,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -69547,7 +70263,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 97 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 98 /* ThisKeyword */ && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } if (flags & 3 /* Variable */) { @@ -69611,7 +70327,7 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 /* ThisKeyword */ && ts.isExpression(location); + var isThisExpression = location.kind === 98 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { @@ -69622,7 +70338,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 172 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 173 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -69631,7 +70347,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression = void 0; - if (location.kind === 174 /* CallExpression */ || location.kind === 175 /* NewExpression */) { + if (location.kind === 175 /* CallExpression */ || location.kind === 176 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -69644,7 +70360,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 175 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 176 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -69662,7 +70378,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -69678,10 +70394,10 @@ var ts; case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 2097152 /* Anonymous */) && type.symbol) { @@ -69697,24 +70413,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 148 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 149 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 149 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 148 /* Constructor */) { + if (functionDeclaration.kind === 149 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -69723,7 +70439,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -69731,7 +70447,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(74 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -69739,49 +70455,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(108 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(75 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(82 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 127 /* NamespaceKeyword */ : 126 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90 /* InKeyword */)); + displayParts.push(ts.keywordPart(91 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -69790,17 +70506,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + if (declaration.kind === 153 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 151 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 152 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -69809,7 +70525,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -69824,7 +70540,7 @@ var ts; var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -69832,33 +70548,33 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228 /* NamespaceExportDeclaration */) { - displayParts.push(ts.keywordPart(82 /* ExportKeyword */)); + if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(127 /* NamespaceKeyword */)); } else { - displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229 /* ImportEqualsDeclaration */) { + if (declaration.kind === 230 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(130 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -69872,7 +70588,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(98 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -69882,7 +70598,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -69919,7 +70635,7 @@ var ts; if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 188 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -69962,9 +70678,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); return; } } @@ -69972,12 +70688,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(35 /* PlusToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(36 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -69995,16 +70711,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 179 /* FunctionExpression */) { + if (declaration.kind === 180 /* FunctionExpression */) { return true; } - if (declaration.kind !== 218 /* VariableDeclaration */ && declaration.kind !== 220 /* FunctionDeclaration */) { + if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 226 /* ModuleBlock */) { + if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { return false; } } @@ -70065,8 +70781,8 @@ var ts; var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); sourceMapText = text; @@ -70082,9 +70798,9 @@ var ts; getCurrentDirectory: function () { return ""; }, getNewLine: function () { return newLine; }, fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } }; var program = ts.createProgram([inputFileName], options, compilerHost); if (transpileOptions.reportDiagnostics) { @@ -70146,8 +70862,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); /** * Scanner that is currently used for formatting */ @@ -70162,7 +70878,7 @@ var ts; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -70187,7 +70903,7 @@ var ts; } }; function advance() { - ts.Debug.assert(scanner !== undefined); + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -70229,11 +70945,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 29 /* GreaterThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanToken */: return true; } } @@ -70243,26 +70959,26 @@ var ts; if (node.parent) { switch (node.parent.kind) { case 246 /* JsxAttribute */: - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: case 245 /* JsxClosingElement */: - case 242 /* JsxSelfClosingElement */: - return node.kind === 69 /* Identifier */; + case 243 /* JsxSelfClosingElement */: + return node.kind === 70 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 244 /* JsxText */; + return node && node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 10 /* RegularExpressionLiteral */; + return container.kind === 11 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 13 /* TemplateMiddle */ || - container.kind === 14 /* TemplateTail */; + return container.kind === 14 /* TemplateMiddle */ || + container.kind === 15 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; + return t === 40 /* SlashToken */ || t === 62 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -70303,7 +71019,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 28 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -70313,11 +71029,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 17 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 70 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -70460,8 +71176,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 16 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -70649,125 +71365,125 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + 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(16 /* 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.Any), 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(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + 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 */)); // No space for dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + 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 */)); // No space before and after indexer - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */, 82 /* ExportKeyword */, 89 /* ImportKeyword */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 3 /* MultiLineCommentTrivia */, 74 /* ClassKeyword */, 83 /* ExportKeyword */, 90 /* ImportKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + 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(15 /* 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, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* 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, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + 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.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(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* 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, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* 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(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* PlusPlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* MinusMinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103 /* VarKeyword */, 99 /* ThrowKeyword */, 93 /* NewKeyword */, 79 /* DeleteKeyword */, 95 /* ReturnKeyword */, 102 /* TypeOfKeyword */, 120 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + 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.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 */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 80 /* DoKeyword */, 81 /* ElseKeyword */, 72 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 131 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 132 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. 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 /* Space */)); 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.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + 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([125 /* ModuleKeyword */, 129 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126 /* ModuleKeyword */, 130 /* 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([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */, 136 /* FromKeyword */]), 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([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */, 136 /* FromKeyword */])), 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 */, 126 /* ModuleKeyword */, 127 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 132 /* SetKeyword */, 114 /* StaticKeyword */, 135 /* TypeKeyword */, 137 /* FromKeyword */]), 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 */, 137 /* 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 */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23 /* DotDotDotToken */, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics and type assertions - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* CloseParenToken */, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([18 /* OpenParenToken */, 20 /* OpenBracketToken */, 28 /* GreaterThanToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 131 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 132 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* YieldKeyword */, 38 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 88 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70 /* Identifier */, formatting.Shared.TokenRange.FromTokens([12 /* NoSubstitutionTemplateLiteral */, 13 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // jsx opening element - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* SlashToken */, 27 /* 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, 56 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + 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 */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -70829,54 +71545,54 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* OpenParenToken */, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty brackets - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* OpenBracketToken */, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing template string braces - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); // No space after type assertion - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -70891,42 +71607,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 206 /* ForStatement */; + return context.contextNode.kind === 207 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 195 /* AsExpression */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 154 /* TypePredicate */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 196 /* AsExpression */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 155 /* TypePredicate */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 169 /* BindingElement */: + case 170 /* BindingElement */: // equals in type X = ... - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: // equal in p = 0; - case 142 /* Parameter */: + case 143 /* Parameter */: case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 207 /* ForInStatement */: - return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; + case 208 /* ForInStatement */: + 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 208 /* ForOfStatement */: - return context.currentTokenSpan.kind === 138 /* OfKeyword */ || context.nextTokenSpan.kind === 138 /* OfKeyword */; + case 209 /* ForOfStatement */: + return context.currentTokenSpan.kind === 139 /* OfKeyword */ || context.nextTokenSpan.kind === 139 /* OfKeyword */; } return false; }; @@ -70934,7 +71650,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188 /* ConditionalExpression */; + return context.contextNode.kind === 189 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -70978,81 +71694,81 @@ var ts; return true; } switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 171 /* ObjectLiteralExpression */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 172 /* ObjectLiteralExpression */: + case 227 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 151 /* CallSignature */: - case 179 /* FunctionExpression */: - case 148 /* Constructor */: - case 180 /* ArrowFunction */: + case 152 /* CallSignature */: + case 180 /* FunctionExpression */: + case 149 /* Constructor */: + case 181 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 /* FunctionDeclaration */ || context.contextNode.kind === 179 /* FunctionExpression */; + return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 159 /* TypeLiteral */: - case 225 /* ModuleDeclaration */: - case 236 /* ExportDeclaration */: - case 237 /* NamedExports */: - case 230 /* ImportDeclaration */: - case 233 /* NamedImports */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 160 /* TypeLiteral */: + case 226 /* ModuleDeclaration */: + case 237 /* ExportDeclaration */: + case 238 /* NamedExports */: + case 231 /* ImportDeclaration */: + case 234 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 221 /* ClassDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: - case 199 /* Block */: + case 222 /* ClassDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: + case 200 /* Block */: case 252 /* CatchClause */: - case 226 /* ModuleBlock */: - case 213 /* SwitchStatement */: + case 227 /* ModuleBlock */: + case 214 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 203 /* IfStatement */: - case 213 /* SwitchStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 216 /* TryStatement */: - case 204 /* DoStatement */: - case 212 /* WithStatement */: + case 204 /* IfStatement */: + case 214 /* SwitchStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 217 /* TryStatement */: + case 205 /* DoStatement */: + case 213 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: case 252 /* CatchClause */: @@ -71062,31 +71778,31 @@ var ts; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171 /* ObjectLiteralExpression */; + return context.contextNode.kind === 172 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174 /* CallExpression */; + return context.contextNode.kind === 175 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175 /* NewExpression */; + return context.contextNode.kind === 176 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24 /* CommaToken */; + return context.currentTokenSpan.kind !== 25 /* CommaToken */; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180 /* ArrowFunction */; + return context.contextNode.kind === 181 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241 /* JsxElement */; + return context.contextNode.kind !== 242 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { return context.contextNode.kind === 248 /* JsxExpression */; @@ -71098,7 +71814,7 @@ var ts; return context.contextNode.kind === 246 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242 /* JsxSelfClosingElement */; + return context.contextNode.kind === 243 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -71113,41 +71829,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 220 /* 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 === 225 /* ModuleDeclaration */; + return context.contextNode.kind === 226 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 160 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { + if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 155 /* TypeReference */: - case 177 /* TypeAssertionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 194 /* ExpressionWithTypeArguments */: + case 156 /* TypeReference */: + case 178 /* TypeAssertionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 195 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -71158,13 +71874,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177 /* TypeAssertionExpression */; + return context.contextNode.kind === 178 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 183 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 184 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -71188,7 +71904,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 /* LastToken */ + 1; + this.mapRowLength = 139 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); // new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); // new Array(this.map.length); @@ -71202,8 +71918,8 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 /* LastKeyword */ && column <= 139 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; - // Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array."); return rulesBucketIndex; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { @@ -71383,12 +72099,12 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 138 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 139 /* LastToken */; token++) { result.push(token); } return result; }; - TokenAllAccess.prototype.Contains = function (tokenValue) { + TokenAllAccess.prototype.Contains = function () { return true; }; TokenAllAccess.prototype.toString = function () { @@ -71427,17 +72143,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 138 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 138 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 139 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 139 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 130 /* NumberKeyword */, 132 /* StringKeyword */, 120 /* BooleanKeyword */, 133 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 131 /* NumberKeyword */, 133 /* StringKeyword */, 121 /* BooleanKeyword */, 134 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -71628,11 +72344,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 24 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 17 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -71696,15 +72412,15 @@ 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 226 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + return body && body.kind === 227 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); case 256 /* SourceFile */: - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); case 252 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); @@ -71761,7 +72477,7 @@ var ts; index++; } }; - function rangeHasNoErrors(r) { + function rangeHasNoErrors() { return false; } } @@ -71911,20 +72627,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 221 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 222 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 220 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 224 /* EnumDeclaration */: return 224 /* EnumDeclaration */; - case 149 /* GetAccessor */: return 123 /* GetKeyword */; - case 150 /* SetAccessor */: return 131 /* SetKeyword */; - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 223 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 221 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 225 /* EnumDeclaration */: return 225 /* EnumDeclaration */; + case 150 /* GetAccessor */: return 124 /* GetKeyword */; + case 151 /* SetAccessor */: return 132 /* SetKeyword */; + case 148 /* MethodDeclaration */: if (node.asteriskToken) { - return 37 /* AsteriskToken */; + return 38 /* AsteriskToken */; } /* fall-through */ - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: return node.name.kind; } } @@ -71936,9 +72652,9 @@ var ts; // .. { // // comment // } - case 16 /* CloseBraceToken */: - case 20 /* CloseBracketToken */: - case 18 /* CloseParenToken */: + case 17 /* CloseBraceToken */: + case 21 /* CloseBracketToken */: + case 19 /* CloseParenToken */: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; @@ -71952,15 +72668,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 15 /* OpenBraceToken */: - case 16 /* CloseBraceToken */: - case 19 /* OpenBracketToken */: - case 20 /* CloseBracketToken */: - case 17 /* OpenParenToken */: - case 18 /* CloseParenToken */: - case 80 /* ElseKeyword */: - case 104 /* WhileKeyword */: - case 55 /* AtToken */: + 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 @@ -72060,18 +72776,19 @@ var ts; if (!formattingScanner.isOnToken()) { return inheritedIndentation; } - if (ts.isToken(child)) { + // JSX text shouldn't affect indenting + if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 143 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 144 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 170 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 171 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -72416,41 +73133,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 181 /* ArrowFunction */: if (node.typeParameters === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.parameters === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.arguments === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 17 /* OpenParenToken */: - return 18 /* CloseParenToken */; - case 25 /* LessThanToken */: - return 27 /* GreaterThanToken */; + case 18 /* OpenParenToken */: + return 19 /* CloseParenToken */; + case 26 /* LessThanToken */: + return 28 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -72554,7 +73271,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 187 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 188 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -72688,11 +73405,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 15 /* OpenBraceToken */) { + if (nextToken.kind === 16 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 16 /* CloseBraceToken */) { + else if (nextToken.kind === 17 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -72710,8 +73427,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); + if (parent.kind === 204 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -72722,23 +73439,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return node.parent.properties; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return node.parent.elements; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: { + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -72749,8 +73466,8 @@ var ts; } break; } - case 175 /* NewExpression */: - case 174 /* CallExpression */: { + case 176 /* NewExpression */: + case 175 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -72777,11 +73494,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 18 /* CloseParenToken */) { + if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) && + if (node.parent && (node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -72799,10 +73516,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: node = node.expression; break; default: @@ -72818,7 +73535,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24 /* CommaToken */) { + if (list[i].kind === 25 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -72866,48 +73583,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ExpressionStatement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 170 /* ArrayLiteralExpression */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: - case 161 /* TupleType */: - case 227 /* CaseBlock */: + case 203 /* ExpressionStatement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 171 /* ArrayLiteralExpression */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: + case 162 /* TupleType */: + case 228 /* CaseBlock */: case 250 /* DefaultClause */: case 249 /* CaseClause */: - case 178 /* ParenthesizedExpression */: - case 172 /* PropertyAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 200 /* VariableStatement */: - case 218 /* VariableDeclaration */: - case 235 /* ExportAssignment */: - case 211 /* ReturnStatement */: - case 188 /* ConditionalExpression */: - case 168 /* ArrayBindingPattern */: - case 167 /* ObjectBindingPattern */: - case 243 /* JsxOpeningElement */: - case 242 /* JsxSelfClosingElement */: + case 179 /* ParenthesizedExpression */: + case 173 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 201 /* VariableStatement */: + case 219 /* VariableDeclaration */: + case 236 /* ExportAssignment */: + case 212 /* ReturnStatement */: + case 189 /* ConditionalExpression */: + case 169 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 244 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: case 248 /* JsxExpression */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 142 /* Parameter */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 164 /* ParenthesizedType */: - case 176 /* TaggedTemplateExpression */: - case 184 /* AwaitExpression */: - case 237 /* NamedExports */: - case 233 /* NamedImports */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 143 /* Parameter */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 165 /* ParenthesizedType */: + case 177 /* TaggedTemplateExpression */: + case 185 /* AwaitExpression */: + case 238 /* NamedExports */: + case 234 /* NamedImports */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: return true; } return false; @@ -72916,26 +73633,26 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 203 /* IfStatement */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return childKind !== 199 /* Block */; - case 236 /* ExportDeclaration */: - return childKind !== 237 /* NamedExports */; - case 230 /* ImportDeclaration */: - return childKind !== 231 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 233 /* NamedImports */); - case 241 /* JsxElement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 204 /* IfStatement */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return childKind !== 200 /* Block */; + case 237 /* ExportDeclaration */: + return childKind !== 238 /* NamedExports */; + case 231 /* ImportDeclaration */: + return childKind !== 232 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 234 /* NamedImports */); + case 242 /* JsxElement */: return childKind !== 245 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument @@ -73001,7 +73718,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 121 /* ConstructorKeyword */) { + if (token.kind !== 122 /* ConstructorKeyword */) { return undefined; } var newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -73016,7 +73733,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97 /* ThisKeyword */) { + if (token.kind !== 98 /* ThisKeyword */) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -73026,7 +73743,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 174 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 175 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -73050,7 +73767,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -73095,8 +73812,8 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 69 /* Identifier */ ? new IdentifierObject(69 /* Identifier */, pos, end) : + var node = kind >= 140 /* FirstNode */ ? new NodeObject(kind, pos, end) : + kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -73173,7 +73890,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 139 /* FirstNode */) { + if (this.kind >= 140 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; @@ -73235,7 +73952,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 139 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -73243,7 +73960,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 139 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -73282,19 +73999,19 @@ var ts; TokenOrIdentifierObject.prototype.getText = function (sourceFile) { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildCount = function () { return 0; }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { + TokenOrIdentifierObject.prototype.getChildAt = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; return TokenOrIdentifierObject; @@ -73315,7 +74032,7 @@ var ts; }; SymbolObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; }; @@ -73332,12 +74049,12 @@ var ts; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { + function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69 /* Identifier */; + IdentifierObject.prototype.kind = 70 /* Identifier */; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -73398,9 +74115,7 @@ var ts; }; SignatureObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; }; @@ -73448,9 +74163,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -73460,7 +74175,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -73470,10 +74185,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -73493,32 +74208,32 @@ var ts; ts.forEachChild(node, visit); } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 159 /* TypeLiteral */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 160 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 142 /* Parameter */: + case 143 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: { + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -73528,18 +74243,18 @@ var ts; visit(decl.initializer); } case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: addDeclaration(node); break; - case 236 /* ExportDeclaration */: + case 237 /* 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 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -73551,7 +74266,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -73575,7 +74290,7 @@ var ts; getSourceFileConstructor: function () { return SourceFileObject; }, getSymbolConstructor: function () { return SymbolObject; }, getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } + getSignatureConstructor: function () { return SignatureObject; }, }; } function toEditorSettings(optionsAsMap) { @@ -73674,7 +74389,7 @@ var ts; }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { + this.fileNameToEntry.forEachValue(function (_path, value) { if (value) { fileNames.push(value.hostFileName); } @@ -73706,7 +74421,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -73884,7 +74599,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, + writeFile: function () { }, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality @@ -74080,12 +74795,12 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 95 /* SuperKeyword */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -74219,7 +74934,7 @@ var ts; function getSourceFile(fileName) { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location var node = ts.getTouchingPropertyName(sourceFile, startPos); @@ -74227,16 +74942,16 @@ var ts; return; } switch (node.kind) { - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: case 9 /* StringLiteral */: - case 84 /* FalseKeyword */: - case 99 /* TrueKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 69 /* Identifier */: + case 85 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 70 /* Identifier */: break; // Cant create the text span default: @@ -74252,7 +74967,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 === 225 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 226 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -74343,14 +75058,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; - case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; - case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; - case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; - case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; - case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; - case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; - case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; + case 16 /* OpenBraceToken */: return 17 /* CloseBraceToken */; + case 18 /* OpenParenToken */: return 19 /* CloseParenToken */; + case 20 /* OpenBracketToken */: return 21 /* CloseBracketToken */; + case 26 /* LessThanToken */: return 28 /* GreaterThanToken */; + case 17 /* CloseBraceToken */: return 16 /* OpenBraceToken */; + case 19 /* CloseParenToken */: return 18 /* OpenParenToken */; + case 21 /* CloseBracketToken */: return 20 /* OpenBracketToken */; + case 28 /* GreaterThanToken */: return 26 /* LessThanToken */; } return undefined; } @@ -74626,7 +75341,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9 /* StringLiteral */: @@ -74636,7 +75351,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 === 240 /* ExternalModuleReference */ || + node.parent.kind === 241 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -74656,7 +75371,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 173 /* ElementAccessExpression */ && + node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -74740,143 +75455,143 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218 /* VariableDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return spanInVariableDeclaration(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return spanInParameterDeclaration(node); - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return spanInBlock(node); case 252 /* CatchClause */: return spanInBlock(node.block); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 203 /* IfStatement */: + case 204 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return spanInForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); case 249 /* CaseClause */: case 250 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 216 /* TryStatement */: + case 217 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: // span on complete node return textSpan(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 143 /* Decorator */: + case 144 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return spanInPreviousNode(node); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 20 /* CloseBracketToken */: + case 21 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return spanInOpenParenToken(node); - case 18 /* CloseParenToken */: + case 19 /* CloseParenToken */: return spanInCloseParenToken(node); - case 54 /* ColonToken */: + case 55 /* ColonToken */: return spanInColonToken(node); - case 27 /* GreaterThanToken */: - case 25 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 26 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return spanInWhileKeyword(node); - case 80 /* ElseKeyword */: - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 81 /* ElseKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 138 /* OfKeyword */: + case 139 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -74888,14 +75603,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern - if ((node.kind === 69 /* Identifier */ || - node.kind == 191 /* SpreadElementExpression */ || + if ((node.kind === 70 /* Identifier */ || + node.kind == 192 /* SpreadElementExpression */ || node.kind === 253 /* PropertyAssignment */ || node.kind === 254 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 187 /* BinaryExpression */) { + if (node.kind === 188 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -74904,7 +75619,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 56 /* EqualsToken */ && + if (binaryExpression.operatorToken.kind === 57 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of @@ -74912,28 +75627,28 @@ var ts; // { a = expression, b, c } = someExpression return textSpan(node); } - if (binaryExpression.operatorToken.kind === 24 /* CommaToken */) { + if (binaryExpression.operatorToken.kind === 25 /* CommaToken */) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 143 /* Decorator */: + case 144 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: return textSpan(node); - case 187 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 24 /* CommaToken */) { + case 188 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -74948,7 +75663,7 @@ var ts; return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 177 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 178 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -74956,8 +75671,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 218 /* VariableDeclaration */ || - node.parent.kind === 142 /* Parameter */)) { + if ((node.parent.kind === 219 /* VariableDeclaration */ || + node.parent.kind === 143 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -74965,7 +75680,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 187 /* BinaryExpression */) { + if (node.parent.kind === 188 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -74991,7 +75706,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 207 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 208 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -75002,7 +75717,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 208 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 209 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -75042,7 +75757,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 221 /* ClassDeclaration */ && functionDeclaration.kind !== 148 /* Constructor */); + (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -75065,25 +75780,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 205 /* WhileStatement */: - case 203 /* IfStatement */: - case 207 /* ForInStatement */: + case 206 /* WhileStatement */: + case 204 /* IfStatement */: + case 208 /* 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 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* 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 === 219 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 220 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -75108,23 +75823,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 169 /* BindingElement */) { + if (bindingPattern.parent.kind === 170 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 /* ArrayBindingPattern */ && node.kind !== 167 /* ObjectBindingPattern */); - var elements = node.kind === 170 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 169 /* ArrayBindingPattern */ && node.kind !== 168 /* ObjectBindingPattern */); + var elements = node.kind === 171 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -75132,18 +75847,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 187 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 188 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -75151,16 +75866,16 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 224 /* EnumDeclaration */: - case 221 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); @@ -75168,7 +75883,7 @@ var ts; // fall through case 252 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -75176,7 +75891,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75192,7 +75907,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75207,12 +75922,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 204 /* DoStatement */ || - node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 205 /* DoStatement */ || + node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 178 /* ParenthesizedExpression */) { + if (node.parent.kind === 179 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -75221,21 +75936,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 178 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 179 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -75246,19 +75961,19 @@ var ts; // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || node.parent.kind === 253 /* PropertyAssignment */ || - node.parent.kind === 142 /* Parameter */) { + node.parent.kind === 143 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177 /* TypeAssertionExpression */) { + if (node.parent.kind === 178 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 204 /* DoStatement */) { + if (node.parent.kind === 205 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -75266,7 +75981,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.kind === 209 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -75445,7 +76160,7 @@ var ts; return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { @@ -75494,7 +76209,7 @@ var ts; // Wrap the API changes for 2.0 release. This try/catch // should be removed once TypeScript 2.0 has shipped. try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); } catch (e) { @@ -75568,7 +76283,7 @@ var ts; this.factory = factory; factory.registerShim(this); } - ShimBase.prototype.dispose = function (dummy) { + ShimBase.prototype.dispose = function (_dummy) { this.factory.unregisterShim(this); }; return ShimBase; @@ -75991,7 +76706,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false); return this.forwardJSONCall("discoverTypings()", function () { var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); }); }; return CoreServicesShimObject; @@ -76080,3 +76795,5 @@ var TypeScript; /* @internal */ var toolsVersion = "2.1"; /* tslint:enable:no-unused-variable */ + +//# sourceMappingURL=typescriptServices.js.map diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 5f319ffb74c0d..2558f2a3f992a 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -47,241 +47,241 @@ declare namespace ts { ConflictMarkerTrivia = 7, NumericLiteral = 8, StringLiteral = 9, - RegularExpressionLiteral = 10, - NoSubstitutionTemplateLiteral = 11, - TemplateHead = 12, - TemplateMiddle = 13, - TemplateTail = 14, - OpenBraceToken = 15, - CloseBraceToken = 16, - OpenParenToken = 17, - CloseParenToken = 18, - OpenBracketToken = 19, - CloseBracketToken = 20, - DotToken = 21, - DotDotDotToken = 22, - SemicolonToken = 23, - CommaToken = 24, - LessThanToken = 25, - LessThanSlashToken = 26, - GreaterThanToken = 27, - LessThanEqualsToken = 28, - GreaterThanEqualsToken = 29, - EqualsEqualsToken = 30, - ExclamationEqualsToken = 31, - EqualsEqualsEqualsToken = 32, - ExclamationEqualsEqualsToken = 33, - EqualsGreaterThanToken = 34, - PlusToken = 35, - MinusToken = 36, - AsteriskToken = 37, - AsteriskAsteriskToken = 38, - SlashToken = 39, - PercentToken = 40, - PlusPlusToken = 41, - MinusMinusToken = 42, - LessThanLessThanToken = 43, - GreaterThanGreaterThanToken = 44, - GreaterThanGreaterThanGreaterThanToken = 45, - AmpersandToken = 46, - BarToken = 47, - CaretToken = 48, - ExclamationToken = 49, - TildeToken = 50, - AmpersandAmpersandToken = 51, - BarBarToken = 52, - QuestionToken = 53, - ColonToken = 54, - AtToken = 55, - EqualsToken = 56, - PlusEqualsToken = 57, - MinusEqualsToken = 58, - AsteriskEqualsToken = 59, - AsteriskAsteriskEqualsToken = 60, - SlashEqualsToken = 61, - PercentEqualsToken = 62, - LessThanLessThanEqualsToken = 63, - GreaterThanGreaterThanEqualsToken = 64, - GreaterThanGreaterThanGreaterThanEqualsToken = 65, - AmpersandEqualsToken = 66, - BarEqualsToken = 67, - CaretEqualsToken = 68, - Identifier = 69, - BreakKeyword = 70, - CaseKeyword = 71, - CatchKeyword = 72, - ClassKeyword = 73, - ConstKeyword = 74, - ContinueKeyword = 75, - DebuggerKeyword = 76, - DefaultKeyword = 77, - DeleteKeyword = 78, - DoKeyword = 79, - ElseKeyword = 80, - EnumKeyword = 81, - ExportKeyword = 82, - ExtendsKeyword = 83, - FalseKeyword = 84, - FinallyKeyword = 85, - ForKeyword = 86, - FunctionKeyword = 87, - IfKeyword = 88, - ImportKeyword = 89, - InKeyword = 90, - InstanceOfKeyword = 91, - NewKeyword = 92, - NullKeyword = 93, - ReturnKeyword = 94, - SuperKeyword = 95, - SwitchKeyword = 96, - ThisKeyword = 97, - ThrowKeyword = 98, - TrueKeyword = 99, - TryKeyword = 100, - TypeOfKeyword = 101, - VarKeyword = 102, - VoidKeyword = 103, - WhileKeyword = 104, - WithKeyword = 105, - ImplementsKeyword = 106, - InterfaceKeyword = 107, - LetKeyword = 108, - PackageKeyword = 109, - PrivateKeyword = 110, - ProtectedKeyword = 111, - PublicKeyword = 112, - StaticKeyword = 113, - YieldKeyword = 114, - AbstractKeyword = 115, - AsKeyword = 116, - AnyKeyword = 117, - AsyncKeyword = 118, - AwaitKeyword = 119, - BooleanKeyword = 120, - ConstructorKeyword = 121, - DeclareKeyword = 122, - GetKeyword = 123, - IsKeyword = 124, - ModuleKeyword = 125, - NamespaceKeyword = 126, - NeverKeyword = 127, - ReadonlyKeyword = 128, - RequireKeyword = 129, - NumberKeyword = 130, - SetKeyword = 131, - StringKeyword = 132, - SymbolKeyword = 133, - TypeKeyword = 134, - UndefinedKeyword = 135, - FromKeyword = 136, - GlobalKeyword = 137, - OfKeyword = 138, - QualifiedName = 139, - ComputedPropertyName = 140, - TypeParameter = 141, - Parameter = 142, - Decorator = 143, - PropertySignature = 144, - PropertyDeclaration = 145, - MethodSignature = 146, - MethodDeclaration = 147, - Constructor = 148, - GetAccessor = 149, - SetAccessor = 150, - CallSignature = 151, - ConstructSignature = 152, - IndexSignature = 153, - TypePredicate = 154, - TypeReference = 155, - FunctionType = 156, - ConstructorType = 157, - TypeQuery = 158, - TypeLiteral = 159, - ArrayType = 160, - TupleType = 161, - UnionType = 162, - IntersectionType = 163, - ParenthesizedType = 164, - ThisType = 165, - LiteralType = 166, - ObjectBindingPattern = 167, - ArrayBindingPattern = 168, - BindingElement = 169, - ArrayLiteralExpression = 170, - ObjectLiteralExpression = 171, - PropertyAccessExpression = 172, - ElementAccessExpression = 173, - CallExpression = 174, - NewExpression = 175, - TaggedTemplateExpression = 176, - TypeAssertionExpression = 177, - ParenthesizedExpression = 178, - FunctionExpression = 179, - ArrowFunction = 180, - DeleteExpression = 181, - TypeOfExpression = 182, - VoidExpression = 183, - AwaitExpression = 184, - PrefixUnaryExpression = 185, - PostfixUnaryExpression = 186, - BinaryExpression = 187, - ConditionalExpression = 188, - TemplateExpression = 189, - YieldExpression = 190, - SpreadElementExpression = 191, - ClassExpression = 192, - OmittedExpression = 193, - ExpressionWithTypeArguments = 194, - AsExpression = 195, - NonNullExpression = 196, - TemplateSpan = 197, - SemicolonClassElement = 198, - Block = 199, - VariableStatement = 200, - EmptyStatement = 201, - ExpressionStatement = 202, - IfStatement = 203, - DoStatement = 204, - WhileStatement = 205, - ForStatement = 206, - ForInStatement = 207, - ForOfStatement = 208, - ContinueStatement = 209, - BreakStatement = 210, - ReturnStatement = 211, - WithStatement = 212, - SwitchStatement = 213, - LabeledStatement = 214, - ThrowStatement = 215, - TryStatement = 216, - DebuggerStatement = 217, - VariableDeclaration = 218, - VariableDeclarationList = 219, - FunctionDeclaration = 220, - ClassDeclaration = 221, - InterfaceDeclaration = 222, - TypeAliasDeclaration = 223, - EnumDeclaration = 224, - ModuleDeclaration = 225, - ModuleBlock = 226, - CaseBlock = 227, - NamespaceExportDeclaration = 228, - ImportEqualsDeclaration = 229, - ImportDeclaration = 230, - ImportClause = 231, - NamespaceImport = 232, - NamedImports = 233, - ImportSpecifier = 234, - ExportAssignment = 235, - ExportDeclaration = 236, - NamedExports = 237, - ExportSpecifier = 238, - MissingDeclaration = 239, - ExternalModuleReference = 240, - JsxElement = 241, - JsxSelfClosingElement = 242, - JsxOpeningElement = 243, - JsxText = 244, + JsxText = 10, + RegularExpressionLiteral = 11, + NoSubstitutionTemplateLiteral = 12, + TemplateHead = 13, + TemplateMiddle = 14, + TemplateTail = 15, + OpenBraceToken = 16, + CloseBraceToken = 17, + OpenParenToken = 18, + CloseParenToken = 19, + OpenBracketToken = 20, + CloseBracketToken = 21, + DotToken = 22, + DotDotDotToken = 23, + SemicolonToken = 24, + CommaToken = 25, + LessThanToken = 26, + LessThanSlashToken = 27, + GreaterThanToken = 28, + LessThanEqualsToken = 29, + GreaterThanEqualsToken = 30, + EqualsEqualsToken = 31, + ExclamationEqualsToken = 32, + EqualsEqualsEqualsToken = 33, + ExclamationEqualsEqualsToken = 34, + EqualsGreaterThanToken = 35, + PlusToken = 36, + MinusToken = 37, + AsteriskToken = 38, + AsteriskAsteriskToken = 39, + SlashToken = 40, + PercentToken = 41, + PlusPlusToken = 42, + MinusMinusToken = 43, + LessThanLessThanToken = 44, + GreaterThanGreaterThanToken = 45, + GreaterThanGreaterThanGreaterThanToken = 46, + AmpersandToken = 47, + BarToken = 48, + CaretToken = 49, + ExclamationToken = 50, + TildeToken = 51, + AmpersandAmpersandToken = 52, + BarBarToken = 53, + QuestionToken = 54, + ColonToken = 55, + AtToken = 56, + EqualsToken = 57, + PlusEqualsToken = 58, + MinusEqualsToken = 59, + AsteriskEqualsToken = 60, + AsteriskAsteriskEqualsToken = 61, + SlashEqualsToken = 62, + PercentEqualsToken = 63, + LessThanLessThanEqualsToken = 64, + GreaterThanGreaterThanEqualsToken = 65, + GreaterThanGreaterThanGreaterThanEqualsToken = 66, + AmpersandEqualsToken = 67, + BarEqualsToken = 68, + CaretEqualsToken = 69, + Identifier = 70, + BreakKeyword = 71, + CaseKeyword = 72, + CatchKeyword = 73, + ClassKeyword = 74, + ConstKeyword = 75, + ContinueKeyword = 76, + DebuggerKeyword = 77, + DefaultKeyword = 78, + DeleteKeyword = 79, + DoKeyword = 80, + ElseKeyword = 81, + EnumKeyword = 82, + ExportKeyword = 83, + ExtendsKeyword = 84, + FalseKeyword = 85, + FinallyKeyword = 86, + ForKeyword = 87, + FunctionKeyword = 88, + IfKeyword = 89, + ImportKeyword = 90, + InKeyword = 91, + InstanceOfKeyword = 92, + NewKeyword = 93, + NullKeyword = 94, + ReturnKeyword = 95, + SuperKeyword = 96, + SwitchKeyword = 97, + ThisKeyword = 98, + ThrowKeyword = 99, + TrueKeyword = 100, + TryKeyword = 101, + TypeOfKeyword = 102, + VarKeyword = 103, + VoidKeyword = 104, + WhileKeyword = 105, + WithKeyword = 106, + ImplementsKeyword = 107, + InterfaceKeyword = 108, + LetKeyword = 109, + PackageKeyword = 110, + PrivateKeyword = 111, + ProtectedKeyword = 112, + PublicKeyword = 113, + StaticKeyword = 114, + YieldKeyword = 115, + AbstractKeyword = 116, + AsKeyword = 117, + AnyKeyword = 118, + AsyncKeyword = 119, + AwaitKeyword = 120, + BooleanKeyword = 121, + ConstructorKeyword = 122, + DeclareKeyword = 123, + GetKeyword = 124, + IsKeyword = 125, + ModuleKeyword = 126, + NamespaceKeyword = 127, + NeverKeyword = 128, + ReadonlyKeyword = 129, + RequireKeyword = 130, + NumberKeyword = 131, + SetKeyword = 132, + StringKeyword = 133, + SymbolKeyword = 134, + TypeKeyword = 135, + UndefinedKeyword = 136, + FromKeyword = 137, + GlobalKeyword = 138, + OfKeyword = 139, + QualifiedName = 140, + ComputedPropertyName = 141, + TypeParameter = 142, + Parameter = 143, + Decorator = 144, + PropertySignature = 145, + PropertyDeclaration = 146, + MethodSignature = 147, + MethodDeclaration = 148, + Constructor = 149, + GetAccessor = 150, + SetAccessor = 151, + CallSignature = 152, + ConstructSignature = 153, + IndexSignature = 154, + TypePredicate = 155, + TypeReference = 156, + FunctionType = 157, + ConstructorType = 158, + TypeQuery = 159, + TypeLiteral = 160, + ArrayType = 161, + TupleType = 162, + UnionType = 163, + IntersectionType = 164, + ParenthesizedType = 165, + ThisType = 166, + LiteralType = 167, + ObjectBindingPattern = 168, + ArrayBindingPattern = 169, + BindingElement = 170, + ArrayLiteralExpression = 171, + ObjectLiteralExpression = 172, + PropertyAccessExpression = 173, + ElementAccessExpression = 174, + CallExpression = 175, + NewExpression = 176, + TaggedTemplateExpression = 177, + TypeAssertionExpression = 178, + ParenthesizedExpression = 179, + FunctionExpression = 180, + ArrowFunction = 181, + DeleteExpression = 182, + TypeOfExpression = 183, + VoidExpression = 184, + AwaitExpression = 185, + PrefixUnaryExpression = 186, + PostfixUnaryExpression = 187, + BinaryExpression = 188, + ConditionalExpression = 189, + TemplateExpression = 190, + YieldExpression = 191, + SpreadElementExpression = 192, + ClassExpression = 193, + OmittedExpression = 194, + ExpressionWithTypeArguments = 195, + AsExpression = 196, + NonNullExpression = 197, + TemplateSpan = 198, + SemicolonClassElement = 199, + Block = 200, + VariableStatement = 201, + EmptyStatement = 202, + ExpressionStatement = 203, + IfStatement = 204, + DoStatement = 205, + WhileStatement = 206, + ForStatement = 207, + ForInStatement = 208, + ForOfStatement = 209, + ContinueStatement = 210, + BreakStatement = 211, + ReturnStatement = 212, + WithStatement = 213, + SwitchStatement = 214, + LabeledStatement = 215, + ThrowStatement = 216, + TryStatement = 217, + DebuggerStatement = 218, + VariableDeclaration = 219, + VariableDeclarationList = 220, + FunctionDeclaration = 221, + ClassDeclaration = 222, + InterfaceDeclaration = 223, + TypeAliasDeclaration = 224, + EnumDeclaration = 225, + ModuleDeclaration = 226, + ModuleBlock = 227, + CaseBlock = 228, + NamespaceExportDeclaration = 229, + ImportEqualsDeclaration = 230, + ImportDeclaration = 231, + ImportClause = 232, + NamespaceImport = 233, + NamedImports = 234, + ImportSpecifier = 235, + ExportAssignment = 236, + ExportDeclaration = 237, + NamedExports = 238, + ExportSpecifier = 239, + MissingDeclaration = 240, + ExternalModuleReference = 241, + JsxElement = 242, + JsxSelfClosingElement = 243, + JsxOpeningElement = 244, JsxClosingElement = 245, JsxAttribute = 246, JsxSpreadAttribute = 247, @@ -327,31 +327,31 @@ declare namespace ts { NotEmittedStatement = 287, PartiallyEmittedExpression = 288, Count = 289, - FirstAssignment = 56, - LastAssignment = 68, - FirstCompoundAssignment = 57, - LastCompoundAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 138, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 154, - LastTypeNode = 166, - FirstPunctuation = 15, - LastPunctuation = 68, + FirstAssignment = 57, + LastAssignment = 69, + FirstCompoundAssignment = 58, + LastCompoundAssignment = 69, + FirstReservedWord = 71, + LastReservedWord = 106, + FirstKeyword = 71, + LastKeyword = 139, + FirstFutureReservedWord = 107, + LastFutureReservedWord = 115, + FirstTypeNode = 155, + LastTypeNode = 167, + FirstPunctuation = 16, + LastPunctuation = 69, FirstToken = 0, - LastToken = 138, + LastToken = 139, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 139, + LastLiteralToken = 12, + FirstTemplateToken = 12, + LastTemplateToken = 15, + FirstBinaryOperator = 26, + LastBinaryOperator = 69, + FirstNode = 140, FirstJSDocNode = 257, LastJSDocNode = 282, FirstJSDocTagNode = 273, @@ -406,6 +406,7 @@ declare namespace ts { AccessibilityModifier = 28, ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, + TypeScriptModifier = 2270, } enum JsxFlags { None = 0, @@ -1351,8 +1352,9 @@ declare namespace ts { TrueCondition = 32, FalseCondition = 64, SwitchClause = 128, - Referenced = 256, - Shared = 512, + ArrayMutation = 256, + Referenced = 512, + Shared = 1024, Label = 12, Condition = 96, } @@ -1380,6 +1382,10 @@ declare namespace ts { clauseEnd: number; antecedent: FlowNode; } + interface FlowArrayMutation extends FlowNode { + node: CallExpression | BinaryExpression; + antecedent: FlowNode; + } type FlowType = Type | IncompleteType; interface IncompleteType { flags: TypeFlags; @@ -1913,7 +1919,6 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, - ES6 = 5, ES2015 = 5, } enum JsxEmit { @@ -1939,9 +1944,10 @@ declare namespace ts { enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, ES2015 = 2, - Latest = 2, + ES2016 = 3, + ES2017 = 4, + Latest = 4, } enum LanguageVariant { Standard = 0, diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index c534a7259019f..dad603b624aa2 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -37,259 +37,259 @@ var ts; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 38] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 39] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 40] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 41] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 42] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 43] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 44] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 46] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 47] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 48] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 49] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 50] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 51] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 52] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 53] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 54] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 55] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 56] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 57] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 58] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 59] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 60] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 61] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 62] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 63] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 64] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 66] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 67] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 68] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 70] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 71] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 72] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 73] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 74] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 75] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 76] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 77] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 78] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 79] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 80] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 81] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 82] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 83] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 84] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 85] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 86] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 87] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 88] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 89] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 90] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 91] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 92] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 93] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 94] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 95] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 96] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 97] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 98] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 99] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 100] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 101] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 102] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 103] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 104] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 105] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 106] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 107] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 108] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 109] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 110] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 111] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 112] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 113] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 114] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 115] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 116] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 117] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 118] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 119] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 120] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 121] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 122] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 123] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 124] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 125] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 126] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 127] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 128] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 129] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 130] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 131] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 132] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 133] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 134] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 135] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 136] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 137] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 138] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 139] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 140] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 141] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 142] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 143] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 144] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 145] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 146] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 147] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 148] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 149] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 150] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 151] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 152] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 153] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 154] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 155] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 156] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 157] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 158] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 159] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 160] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 161] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 162] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 163] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 164] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 165] = "ThisType"; - SyntaxKind[SyntaxKind["LiteralType"] = 166] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 167] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 168] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 169] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 170] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 171] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 172] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 173] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 174] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 175] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 176] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 177] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 178] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 179] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 180] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 181] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 182] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 183] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 184] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 185] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 186] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 187] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 188] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 189] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 190] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 191] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 192] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 193] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 194] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 195] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 196] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 197] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 198] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 199] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 200] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 201] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 202] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 203] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 204] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 205] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 206] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 207] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 208] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 209] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 210] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 211] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 212] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 213] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 214] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 215] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 216] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 217] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 218] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 219] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 220] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 221] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 222] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 223] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 224] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 225] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 226] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 227] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 228] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 229] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 230] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 231] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 232] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 233] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 234] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 235] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 236] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 237] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 238] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 239] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 240] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 241] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 242] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 243] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 244] = "JsxText"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; @@ -346,31 +346,31 @@ var ts; // Enum value count SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 57] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 68] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 138] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 154] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 166] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 138] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 139] = "FirstNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; @@ -430,6 +430,7 @@ var ts; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; })(ts.ModifierFlags || (ts.ModifierFlags = {})); var ModifierFlags = ts.ModifierFlags; (function (JsxFlags) { @@ -466,8 +467,9 @@ var ts; FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["Referenced"] = 256] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 512] = "Shared"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(ts.FlowFlags || (ts.FlowFlags = {})); @@ -755,7 +757,6 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; @@ -781,9 +782,10 @@ var ts; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; - ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; - ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; })(ts.ScriptTarget || (ts.ScriptTarget = {})); var ScriptTarget = ts.ScriptTarget; (function (LanguageVariant) { @@ -940,55 +942,58 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; - TransformFlags[TransformFlags["ES7"] = 16] = "ES7"; - TransformFlags[TransformFlags["ContainsES7"] = 32] = "ContainsES7"; - TransformFlags[TransformFlags["ES6"] = 64] = "ES6"; - TransformFlags[TransformFlags["ContainsES6"] = 128] = "ContainsES6"; - TransformFlags[TransformFlags["DestructuringAssignment"] = 256] = "DestructuringAssignment"; - TransformFlags[TransformFlags["Generator"] = 512] = "Generator"; - TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsDecorators"] = 2048] = "ContainsDecorators"; - TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 4096] = "ContainsPropertyInitializer"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 16384] = "ContainsCapturedLexicalThis"; - TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 32768] = "ContainsLexicalThisInComputedPropertyName"; - TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 65536] = "ContainsDefaultValueAssignments"; - TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 131072] = "ContainsParameterPropertyAssignments"; - TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 262144] = "ContainsSpreadElementExpression"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 524288] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 1048576] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 2097152] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 4194304] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 8388608] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; - TransformFlags[TransformFlags["AssertES7"] = 48] = "AssertES7"; - TransformFlags[TransformFlags["AssertES6"] = 192] = "AssertES6"; - TransformFlags[TransformFlags["AssertGenerator"] = 1536] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["NodeExcludes"] = 536871765] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 550710101] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 550726485] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 550593365] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 550593365] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537590613] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546335573] = "ModuleExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537430869] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537133909] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 538968917] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 538968917] = "ParameterExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; // Masks // - Additional bitmasks - TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 137216] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES6FunctionSyntaxMask"] = 81920] = "ES6FunctionSyntaxMask"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; })(ts.TransformFlags || (ts.TransformFlags = {})); var TransformFlags = ts.TransformFlags; /* @internal */ @@ -1044,7 +1049,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -1146,6 +1151,8 @@ var ts; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; var createObject = Object.create; + // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. @@ -1171,7 +1178,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -1378,13 +1385,33 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + // Maps from T to T and avoids allocation if all elements map to themselves + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; /** * Flattens an array containing a mix of array or non-array elements. * @@ -1507,6 +1534,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -1520,8 +1559,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -1557,8 +1596,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -1857,8 +1896,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -1971,7 +2010,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -2002,7 +2041,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -2027,12 +2066,12 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; /* internal */ - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -2095,7 +2134,8 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { + // accent means a ≠ b, a ≠ á, a = A var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } @@ -2269,7 +2309,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; /* @internal */ @@ -2617,7 +2657,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -2632,7 +2672,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -2847,10 +2887,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -3230,7 +3270,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -3462,7 +3502,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { // encoding is automatically handled by the implementation in ChakraHost return ChakraHost.readFile(path); }, @@ -3480,9 +3520,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -4276,7 +4316,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4313,7 +4353,7 @@ var ts; 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" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); /// @@ -4322,133 +4362,133 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 69 /* Identifier */; + return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "abstract": 115 /* AbstractKeyword */, - "any": 117 /* AnyKeyword */, - "as": 116 /* AsKeyword */, - "boolean": 120 /* BooleanKeyword */, - "break": 70 /* BreakKeyword */, - "case": 71 /* CaseKeyword */, - "catch": 72 /* CatchKeyword */, - "class": 73 /* ClassKeyword */, - "continue": 75 /* ContinueKeyword */, - "const": 74 /* ConstKeyword */, - "constructor": 121 /* ConstructorKeyword */, - "debugger": 76 /* DebuggerKeyword */, - "declare": 122 /* DeclareKeyword */, - "default": 77 /* DefaultKeyword */, - "delete": 78 /* DeleteKeyword */, - "do": 79 /* DoKeyword */, - "else": 80 /* ElseKeyword */, - "enum": 81 /* EnumKeyword */, - "export": 82 /* ExportKeyword */, - "extends": 83 /* ExtendsKeyword */, - "false": 84 /* FalseKeyword */, - "finally": 85 /* FinallyKeyword */, - "for": 86 /* ForKeyword */, - "from": 136 /* FromKeyword */, - "function": 87 /* FunctionKeyword */, - "get": 123 /* GetKeyword */, - "if": 88 /* IfKeyword */, - "implements": 106 /* ImplementsKeyword */, - "import": 89 /* ImportKeyword */, - "in": 90 /* InKeyword */, - "instanceof": 91 /* InstanceOfKeyword */, - "interface": 107 /* InterfaceKeyword */, - "is": 124 /* IsKeyword */, - "let": 108 /* LetKeyword */, - "module": 125 /* ModuleKeyword */, - "namespace": 126 /* NamespaceKeyword */, - "never": 127 /* NeverKeyword */, - "new": 92 /* NewKeyword */, - "null": 93 /* NullKeyword */, - "number": 130 /* NumberKeyword */, - "package": 109 /* PackageKeyword */, - "private": 110 /* PrivateKeyword */, - "protected": 111 /* ProtectedKeyword */, - "public": 112 /* PublicKeyword */, - "readonly": 128 /* ReadonlyKeyword */, - "require": 129 /* RequireKeyword */, - "global": 137 /* GlobalKeyword */, - "return": 94 /* ReturnKeyword */, - "set": 131 /* SetKeyword */, - "static": 113 /* StaticKeyword */, - "string": 132 /* StringKeyword */, - "super": 95 /* SuperKeyword */, - "switch": 96 /* SwitchKeyword */, - "symbol": 133 /* SymbolKeyword */, - "this": 97 /* ThisKeyword */, - "throw": 98 /* ThrowKeyword */, - "true": 99 /* TrueKeyword */, - "try": 100 /* TryKeyword */, - "type": 134 /* TypeKeyword */, - "typeof": 101 /* TypeOfKeyword */, - "undefined": 135 /* UndefinedKeyword */, - "var": 102 /* VarKeyword */, - "void": 103 /* VoidKeyword */, - "while": 104 /* WhileKeyword */, - "with": 105 /* WithKeyword */, - "yield": 114 /* YieldKeyword */, - "async": 118 /* AsyncKeyword */, - "await": 119 /* AwaitKeyword */, - "of": 138 /* OfKeyword */, - "{": 15 /* OpenBraceToken */, - "}": 16 /* CloseBraceToken */, - "(": 17 /* OpenParenToken */, - ")": 18 /* CloseParenToken */, - "[": 19 /* OpenBracketToken */, - "]": 20 /* CloseBracketToken */, - ".": 21 /* DotToken */, - "...": 22 /* DotDotDotToken */, - ";": 23 /* SemicolonToken */, - ",": 24 /* CommaToken */, - "<": 25 /* LessThanToken */, - ">": 27 /* GreaterThanToken */, - "<=": 28 /* LessThanEqualsToken */, - ">=": 29 /* GreaterThanEqualsToken */, - "==": 30 /* EqualsEqualsToken */, - "!=": 31 /* ExclamationEqualsToken */, - "===": 32 /* EqualsEqualsEqualsToken */, - "!==": 33 /* ExclamationEqualsEqualsToken */, - "=>": 34 /* EqualsGreaterThanToken */, - "+": 35 /* PlusToken */, - "-": 36 /* MinusToken */, - "**": 38 /* AsteriskAsteriskToken */, - "*": 37 /* AsteriskToken */, - "/": 39 /* SlashToken */, - "%": 40 /* PercentToken */, - "++": 41 /* PlusPlusToken */, - "--": 42 /* MinusMinusToken */, - "<<": 43 /* LessThanLessThanToken */, - ">": 44 /* GreaterThanGreaterThanToken */, - ">>>": 45 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 46 /* AmpersandToken */, - "|": 47 /* BarToken */, - "^": 48 /* CaretToken */, - "!": 49 /* ExclamationToken */, - "~": 50 /* TildeToken */, - "&&": 51 /* AmpersandAmpersandToken */, - "||": 52 /* BarBarToken */, - "?": 53 /* QuestionToken */, - ":": 54 /* ColonToken */, - "=": 56 /* EqualsToken */, - "+=": 57 /* PlusEqualsToken */, - "-=": 58 /* MinusEqualsToken */, - "*=": 59 /* AsteriskEqualsToken */, - "**=": 60 /* AsteriskAsteriskEqualsToken */, - "/=": 61 /* SlashEqualsToken */, - "%=": 62 /* PercentEqualsToken */, - "<<=": 63 /* LessThanLessThanEqualsToken */, - ">>=": 64 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 66 /* AmpersandEqualsToken */, - "|=": 67 /* BarEqualsToken */, - "^=": 68 /* CaretEqualsToken */, - "@": 55 /* AtToken */ + "abstract": 116 /* AbstractKeyword */, + "any": 118 /* AnyKeyword */, + "as": 117 /* AsKeyword */, + "boolean": 121 /* BooleanKeyword */, + "break": 71 /* BreakKeyword */, + "case": 72 /* CaseKeyword */, + "catch": 73 /* CatchKeyword */, + "class": 74 /* ClassKeyword */, + "continue": 76 /* ContinueKeyword */, + "const": 75 /* ConstKeyword */, + "constructor": 122 /* ConstructorKeyword */, + "debugger": 77 /* DebuggerKeyword */, + "declare": 123 /* DeclareKeyword */, + "default": 78 /* DefaultKeyword */, + "delete": 79 /* DeleteKeyword */, + "do": 80 /* DoKeyword */, + "else": 81 /* ElseKeyword */, + "enum": 82 /* EnumKeyword */, + "export": 83 /* ExportKeyword */, + "extends": 84 /* ExtendsKeyword */, + "false": 85 /* FalseKeyword */, + "finally": 86 /* FinallyKeyword */, + "for": 87 /* ForKeyword */, + "from": 137 /* FromKeyword */, + "function": 88 /* FunctionKeyword */, + "get": 124 /* GetKeyword */, + "if": 89 /* IfKeyword */, + "implements": 107 /* ImplementsKeyword */, + "import": 90 /* ImportKeyword */, + "in": 91 /* InKeyword */, + "instanceof": 92 /* InstanceOfKeyword */, + "interface": 108 /* InterfaceKeyword */, + "is": 125 /* IsKeyword */, + "let": 109 /* LetKeyword */, + "module": 126 /* ModuleKeyword */, + "namespace": 127 /* NamespaceKeyword */, + "never": 128 /* NeverKeyword */, + "new": 93 /* NewKeyword */, + "null": 94 /* NullKeyword */, + "number": 131 /* NumberKeyword */, + "package": 110 /* PackageKeyword */, + "private": 111 /* PrivateKeyword */, + "protected": 112 /* ProtectedKeyword */, + "public": 113 /* PublicKeyword */, + "readonly": 129 /* ReadonlyKeyword */, + "require": 130 /* RequireKeyword */, + "global": 138 /* GlobalKeyword */, + "return": 95 /* ReturnKeyword */, + "set": 132 /* SetKeyword */, + "static": 114 /* StaticKeyword */, + "string": 133 /* StringKeyword */, + "super": 96 /* SuperKeyword */, + "switch": 97 /* SwitchKeyword */, + "symbol": 134 /* SymbolKeyword */, + "this": 98 /* ThisKeyword */, + "throw": 99 /* ThrowKeyword */, + "true": 100 /* TrueKeyword */, + "try": 101 /* TryKeyword */, + "type": 135 /* TypeKeyword */, + "typeof": 102 /* TypeOfKeyword */, + "undefined": 136 /* UndefinedKeyword */, + "var": 103 /* VarKeyword */, + "void": 104 /* VoidKeyword */, + "while": 105 /* WhileKeyword */, + "with": 106 /* WithKeyword */, + "yield": 115 /* YieldKeyword */, + "async": 119 /* AsyncKeyword */, + "await": 120 /* AwaitKeyword */, + "of": 139 /* OfKeyword */, + "{": 16 /* OpenBraceToken */, + "}": 17 /* CloseBraceToken */, + "(": 18 /* OpenParenToken */, + ")": 19 /* CloseParenToken */, + "[": 20 /* OpenBracketToken */, + "]": 21 /* CloseBracketToken */, + ".": 22 /* DotToken */, + "...": 23 /* DotDotDotToken */, + ";": 24 /* SemicolonToken */, + ",": 25 /* CommaToken */, + "<": 26 /* LessThanToken */, + ">": 28 /* GreaterThanToken */, + "<=": 29 /* LessThanEqualsToken */, + ">=": 30 /* GreaterThanEqualsToken */, + "==": 31 /* EqualsEqualsToken */, + "!=": 32 /* ExclamationEqualsToken */, + "===": 33 /* EqualsEqualsEqualsToken */, + "!==": 34 /* ExclamationEqualsEqualsToken */, + "=>": 35 /* EqualsGreaterThanToken */, + "+": 36 /* PlusToken */, + "-": 37 /* MinusToken */, + "**": 39 /* AsteriskAsteriskToken */, + "*": 38 /* AsteriskToken */, + "/": 40 /* SlashToken */, + "%": 41 /* PercentToken */, + "++": 42 /* PlusPlusToken */, + "--": 43 /* MinusMinusToken */, + "<<": 44 /* LessThanLessThanToken */, + ">": 45 /* GreaterThanGreaterThanToken */, + ">>>": 46 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 47 /* AmpersandToken */, + "|": 48 /* BarToken */, + "^": 49 /* CaretToken */, + "!": 50 /* ExclamationToken */, + "~": 51 /* TildeToken */, + "&&": 52 /* AmpersandAmpersandToken */, + "||": 53 /* BarBarToken */, + "?": 54 /* QuestionToken */, + ":": 55 /* ColonToken */, + "=": 57 /* EqualsToken */, + "+=": 58 /* PlusEqualsToken */, + "-=": 59 /* MinusEqualsToken */, + "*=": 60 /* AsteriskEqualsToken */, + "**=": 61 /* AsteriskAsteriskEqualsToken */, + "/=": 62 /* SlashEqualsToken */, + "%=": 63 /* PercentEqualsToken */, + "<<=": 64 /* LessThanLessThanEqualsToken */, + ">>=": 65 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 67 /* AmpersandEqualsToken */, + "|=": 68 /* BarEqualsToken */, + "^=": 69 /* CaretEqualsToken */, + "@": 56 /* AtToken */, }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -4952,7 +4992,7 @@ var ts; return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -5025,8 +5065,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, + isIdentifier: function () { return token === 70 /* Identifier */ || token > 106 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -5045,7 +5085,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -5174,7 +5214,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -5182,14 +5222,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 13 /* TemplateHead */ : 14 /* TemplateMiddle */; break; } // Escape character @@ -5367,7 +5407,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -5447,12 +5487,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 34 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 31 /* ExclamationEqualsToken */; + return pos += 2, token = 32 /* ExclamationEqualsToken */; } pos++; - return token = 49 /* ExclamationToken */; + return token = 50 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -5461,68 +5501,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* PercentEqualsToken */; + return pos += 2, token = 63 /* PercentEqualsToken */; } pos++; - return token = 40 /* PercentToken */; + return token = 41 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 51 /* AmpersandAmpersandToken */; + return pos += 2, token = 52 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AmpersandEqualsToken */; + return pos += 2, token = 67 /* AmpersandEqualsToken */; } pos++; - return token = 46 /* AmpersandToken */; + return token = 47 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 17 /* OpenParenToken */; + return token = 18 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 18 /* CloseParenToken */; + return token = 19 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* AsteriskEqualsToken */; + return pos += 2, token = 60 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 61 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 38 /* AsteriskAsteriskToken */; + return pos += 2, token = 39 /* AsteriskAsteriskToken */; } pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 41 /* PlusPlusToken */; + return pos += 2, token = 42 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* PlusEqualsToken */; + return pos += 2, token = 58 /* PlusEqualsToken */; } pos++; - return token = 35 /* PlusToken */; + return token = 36 /* PlusToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 42 /* MinusMinusToken */; + return pos += 2, token = 43 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* MinusEqualsToken */; + return pos += 2, token = 59 /* MinusEqualsToken */; } pos++; - return token = 36 /* MinusToken */; + return token = 37 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 22 /* DotDotDotToken */; + return pos += 3, token = 23 /* DotDotDotToken */; } pos++; - return token = 21 /* DotToken */; + return token = 22 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -5568,10 +5608,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* SlashEqualsToken */; + return pos += 2, token = 62 /* SlashEqualsToken */; } pos++; - return token = 39 /* SlashToken */; + return token = 40 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -5624,10 +5664,10 @@ var ts; return token = 8 /* NumericLiteral */; case 58 /* colon */: pos++; - return token = 54 /* ColonToken */; + return token = 55 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 23 /* SemicolonToken */; + return token = 24 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5640,20 +5680,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 64 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 43 /* LessThanLessThanToken */; + return pos += 2, token = 44 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 28 /* LessThanEqualsToken */; + return pos += 2, token = 29 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 26 /* LessThanSlashToken */; + return pos += 2, token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5666,15 +5706,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 33 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 30 /* EqualsEqualsToken */; + return pos += 2, token = 31 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 34 /* EqualsGreaterThanToken */; + return pos += 2, token = 35 /* EqualsGreaterThanToken */; } pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5686,43 +5726,43 @@ var ts; } } pos++; - return token = 27 /* GreaterThanToken */; + return token = 28 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 53 /* QuestionToken */; + return token = 54 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* CaretEqualsToken */; + return pos += 2, token = 69 /* CaretEqualsToken */; } pos++; - return token = 48 /* CaretToken */; + return token = 49 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 52 /* BarBarToken */; + return pos += 2, token = 53 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* BarEqualsToken */; + return pos += 2, token = 68 /* BarEqualsToken */; } pos++; - return token = 47 /* BarToken */; + return token = 48 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 50 /* TildeToken */; + return token = 51 /* TildeToken */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -5760,29 +5800,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27 /* GreaterThanToken */) { + if (token === 28 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 46 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 65 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 44 /* GreaterThanGreaterThanToken */; + return token = 45 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 29 /* GreaterThanEqualsToken */; + return token = 30 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { + if (token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -5827,7 +5867,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10 /* RegularExpressionLiteral */; + token = 11 /* RegularExpressionLiteral */; } return token; } @@ -5835,7 +5875,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -5852,14 +5892,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 26 /* LessThanSlashToken */; + return token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -5868,7 +5908,7 @@ var ts; break; } } - return token = 244 /* JsxText */; + return token = 10 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -5918,39 +5958,39 @@ var ts; return token = 5 /* WhitespaceTrivia */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: pos++; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 61 /* equals */: pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; } - if (isIdentifierStart(ch, 2 /* Latest */)) { + if (isIdentifierStart(ch, 4 /* Latest */)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2 /* Latest */) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4 /* Latest */) && pos < end) { pos++; } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } else { return pos += 1, token = 0 /* Unknown */; @@ -6189,11 +6229,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return true; } return false; @@ -6329,14 +6369,14 @@ var ts; function getLiteralText(node, sourceFile, languageVersion) { // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < 2 /* ES6 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + if (languageVersion < 2 /* ES2015 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { return getQuotedEscapedLiteralText('"', node.text, '"'); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + if (languageVersion < 2 /* ES2015 */ && isBinaryOrOctalIntegerLiteral(node, text)) { return node.text; } return text; @@ -6346,13 +6386,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: + case 14 /* TemplateMiddle */: return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: + case 15 /* TemplateTail */: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8 /* NumericLiteral */: return node.text; @@ -6398,7 +6438,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 /* ModuleDeclaration */ && + return node && node.kind === 226 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6408,11 +6448,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 === 225 /* ModuleDeclaration */ && (!node.body); + return node.kind === 226 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 /* SourceFile */ || - node.kind === 225 /* ModuleDeclaration */ || + node.kind === 226 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6430,7 +6470,7 @@ var ts; switch (node.parent.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node.parent); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6439,21 +6479,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: case 252 /* CatchClause */: - case 225 /* ModuleDeclaration */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 226 /* ModuleDeclaration */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return true; - case 199 /* Block */: + case 200 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6475,7 +6515,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 /* VariableDeclaration */ && + declaration.kind === 219 /* VariableDeclaration */ && declaration.parent && declaration.parent.kind === 252 /* CatchClause */; } @@ -6515,7 +6555,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199 /* Block */) { + if (node.body && node.body.kind === 200 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6538,23 +6578,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 224 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6577,7 +6617,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 /* EnumDeclaration */ && isConst(node); + return node.kind === 225 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6590,11 +6630,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 203 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6610,10 +6650,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 /* Parameter */ || - node.kind === 141 /* TypeParameter */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 180 /* ArrowFunction */) ? + var commentRanges = (node.kind === 143 /* Parameter */ || + node.kind === 142 /* TypeParameter */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 181 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6629,39 +6669,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 /* FirstTypeNode */ <= node.kind && node.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= node.kind && node.kind <= 167 /* LastTypeNode */) { return true; } switch (node.kind) { - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return true; - case 103 /* VoidKeyword */: - return node.parent.kind !== 183 /* VoidExpression */; - case 194 /* ExpressionWithTypeArguments */: + case 104 /* VoidKeyword */: + return node.parent.kind !== 184 /* VoidExpression */; + case 195 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 69 /* Identifier */: + case 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139 /* QualifiedName */: - case 172 /* PropertyAccessExpression */: - case 97 /* ThisKeyword */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 98 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 158 /* TypeQuery */) { + if (parent_1.kind === 159 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -6670,38 +6710,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (154 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 167 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return node === parent_1.constraint; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: return node === parent_1.type; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node === parent_1.type; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return node === parent_1.type; - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return node === parent_1.type; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6715,22 +6755,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitor(node); - case 227 /* CaseBlock */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 228 /* CaseBlock */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: case 250 /* DefaultClause */: - case 214 /* LabeledStatement */: - case 216 /* TryStatement */: + case 215 /* LabeledStatement */: + case 217 /* TryStatement */: case 252 /* CatchClause */: return ts.forEachChild(node, traverse); } @@ -6741,18 +6781,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* 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 // skipped in this traversal. @@ -6760,7 +6800,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 140 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 141 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(name_5.expression); @@ -6779,14 +6819,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: case 255 /* EnumMember */: - case 142 /* Parameter */: + case 143 /* Parameter */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 254 /* ShorthandPropertyAssignment */: - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return true; } } @@ -6794,11 +6834,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */); + return node && (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */); + return node && (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6807,19 +6847,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return true; } return false; @@ -6827,13 +6867,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return true; } return false; @@ -6841,30 +6881,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return true; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 200 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 /* MethodDeclaration */ && node.parent.kind === 171 /* ObjectLiteralExpression */; + return node && node.kind === 148 /* MethodDeclaration */ && node.parent.kind === 172 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 /* MethodDeclaration */ && - (node.parent.kind === 171 /* ObjectLiteralExpression */ || - node.parent.kind === 192 /* ClassExpression */); + return node.kind === 148 /* MethodDeclaration */ && + (node.parent.kind === 172 /* ObjectLiteralExpression */ || + node.parent.kind === 193 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6900,7 +6940,7 @@ var ts; return undefined; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -6915,9 +6955,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -6928,25 +6968,25 @@ var ts; node = node.parent; } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 225 /* ModuleDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 226 /* ModuleDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 225 /* EnumDeclaration */: case 256 /* SourceFile */: return node; } @@ -6968,26 +7008,26 @@ var ts; return node; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: node = node.parent; break; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -7003,14 +7043,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */) { + if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 178 /* ParenthesizedExpression */) { + while (parent_2.kind === 179 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 174 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7021,20 +7061,20 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 /* PropertyAccessExpression */ || kind === 173 /* ElementAccessExpression */) - && node.expression.kind === 95 /* SuperKeyword */; + return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: return node; } } @@ -7043,10 +7083,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 143 /* Decorator */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 144 /* Decorator */: return true; default: return false; @@ -7054,7 +7094,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7063,25 +7103,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // classes are valid targets return true; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 221 /* ClassDeclaration */; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + return node.parent.kind === 222 /* ClassDeclaration */; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* 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 === 221 /* ClassDeclaration */; - case 142 /* Parameter */: + && node.parent.kind === 222 /* ClassDeclaration */; + case 143 /* 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 === 148 /* Constructor */ - || node.parent.kind === 147 /* MethodDeclaration */ - || node.parent.kind === 150 /* SetAccessor */) - && node.parent.parent.kind === 221 /* ClassDeclaration */; + && (node.parent.kind === 149 /* Constructor */ + || node.parent.kind === 148 /* MethodDeclaration */ + || node.parent.kind === 151 /* SetAccessor */) + && node.parent.parent.kind === 222 /* ClassDeclaration */; } return false; } @@ -7097,18 +7137,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147 /* MethodDeclaration */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 151 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 /* JsxOpeningElement */ || - parent.kind === 242 /* JsxSelfClosingElement */ || + if (parent.kind === 244 /* JsxOpeningElement */ || + parent.kind === 243 /* JsxSelfClosingElement */ || parent.kind === 245 /* JsxClosingElement */) { return parent.tagName === node; } @@ -7117,98 +7157,98 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 10 /* RegularExpressionLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 195 /* AsExpression */: - case 177 /* TypeAssertionExpression */: - case 196 /* NonNullExpression */: - case 178 /* ParenthesizedExpression */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 191 /* SpreadElementExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 193 /* OmittedExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 190 /* YieldExpression */: - case 184 /* AwaitExpression */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 11 /* RegularExpressionLiteral */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 196 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 197 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 192 /* SpreadElementExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 194 /* OmittedExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 191 /* YieldExpression */: + case 185 /* AwaitExpression */: return true; - case 139 /* QualifiedName */: - while (node.parent.kind === 139 /* QualifiedName */) { + case 140 /* QualifiedName */: + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node); - case 69 /* Identifier */: - if (node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node); + case 70 /* Identifier */: + if (node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: return parent_3.initializer === node; - case 202 /* ExpressionStatement */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 211 /* ReturnStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 203 /* ExpressionStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 212 /* ReturnStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: - case 215 /* ThrowStatement */: - case 213 /* SwitchStatement */: + case 216 /* ThrowStatement */: + case 214 /* SwitchStatement */: return parent_3.expression === node; - case 206 /* ForStatement */: + case 207 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forInStatement.expression === node; - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return node === parent_3.expression; - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return node === parent_3.expression; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return node === parent_3.expression; - case 143 /* Decorator */: + case 144 /* Decorator */: case 248 /* JsxExpression */: case 247 /* JsxSpreadAttribute */: return true; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7226,7 +7266,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7235,7 +7275,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7253,8 +7293,8 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 174 /* CallExpression */ && - expression.expression.kind === 69 /* Identifier */ && + var isRequire = expression.kind === 175 /* CallExpression */ && + expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); @@ -7269,9 +7309,9 @@ 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 === 218 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; } return false; } @@ -7282,15 +7322,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 187 /* BinaryExpression */) { + if (expression.kind !== 188 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 172 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 173 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; - if (lhs.expression.kind === 69 /* Identifier */) { + if (lhs.expression.kind === 70 /* Identifier */) { var lhsId = lhs.expression; if (lhsId.text === "exports") { // exports.name = expr @@ -7301,13 +7341,13 @@ var ts; return 2 /* ModuleExports */; } } - else if (lhs.expression.kind === 97 /* ThisKeyword */) { + else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 172 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 173 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69 /* Identifier */) { + if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { // module.exports.name = expr var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { @@ -7322,35 +7362,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 240 /* ExternalModuleReference */) { + if (reference.kind === 241 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 236 /* ExportDeclaration */) { + if (node.kind === 237 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 225 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 /* ImportDeclaration */ + return node.kind === 231 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7358,13 +7398,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142 /* Parameter */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 143 /* Parameter */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: case 254 /* ShorthandPropertyAssignment */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7434,25 +7474,25 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.parent.kind === 201 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.kind === 201 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 /* ModuleDeclaration */ && - node.parent && node.parent.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 226 /* ModuleDeclaration */) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 /* BinaryExpression */ && - parent_4.operatorToken.kind === 56 /* EqualsToken */ && - parent_4.parent.kind === 202 /* ExpressionStatement */; + parent_4.kind === 188 /* BinaryExpression */ && + parent_4.operatorToken.kind === 57 /* EqualsToken */ && + parent_4.parent.kind === 203 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -7461,7 +7501,7 @@ var ts; result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } // Pull parameter comments from declaring function as well - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7492,7 +7532,7 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69 /* Identifier */) { + else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { @@ -7518,7 +7558,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69 /* Identifier */) { + if (parameter.name && parameter.name.kind === 70 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; @@ -7568,12 +7608,12 @@ var ts; // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */) { node = node.parent; } while (true) { var parent_5 = node.parent; - if (parent_5.kind === 170 /* ArrayLiteralExpression */ || parent_5.kind === 191 /* SpreadElementExpression */) { + if (parent_5.kind === 171 /* ArrayLiteralExpression */ || parent_5.kind === 192 /* SpreadElementExpression */) { node = parent_5; continue; } @@ -7581,10 +7621,10 @@ var ts; node = parent_5.parent; continue; } - return parent_5.kind === 187 /* BinaryExpression */ && + return parent_5.kind === 188 /* BinaryExpression */ && isAssignmentOperator(parent_5.operatorToken.kind) && parent_5.left === node || - (parent_5.kind === 207 /* ForInStatement */ || parent_5.kind === 208 /* ForOfStatement */) && + (parent_5.kind === 208 /* ForInStatement */ || parent_5.kind === 209 /* ForOfStatement */) && parent_5.initializer === node; } } @@ -7610,11 +7650,11 @@ var ts; ts.isInAmbientContext = isInAmbientContext; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 70 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 234 /* ImportSpecifier */ || parent.kind === 238 /* ExportSpecifier */) { + if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7627,7 +7667,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 140 /* ComputedPropertyName */ && + node.parent.kind === 141 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -7635,31 +7675,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 139 /* QualifiedName */) { + while (parent.kind === 140 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 158 /* TypeQuery */; + return parent.kind === 159 /* TypeQuery */; } return false; - case 169 /* BindingElement */: - case 234 /* ImportSpecifier */: + case 170 /* BindingElement */: + case 235 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7675,13 +7715,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 228 /* NamespaceExportDeclaration */ || - node.kind === 231 /* ImportClause */ && !!node.name || - node.kind === 232 /* NamespaceImport */ || - node.kind === 234 /* ImportSpecifier */ || - node.kind === 238 /* ExportSpecifier */ || - node.kind === 235 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 229 /* NamespaceExportDeclaration */ || + node.kind === 232 /* ImportClause */ && !!node.name || + node.kind === 233 /* NamespaceImport */ || + node.kind === 235 /* ImportSpecifier */ || + node.kind === 239 /* ExportSpecifier */ || + node.kind === 236 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7689,17 +7729,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 107 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -7767,7 +7807,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 138 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 139 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -7794,7 +7834,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 /* ComputedPropertyName */ && + return name.kind === 141 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -7809,10 +7849,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 142 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 143 /* Parameter */) { return name.text; } - if (name.kind === 140 /* ComputedPropertyName */) { + if (name.kind === 141 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -7833,22 +7873,26 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 69 /* Identifier */ && node.text === "Symbol"; + return node.kind === 70 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 122 /* DeclareKeyword */: - case 77 /* DefaultKeyword */: - case 82 /* ExportKeyword */: - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 128 /* ReadonlyKeyword */: - case 113 /* StaticKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 114 /* StaticKeyword */: return true; } return false; @@ -7856,11 +7900,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142 /* Parameter */; + return root.kind === 143 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169 /* BindingElement */) { + while (node.kind === 170 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7868,14 +7912,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 179 /* FunctionExpression */ - || kind === 220 /* FunctionDeclaration */ - || kind === 180 /* ArrowFunction */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 225 /* ModuleDeclaration */ + return kind === 149 /* Constructor */ + || kind === 180 /* FunctionExpression */ + || kind === 221 /* FunctionDeclaration */ + || kind === 181 /* ArrowFunction */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 226 /* ModuleDeclaration */ || kind === 256 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -7937,38 +7981,38 @@ var ts; var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: - case 188 /* ConditionalExpression */: - case 190 /* YieldExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: + case 189 /* ConditionalExpression */: + case 191 /* YieldExpression */: return 1 /* Right */; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operator) { - case 38 /* AsteriskAsteriskToken */: - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 39 /* AsteriskAsteriskToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 1 /* Right */; } } @@ -7977,15 +8021,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187 /* BinaryExpression */) { + if (expression.kind === 188 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 185 /* PrefixUnaryExpression */ || expression.kind === 186 /* PostfixUnaryExpression */) { + else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -7995,106 +8039,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 69 /* Identifier */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 70 /* Identifier */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 189 /* TemplateExpression */: - case 178 /* ParenthesizedExpression */: - case 193 /* OmittedExpression */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 190 /* TemplateExpression */: + case 179 /* ParenthesizedExpression */: + case 194 /* OmittedExpression */: return 19; - case 176 /* TaggedTemplateExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 177 /* TaggedTemplateExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: return 18; - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 18 : 17; - case 174 /* CallExpression */: + case 175 /* CallExpression */: return 17; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return 16; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: return 15; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operatorKind) { - case 49 /* ExclamationToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 51 /* TildeToken */: return 15; - case 38 /* AsteriskAsteriskToken */: - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 39 /* AsteriskAsteriskToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 14; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 13; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 25 /* LessThanToken */: - case 28 /* LessThanEqualsToken */: - case 27 /* GreaterThanToken */: - case 29 /* GreaterThanEqualsToken */: - case 90 /* InKeyword */: - case 91 /* InstanceOfKeyword */: + case 26 /* LessThanToken */: + case 29 /* LessThanEqualsToken */: + case 28 /* GreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 91 /* InKeyword */: + case 92 /* InstanceOfKeyword */: return 11; - case 30 /* EqualsEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 10; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 9; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 8; - case 47 /* BarToken */: + case 48 /* BarToken */: return 7; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 6; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 5; - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 3; - case 24 /* CommaToken */: + case 25 /* CommaToken */: return 0; default: return -1; } - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return 4; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return 2; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return 1; default: return -1; @@ -8395,7 +8439,7 @@ var ts; var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -8427,7 +8471,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -8533,7 +8577,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8561,11 +8605,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 /* Identifier */ && identifierIsThisKeyword(node); + return node && node.kind === 70 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97 /* ThisKeyword */; + return id.originalKeywordKind === 98 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -8575,10 +8619,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 150 /* SetAccessor */) { + else if (accessor.kind === 151 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8587,7 +8631,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 /* GetAccessor */ || member.kind === 150 /* SetAccessor */) + if ((member.kind === 150 /* GetAccessor */ || member.kind === 151 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8598,10 +8642,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 /* GetAccessor */ && !getAccessor) { + if (member.kind === 150 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 150 /* SetAccessor */ && !setAccessor) { + if (member.kind === 151 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -8837,35 +8881,35 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 32 /* Static */; - case 112 /* PublicKeyword */: return 4 /* Public */; - case 111 /* ProtectedKeyword */: return 16 /* Protected */; - case 110 /* PrivateKeyword */: return 8 /* Private */; - case 115 /* AbstractKeyword */: return 128 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 2048 /* Const */; - case 77 /* DefaultKeyword */: return 512 /* Default */; - case 118 /* AsyncKeyword */: return 256 /* Async */; - case 128 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 114 /* StaticKeyword */: return 32 /* Static */; + case 113 /* PublicKeyword */: return 4 /* Public */; + case 112 /* ProtectedKeyword */: return 16 /* Protected */; + case 111 /* PrivateKeyword */: return 8 /* Private */; + case 116 /* AbstractKeyword */: return 128 /* Abstract */; + case 83 /* ExportKeyword */: return 1 /* Export */; + case 123 /* DeclareKeyword */: return 2 /* Ambient */; + case 75 /* ConstKeyword */: return 2048 /* Const */; + case 78 /* DefaultKeyword */: return 512 /* Default */; + case 119 /* AsyncKeyword */: return 256 /* Async */; + case 129 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 /* BarBarToken */ - || token === 51 /* AmpersandAmpersandToken */ - || token === 49 /* ExclamationToken */; + return token === 53 /* BarBarToken */ + || token === 52 /* AmpersandAmpersandToken */ + || token === 50 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; + return token >= 57 /* FirstAssignment */ && token <= 69 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ && - node.parent.token === 83 /* ExtendsKeyword */ && + if (node.kind === 195 /* ExpressionWithTypeArguments */ && + node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -8873,10 +8917,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.operatorToken.kind === 57 /* EqualsToken */) { var kind = node.left.kind; - return kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; + return kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; } } return false; @@ -8889,7 +8933,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { return true; } else if (isPropertyAccessExpression(node)) { @@ -8904,21 +8948,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 /* Identifier */ || - node.kind === 172 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + return node.kind === 70 /* Identifier */ || + node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171 /* ObjectLiteralExpression */) { + if (kind === 172 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 170 /* ArrayLiteralExpression */) { + if (kind === 171 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9070,49 +9114,49 @@ var ts; var kind = node.kind; if (kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 10 /* RegularExpressionLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 69 /* Identifier */ - || kind === 97 /* ThisKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */) { + || kind === 11 /* RegularExpressionLiteral */ + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 70 /* Identifier */ + || kind === 98 /* ThisKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 172 /* PropertyAccessExpression */) { + else if (kind === 173 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173 /* ElementAccessExpression */) { + else if (kind === 174 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */) { + else if (kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187 /* BinaryExpression */) { - return node.operatorToken.kind !== 38 /* AsteriskAsteriskToken */ + else if (kind === 188 /* BinaryExpression */) { + return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188 /* ConditionalExpression */) { + else if (kind === 189 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 /* VoidExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 181 /* DeleteExpression */) { + else if (kind === 184 /* VoidExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 182 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170 /* ArrayLiteralExpression */) { + else if (kind === 171 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 171 /* ObjectLiteralExpression */) { + else if (kind === 172 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 174 /* CallExpression */) { + else if (kind === 175 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9271,7 +9315,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -9279,33 +9323,28 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 230 /* ImportDeclaration */: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { - // import "mod" - // import x from "mod" where x is referenced - // import * as x from "mod" where x is referenced - // import { x, y } from "mod" where at least one import is referenced - externalImports.push(node); - } + case 231 /* ImportDeclaration */: + // import "mod" + // import x from "mod" + // import * as x from "mod" + // import { x, y } from "mod" + externalImports.push(node); break; - case 229 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 240 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced + case 230 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + // import x = require("mod") externalImports.push(node); } break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol + else { + // export { x, y } from "mod" externalImports.push(node); } } @@ -9318,7 +9357,7 @@ var ts; } } break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -9343,7 +9382,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 === 221 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 222 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9373,15 +9412,15 @@ var ts; ts.isNodeArray = isNodeArray; // Literals function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11 /* NoSubstitutionTemplateLiteral */; + return node.kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 12 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9390,22 +9429,22 @@ var ts; ts.isLiteralExpression = isLiteralExpression; // Pseudo-literals function isTemplateLiteralKind(kind) { - return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; + return 12 /* FirstTemplateToken */ <= kind && kind <= 15 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12 /* TemplateHead */; + return node.kind === 13 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 /* TemplateMiddle */ - || kind === 14 /* TemplateTail */; + return kind === 14 /* TemplateMiddle */ + || kind === 15 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { - return node.kind === 69 /* Identifier */; + return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -9420,90 +9459,90 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 139 /* QualifiedName */; + return node.kind === 140 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140 /* ComputedPropertyName */; + return node.kind === 141 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 140 /* ComputedPropertyName */; + || kind === 141 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 167 /* ObjectBindingPattern */ - || kind === 168 /* ArrayBindingPattern */; + return kind === 70 /* Identifier */ + || kind === 168 /* ObjectBindingPattern */ + || kind === 169 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 141 /* TypeParameter */; + return node.kind === 142 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142 /* Parameter */; + return node.kind === 143 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 145 /* PropertyDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 153 /* IndexSignature */ - || kind === 198 /* SemicolonClassElement */; + return kind === 149 /* Constructor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 154 /* IndexSignature */ + || kind === 199 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 /* PropertyAssignment */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 239 /* MissingDeclaration */; + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 240 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) - || kind === 117 /* AnyKeyword */ - || kind === 130 /* NumberKeyword */ - || kind === 120 /* BooleanKeyword */ - || kind === 132 /* StringKeyword */ - || kind === 133 /* SymbolKeyword */ - || kind === 103 /* VoidKeyword */ - || kind === 127 /* NeverKeyword */ - || kind === 194 /* ExpressionWithTypeArguments */; + return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + || kind === 118 /* AnyKeyword */ + || kind === 131 /* NumberKeyword */ + || kind === 121 /* BooleanKeyword */ + || kind === 133 /* StringKeyword */ + || kind === 134 /* SymbolKeyword */ + || kind === 104 /* VoidKeyword */ + || kind === 128 /* NeverKeyword */ + || kind === 195 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9518,95 +9557,95 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 /* ArrayBindingPattern */ - || kind === 167 /* ObjectBindingPattern */; + return kind === 169 /* ArrayBindingPattern */ + || kind === 168 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169 /* BindingElement */; + return node.kind === 170 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 /* BindingElement */ - || kind === 193 /* OmittedExpression */; + return kind === 170 /* BindingElement */ + || kind === 194 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression function isPropertyAccessExpression(node) { - return node.kind === 172 /* PropertyAccessExpression */; + return node.kind === 173 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173 /* ElementAccessExpression */; + return node.kind === 174 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187 /* BinaryExpression */; + return node.kind === 188 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188 /* ConditionalExpression */; + return node.kind === 189 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174 /* CallExpression */; + return node.kind === 175 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 /* TemplateExpression */ - || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 190 /* TemplateExpression */ + || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191 /* SpreadElementExpression */; + return node.kind === 192 /* SpreadElementExpression */; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194 /* ExpressionWithTypeArguments */; + return node.kind === 195 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 /* PropertyAccessExpression */ - || kind === 173 /* ElementAccessExpression */ - || kind === 175 /* NewExpression */ - || kind === 174 /* CallExpression */ - || kind === 241 /* JsxElement */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 176 /* TaggedTemplateExpression */ - || kind === 170 /* ArrayLiteralExpression */ - || kind === 178 /* ParenthesizedExpression */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 192 /* ClassExpression */ - || kind === 179 /* FunctionExpression */ - || kind === 69 /* Identifier */ - || kind === 10 /* RegularExpressionLiteral */ + return kind === 173 /* PropertyAccessExpression */ + || kind === 174 /* ElementAccessExpression */ + || kind === 176 /* NewExpression */ + || kind === 175 /* CallExpression */ + || kind === 242 /* JsxElement */ + || kind === 243 /* JsxSelfClosingElement */ + || kind === 177 /* TaggedTemplateExpression */ + || kind === 171 /* ArrayLiteralExpression */ + || kind === 179 /* ParenthesizedExpression */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 193 /* ClassExpression */ + || kind === 180 /* FunctionExpression */ + || kind === 70 /* Identifier */ + || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 189 /* TemplateExpression */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */ - || kind === 97 /* ThisKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 196 /* NonNullExpression */; + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 190 /* TemplateExpression */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */ + || kind === 98 /* ThisKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 197 /* NonNullExpression */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */ - || kind === 181 /* DeleteExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 183 /* VoidExpression */ - || kind === 184 /* AwaitExpression */ - || kind === 177 /* TypeAssertionExpression */ + return kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */ + || kind === 182 /* DeleteExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 184 /* VoidExpression */ + || kind === 185 /* AwaitExpression */ + || kind === 178 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9614,13 +9653,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 /* ConditionalExpression */ - || kind === 190 /* YieldExpression */ - || kind === 180 /* ArrowFunction */ - || kind === 187 /* BinaryExpression */ - || kind === 191 /* SpreadElementExpression */ - || kind === 195 /* AsExpression */ - || kind === 193 /* OmittedExpression */ + return kind === 189 /* ConditionalExpression */ + || kind === 191 /* YieldExpression */ + || kind === 181 /* ArrowFunction */ + || kind === 188 /* BinaryExpression */ + || kind === 192 /* SpreadElementExpression */ + || kind === 196 /* AsExpression */ + || kind === 194 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9629,8 +9668,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 /* TypeAssertionExpression */ - || kind === 195 /* AsExpression */; + return kind === 178 /* TypeAssertionExpression */ + || kind === 196 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -9647,17 +9686,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193 /* OmittedExpression */; + return node.kind === 194 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 197 /* TemplateSpan */; + return node.kind === 198 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 199 /* Block */; + return node.kind === 200 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9675,118 +9714,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218 /* VariableDeclaration */; + return node.kind === 219 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219 /* VariableDeclarationList */; + return node.kind === 220 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227 /* CaseBlock */; + return node.kind === 228 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 /* ModuleBlock */ - || kind === 225 /* ModuleDeclaration */; + return kind === 227 /* ModuleBlock */ + || kind === 226 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */; + return node.kind === 230 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231 /* ImportClause */; + return node.kind === 232 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 /* NamedImports */ - || kind === 232 /* NamespaceImport */; + return kind === 234 /* NamedImports */ + || kind === 233 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234 /* ImportSpecifier */; + return node.kind === 235 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237 /* NamedExports */; + return node.kind === 238 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238 /* ExportSpecifier */; + return node.kind === 239 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 /* ModuleDeclaration */ || node.kind === 224 /* EnumDeclaration */; + return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 /* ArrowFunction */ - || kind === 169 /* BindingElement */ - || kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 148 /* Constructor */ - || kind === 224 /* EnumDeclaration */ + return kind === 181 /* ArrowFunction */ + || kind === 170 /* BindingElement */ + || kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 149 /* Constructor */ + || kind === 225 /* EnumDeclaration */ || kind === 255 /* EnumMember */ - || kind === 238 /* ExportSpecifier */ - || kind === 220 /* FunctionDeclaration */ - || kind === 179 /* FunctionExpression */ - || kind === 149 /* GetAccessor */ - || kind === 231 /* ImportClause */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 234 /* ImportSpecifier */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 146 /* MethodSignature */ - || kind === 225 /* ModuleDeclaration */ - || kind === 228 /* NamespaceExportDeclaration */ - || kind === 232 /* NamespaceImport */ - || kind === 142 /* Parameter */ + || kind === 239 /* ExportSpecifier */ + || kind === 221 /* FunctionDeclaration */ + || kind === 180 /* FunctionExpression */ + || kind === 150 /* GetAccessor */ + || kind === 232 /* ImportClause */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 235 /* ImportSpecifier */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 147 /* MethodSignature */ + || kind === 226 /* ModuleDeclaration */ + || kind === 229 /* NamespaceExportDeclaration */ + || kind === 233 /* NamespaceImport */ + || kind === 143 /* Parameter */ || kind === 253 /* PropertyAssignment */ - || kind === 145 /* PropertyDeclaration */ - || kind === 144 /* PropertySignature */ - || kind === 150 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 145 /* PropertySignature */ + || kind === 151 /* SetAccessor */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 141 /* TypeParameter */ - || kind === 218 /* VariableDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 142 /* TypeParameter */ + || kind === 219 /* VariableDeclaration */ || kind === 279 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 220 /* FunctionDeclaration */ - || kind === 239 /* MissingDeclaration */ - || kind === 221 /* ClassDeclaration */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 224 /* EnumDeclaration */ - || kind === 225 /* ModuleDeclaration */ - || kind === 230 /* ImportDeclaration */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 236 /* ExportDeclaration */ - || kind === 235 /* ExportAssignment */ - || kind === 228 /* NamespaceExportDeclaration */; + return kind === 221 /* FunctionDeclaration */ + || kind === 240 /* MissingDeclaration */ + || kind === 222 /* ClassDeclaration */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 225 /* EnumDeclaration */ + || kind === 226 /* ModuleDeclaration */ + || kind === 231 /* ImportDeclaration */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 237 /* ExportDeclaration */ + || kind === 236 /* ExportAssignment */ + || kind === 229 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 /* BreakStatement */ - || kind === 209 /* ContinueStatement */ - || kind === 217 /* DebuggerStatement */ - || kind === 204 /* DoStatement */ - || kind === 202 /* ExpressionStatement */ - || kind === 201 /* EmptyStatement */ - || kind === 207 /* ForInStatement */ - || kind === 208 /* ForOfStatement */ - || kind === 206 /* ForStatement */ - || kind === 203 /* IfStatement */ - || kind === 214 /* LabeledStatement */ - || kind === 211 /* ReturnStatement */ - || kind === 213 /* SwitchStatement */ - || kind === 215 /* ThrowStatement */ - || kind === 216 /* TryStatement */ - || kind === 200 /* VariableStatement */ - || kind === 205 /* WhileStatement */ - || kind === 212 /* WithStatement */ + return kind === 211 /* BreakStatement */ + || kind === 210 /* ContinueStatement */ + || kind === 218 /* DebuggerStatement */ + || kind === 205 /* DoStatement */ + || kind === 203 /* ExpressionStatement */ + || kind === 202 /* EmptyStatement */ + || kind === 208 /* ForInStatement */ + || kind === 209 /* ForOfStatement */ + || kind === 207 /* ForStatement */ + || kind === 204 /* IfStatement */ + || kind === 215 /* LabeledStatement */ + || kind === 212 /* ReturnStatement */ + || kind === 214 /* SwitchStatement */ + || kind === 216 /* ThrowStatement */ + || kind === 217 /* TryStatement */ + || kind === 201 /* VariableStatement */ + || kind === 206 /* WhileStatement */ + || kind === 213 /* WithStatement */ || kind === 287 /* NotEmittedStatement */; } function isDeclaration(node) { @@ -9808,20 +9847,20 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199 /* Block */; + || kind === 200 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 240 /* ExternalModuleReference */ - || kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 241 /* ExternalModuleReference */ + || kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 243 /* JsxOpeningElement */; + return node.kind === 244 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -9830,17 +9869,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 /* ThisKeyword */ - || kind === 69 /* Identifier */ - || kind === 172 /* PropertyAccessExpression */; + return kind === 98 /* ThisKeyword */ + || kind === 70 /* Identifier */ + || kind === 173 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 /* JsxElement */ + return kind === 242 /* JsxElement */ || kind === 248 /* JsxExpression */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 244 /* JsxText */; + || kind === 243 /* JsxSelfClosingElement */ + || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -9905,7 +9944,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4 /* ES2017 */: + return "lib.es2017.d.ts"; + case 3 /* ES2016 */: + return "lib.es2016.d.ts"; + case 2 /* ES2015 */: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -10114,9 +10162,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141 /* TypeParameter */) { + if (d && d.kind === 142 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223 /* InterfaceDeclaration */) { return current; } } @@ -10124,11 +10172,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 148 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 149 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10136,14 +10184,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10159,14 +10207,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10271,7 +10319,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 /* TrueKeyword */ : 84 /* FalseKeyword */, location, /*flags*/ undefined); + return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); } else if (typeof value === "string") { var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); @@ -10289,7 +10337,7 @@ var ts; // Identifiers var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69 /* Identifier */, location); + var node = createNode(70 /* Identifier */, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0 /* None */; @@ -10298,7 +10346,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 1 /* Auto */; @@ -10311,7 +10359,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 2 /* Loop */; @@ -10321,7 +10369,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = text; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 3 /* Unique */; @@ -10331,7 +10379,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.original = node; name.text = ""; name.originalKeywordKind = 0 /* Unknown */; @@ -10348,23 +10396,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(95 /* SuperKeyword */); + var node = createNode(96 /* SuperKeyword */); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97 /* ThisKeyword */, location); + var node = createNode(98 /* ThisKeyword */, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93 /* NullKeyword */); + var node = createNode(94 /* NullKeyword */); return node; } ts.createNull = createNull; // Names function createComputedPropertyName(expression, location) { - var node = createNode(140 /* ComputedPropertyName */, location); + var node = createNode(141 /* ComputedPropertyName */, location); node.expression = expression; return node; } @@ -10387,7 +10435,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142 /* Parameter */, location, flags); + var node = createNode(143 /* Parameter */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10407,7 +10455,7 @@ var ts; ts.updateParameterDeclaration = updateParameterDeclaration; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145 /* PropertyDeclaration */, location); + var node = createNode(146 /* PropertyDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10425,7 +10473,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147 /* MethodDeclaration */, location, flags); + var node = createNode(148 /* MethodDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10445,7 +10493,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148 /* Constructor */, location, flags); + var node = createNode(149 /* Constructor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10463,7 +10511,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149 /* GetAccessor */, location, flags); + var node = createNode(150 /* GetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10482,7 +10530,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150 /* SetAccessor */, location, flags); + var node = createNode(151 /* SetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10501,7 +10549,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(167 /* ObjectBindingPattern */, location); + var node = createNode(168 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10514,7 +10562,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168 /* ArrayBindingPattern */, location); + var node = createNode(169 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10527,7 +10575,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169 /* BindingElement */, location); + var node = createNode(170 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10544,7 +10592,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170 /* ArrayLiteralExpression */, location); + var node = createNode(171 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10560,7 +10608,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171 /* ObjectLiteralExpression */, location); + var node = createNode(172 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10576,7 +10624,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172 /* PropertyAccessExpression */, location, flags); + var node = createNode(173 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10594,7 +10642,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173 /* ElementAccessExpression */, location); + var node = createNode(174 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10608,7 +10656,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174 /* CallExpression */, location, flags); + var node = createNode(175 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10625,7 +10673,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* NewExpression */, location, flags); + var node = createNode(176 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10640,7 +10688,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176 /* TaggedTemplateExpression */, location); + var node = createNode(177 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10654,7 +10702,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178 /* ParenthesizedExpression */, location); + var node = createNode(179 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10666,9 +10714,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179 /* FunctionExpression */, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180 /* FunctionExpression */, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -10678,20 +10726,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180 /* ArrowFunction */, location, flags); + var node = createNode(181 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); node.body = parenthesizeConciseBody(body); return node; } @@ -10704,7 +10752,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181 /* DeleteExpression */, location); + var node = createNode(182 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10717,7 +10765,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182 /* TypeOfExpression */, location); + var node = createNode(183 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10730,7 +10778,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183 /* VoidExpression */, location); + var node = createNode(184 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10743,7 +10791,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184 /* AwaitExpression */, location); + var node = createNode(185 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10756,7 +10804,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185 /* PrefixUnaryExpression */, location); + var node = createNode(186 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10770,7 +10818,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186 /* PostfixUnaryExpression */, location); + var node = createNode(187 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10786,7 +10834,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187 /* BinaryExpression */, location); + var node = createNode(188 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10801,7 +10849,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188 /* ConditionalExpression */, location); + var node = createNode(189 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10818,7 +10866,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189 /* TemplateExpression */, location); + var node = createNode(190 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10832,7 +10880,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190 /* YieldExpression */, location); + var node = createNode(191 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10846,7 +10894,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191 /* SpreadElementExpression */, location); + var node = createNode(192 /* SpreadElementExpression */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10859,7 +10907,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192 /* ClassExpression */, location); + var node = createNode(193 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10877,12 +10925,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193 /* OmittedExpression */, location); + var node = createNode(194 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194 /* ExpressionWithTypeArguments */, location); + var node = createNode(195 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10897,7 +10945,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(197 /* TemplateSpan */, location); + var node = createNode(198 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -10912,7 +10960,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(199 /* Block */, location, flags); + var block = createNode(200 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10928,7 +10976,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200 /* VariableStatement */, location, flags); + var node = createNode(201 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10943,7 +10991,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219 /* VariableDeclarationList */, location, flags); + var node = createNode(220 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10956,7 +11004,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218 /* VariableDeclaration */, location, flags); + var node = createNode(219 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10971,11 +11019,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201 /* EmptyStatement */, location); + return createNode(202 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202 /* ExpressionStatement */, location, flags); + var node = createNode(203 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10988,7 +11036,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203 /* IfStatement */, location); + var node = createNode(204 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11003,7 +11051,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204 /* DoStatement */, location); + var node = createNode(205 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11017,7 +11065,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205 /* WhileStatement */, location); + var node = createNode(206 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11031,7 +11079,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11047,7 +11095,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207 /* ForInStatement */, location); + var node = createNode(208 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11062,7 +11110,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208 /* ForOfStatement */, location); + var node = createNode(209 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11077,7 +11125,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209 /* ContinueStatement */, location); + var node = createNode(210 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11092,7 +11140,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210 /* BreakStatement */, location); + var node = createNode(211 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11107,7 +11155,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211 /* ReturnStatement */, location); + var node = createNode(212 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11120,7 +11168,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212 /* WithStatement */, location); + var node = createNode(213 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11134,7 +11182,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213 /* SwitchStatement */, location); + var node = createNode(214 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11148,7 +11196,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214 /* LabeledStatement */, location); + var node = createNode(215 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11162,7 +11210,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215 /* ThrowStatement */, location); + var node = createNode(216 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11175,7 +11223,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216 /* TryStatement */, location); + var node = createNode(217 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11190,7 +11238,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227 /* CaseBlock */, location); + var node = createNode(228 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11203,7 +11251,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220 /* FunctionDeclaration */, location, flags); + var node = createNode(221 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11223,7 +11271,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221 /* ClassDeclaration */, location); + var node = createNode(222 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11241,7 +11289,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230 /* ImportDeclaration */, location); + var node = createNode(231 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11257,7 +11305,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231 /* ImportClause */, location); + var node = createNode(232 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11271,7 +11319,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232 /* NamespaceImport */, location); + var node = createNode(233 /* NamespaceImport */, location); node.name = name; return node; } @@ -11284,7 +11332,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233 /* NamedImports */, location); + var node = createNode(234 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11297,7 +11345,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234 /* ImportSpecifier */, location); + var node = createNode(235 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11311,7 +11359,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235 /* ExportAssignment */, location); + var node = createNode(236 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11327,7 +11375,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236 /* ExportDeclaration */, location); + var node = createNode(237 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11343,7 +11391,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237 /* NamedExports */, location); + var node = createNode(238 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11356,7 +11404,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238 /* ExportSpecifier */, location); + var node = createNode(239 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11371,7 +11419,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241 /* JsxElement */, location); + var node = createNode(242 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11386,7 +11434,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242 /* JsxSelfClosingElement */, location); + var node = createNode(243 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11400,7 +11448,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243 /* JsxOpeningElement */, location); + var node = createNode(244 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11653,47 +11701,47 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; // Compound nodes function createComma(left, right) { - return createBinary(left, 24 /* CommaToken */, right); + return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25 /* LessThanToken */, right, location); + return createBinary(left, 26 /* LessThanToken */, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56 /* EqualsToken */, right, location); + return createBinary(left, 57 /* EqualsToken */, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 33 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 34 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35 /* PlusToken */, right); + return createBinary(left, 36 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36 /* MinusToken */, right); + return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41 /* PlusPlusToken */, location); + return createPostfix(operand, 42 /* PlusPlusToken */, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51 /* AmpersandAmpersandToken */, right); + return createBinary(left, 52 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52 /* BarBarToken */, right); + return createBinary(left, 53 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49 /* ExclamationToken */, operand); + return createPrefix(50 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -11714,7 +11762,7 @@ var ts; function createRestParameter(name) { return createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createToken(22 /* DotDotDotToken */), name, + /*modifiers*/ undefined, createToken(23 /* DotDotDotToken */), name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -11844,7 +11892,8 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37 /* AsteriskToken */), + var generatorFunc = createFunctionExpression( + /*modifiers*/ undefined, createToken(38 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -11935,6 +11984,7 @@ var ts; /*modifiers*/ undefined, createConstDeclarationList([ createVariableDeclaration("_super", /*type*/ undefined, createCall(createParen(createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ @@ -11963,19 +12013,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return cacheIdentifiers; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -11989,13 +12039,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95 /* SuperKeyword */) { + else if (callee.kind === 96 /* SuperKeyword */) { thisArg = createThis(); - target = languageVersion < 2 /* ES6 */ ? createIdentifier("_super", /*location*/ callee) : callee; + target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; } else { switch (callee.kind) { - case 172 /* PropertyAccessExpression */: { + case 173 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12009,7 +12059,7 @@ var ts; } break; } - case 173 /* ElementAccessExpression */: { + case 174 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12063,14 +12113,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); case 254 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12080,7 +12130,7 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression( + var getterFunction = createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, @@ -12091,7 +12141,7 @@ var ts; properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression( + var setterFunction = createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, @@ -12125,7 +12175,7 @@ var ts; /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, /*type*/ undefined, method.body, @@ -12150,7 +12200,7 @@ var ts; * @param visitor: Optional callback used to visit any custom prologue directives. */ function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -12163,16 +12213,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -12219,7 +12273,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 178 /* ParenthesizedExpression */) { + if (skipped.kind === 179 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12253,8 +12307,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12263,7 +12317,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 190 /* YieldExpression */) { + && operand.kind === 191 /* YieldExpression */) { return false; } return true; @@ -12300,7 +12354,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 35 /* PlusToken */) { + if (binaryOperator === 36 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12335,10 +12389,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 37 /* AsteriskToken */ - || binaryOperator === 47 /* BarToken */ - || binaryOperator === 46 /* AmpersandToken */ - || binaryOperator === 48 /* CaretToken */; + return binaryOperator === 38 /* AsteriskToken */ + || binaryOperator === 48 /* BarToken */ + || binaryOperator === 47 /* AmpersandToken */ + || binaryOperator === 49 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -12351,7 +12405,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 35 /* PlusToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12374,9 +12428,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return createParen(expression); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12401,7 +12455,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12439,7 +12493,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, 24 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12450,7 +12504,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 /* FunctionExpression */ || kind === 180 /* ArrowFunction */) { + if (kind === 180 /* FunctionExpression */ || kind === 181 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12458,7 +12512,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 /* ObjectLiteralExpression */ || leftmostExpressionKind === 179 /* FunctionExpression */) { + if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12482,18 +12536,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: node = node.operand; continue; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: node = node.left; continue; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: node = node.condition; continue; - case 174 /* CallExpression */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: node = node.expression; continue; case 288 /* PartiallyEmittedExpression */: @@ -12505,7 +12559,7 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { return createParen(body, /*location*/ body); } return body; @@ -12537,7 +12591,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */) { + while (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12771,10 +12825,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 231 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12845,10 +12899,10 @@ var ts; if (kind === 256 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69 /* Identifier */) { + else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139 /* FirstNode */) { + else if (kind < 140 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12891,10 +12945,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -12905,12 +12959,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12919,24 +12973,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12947,176 +13001,176 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 161 /* TupleType */: + case 162 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return visitNode(cbNode, node.literal); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195 /* AsExpression */: + case 196 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); case 256 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return visitNode(cbNode, node.label); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); case 249 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143 /* Decorator */: + case 144 /* Decorator */: return visitNode(cbNode, node.expression); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: 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 222 /* InterfaceDeclaration */: + case 223 /* 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 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13124,65 +13178,65 @@ var ts; case 255 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); case 251 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246 /* JsxAttribute */: @@ -13303,7 +13357,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 32768 /* DisallowInContext */ | 131072 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; @@ -13394,9 +13448,9 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -13406,7 +13460,7 @@ var ts; // .tsx and .jsx files are treated as jsx language variant. return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -13710,20 +13764,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 69 /* Identifier */) { + if (token() === 70 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 114 /* YieldKeyword */ && inYieldContext()) { + if (token() === 115 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 119 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 120 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 105 /* LastReservedWord */; + return token() > 106 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13766,22 +13820,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 16 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 17 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(23 /* SemicolonToken */); + return parseExpected(24 /* SemicolonToken */); } } // note: this function creates only node @@ -13790,8 +13844,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : - kind === 69 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13838,16 +13892,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69 /* Identifier */); + var node = createNode(70 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 69 /* Identifier */) { + if (token() !== 70 /* Identifier */) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13864,7 +13918,7 @@ var ts; if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token() === 19 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 20 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13882,13 +13936,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(140 /* ComputedPropertyName */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(141 /* ComputedPropertyName */); + parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -13902,21 +13956,21 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74 /* ConstKeyword */) { + if (token() === 75 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 81 /* EnumKeyword */; + return nextToken() === 82 /* EnumKeyword */; } - if (token() === 82 /* ExportKeyword */) { + if (token() === 83 /* ExportKeyword */) { nextToken(); - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 /* AsteriskToken */ && token() !== 116 /* AsKeyword */ && token() !== 15 /* OpenBraceToken */ && canFollowModifier(); + return token() !== 38 /* AsteriskToken */ && token() !== 117 /* AsKeyword */ && token() !== 16 /* OpenBraceToken */ && canFollowModifier(); } - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113 /* StaticKeyword */) { + if (token() === 114 /* StaticKeyword */) { nextToken(); return canFollowModifier(); } @@ -13926,16 +13980,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 /* OpenBracketToken */ - || token() === 15 /* OpenBraceToken */ - || token() === 37 /* AsteriskToken */ - || token() === 22 /* DotDotDotToken */ + return token() === 20 /* OpenBracketToken */ + || token() === 16 /* OpenBraceToken */ + || token() === 38 /* AsteriskToken */ + || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 /* ClassKeyword */ || token() === 87 /* FunctionKeyword */ || - (token() === 118 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 /* ClassKeyword */ || token() === 88 /* FunctionKeyword */ || + (token() === 119 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -13953,9 +14007,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -13963,19 +14017,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 23 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 19 /* OpenBracketToken */ || token() === 37 /* AsteriskToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13990,23 +14044,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token() === 24 /* CommaToken */ || isStartOfType(); + return token() === 25 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -14019,8 +14073,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15 /* OpenBraceToken */); - if (nextToken() === 16 /* CloseBraceToken */) { + ts.Debug.assert(token() === 16 /* OpenBraceToken */); + if (nextToken() === 17 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -14029,7 +14083,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; + return next === 25 /* CommaToken */ || next === 16 /* OpenBraceToken */ || next === 84 /* ExtendsKeyword */ || next === 107 /* ImplementsKeyword */; } return true; } @@ -14042,8 +14096,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 /* ImplementsKeyword */ || - token() === 83 /* ExtendsKeyword */) { + if (token() === 107 /* ImplementsKeyword */ || + token() === 84 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -14067,43 +14121,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 16 /* CloseBraceToken */ || token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 15 /* OpenBraceToken */ || token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 27 /* GreaterThanToken */ || token() === 17 /* OpenParenToken */ || token() === 15 /* OpenBraceToken */ || token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 23 /* SemicolonToken */; + return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 20 /* CloseBracketToken */; + return token() === 21 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 24 /* CommaToken */; + return token() !== 25 /* CommaToken */; case 20 /* HeritageClauses */: - return token() === 15 /* OpenBraceToken */ || token() === 16 /* CloseBraceToken */; + return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 27 /* GreaterThanToken */ || token() === 39 /* SlashToken */; + return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token() === 18 /* CloseParenToken */ || token() === 54 /* ColonToken */ || token() === 16 /* CloseBraceToken */; + return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token() === 27 /* GreaterThanToken */ || token() === 16 /* CloseBraceToken */; + return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token() === 20 /* CloseBracketToken */ || token() === 16 /* CloseBraceToken */; + return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -14121,7 +14175,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -14284,20 +14338,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148 /* Constructor */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 145 /* PropertyDeclaration */: - case 198 /* SemicolonClassElement */: + case 149 /* Constructor */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 199 /* SemicolonClassElement */: return true; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 70 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 122 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -14316,35 +14370,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 200 /* VariableStatement */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 202 /* ExpressionStatement */: - case 215 /* ThrowStatement */: - case 211 /* ReturnStatement */: - case 213 /* SwitchStatement */: - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 201 /* EmptyStatement */: - case 216 /* TryStatement */: - case 214 /* LabeledStatement */: - case 204 /* DoStatement */: - case 217 /* DebuggerStatement */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 201 /* VariableStatement */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 203 /* ExpressionStatement */: + case 216 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 214 /* SwitchStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 202 /* EmptyStatement */: + case 217 /* TryStatement */: + case 215 /* LabeledStatement */: + case 205 /* DoStatement */: + case 218 /* DebuggerStatement */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: return true; } } @@ -14356,18 +14410,18 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152 /* ConstructSignature */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 144 /* PropertySignature */: - case 151 /* CallSignature */: + case 153 /* ConstructSignature */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 145 /* PropertySignature */: + case 152 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218 /* VariableDeclaration */) { + if (node.kind !== 219 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14388,7 +14442,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142 /* Parameter */) { + if (node.kind !== 143 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -14445,7 +14499,7 @@ var ts; if (isListElement(kind, /*inErrorRecovery*/ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -14454,13 +14508,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(24 /* CommaToken */); + parseExpected(25 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 24 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -14499,8 +14553,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21 /* DotToken */)) { - var node = createNode(139 /* QualifiedName */, entity.pos); // !!! + while (parseOptional(22 /* DotToken */)) { + var node = createNode(140 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14533,33 +14587,33 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189 /* TemplateExpression */); + var template = createNode(190 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197 /* TemplateSpan */); + var span = createNode(198 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16 /* CloseBraceToken */) { + if (token() === 17 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); + literal = parseExpectedToken(15 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(17 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -14569,12 +14623,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 13 /* TemplateMiddle */ || fragment.kind === 14 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 /* TemplateMiddle */ || fragment.kind === 15 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -14606,35 +14660,35 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(155 /* TypeReference */, typeName.pos); + var node = createNode(156 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154 /* TypePredicate */, lhs.pos); + var node = createNode(155 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165 /* ThisType */); + var node = createNode(166 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158 /* TypeQuery */); - parseExpected(101 /* TypeOfKeyword */); + var node = createNode(159 /* TypeQuery */); + parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141 /* TypeParameter */); + var node = createNode(142 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(83 /* ExtendsKeyword */)) { + if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -14656,29 +14710,29 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(54 /* ColonToken */)) { + if (parseOptional(55 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 /* AtToken */ || token() === 97 /* ThisKeyword */; + return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(142 /* Parameter */); - if (token() === 97 /* ThisKeyword */) { + var node = createNode(143 /* Parameter */); + if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -14693,7 +14747,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(53 /* QuestionToken */); + node.questionToken = parseOptionalToken(54 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -14713,7 +14767,7 @@ var ts; return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 35 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -14738,7 +14792,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(17 /* OpenParenToken */)) { + if (parseExpected(18 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -14746,7 +14800,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(19 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -14761,7 +14815,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -14769,15 +14823,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152 /* ConstructSignature */) { - parseExpected(92 /* NewKeyword */); + if (kind === 153 /* ConstructSignature */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19 /* OpenBracketToken */) { + if (token() !== 20 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -14800,7 +14854,7 @@ var ts; // [] // nextToken(); - if (token() === 22 /* DotDotDotToken */ || token() === 20 /* CloseBracketToken */) { + if (token() === 23 /* DotDotDotToken */ || token() === 21 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -14819,49 +14873,49 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 53 /* QuestionToken */) { + if (token() !== 54 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || token() === 20 /* CloseBracketToken */; + return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153 /* IndexSignature */, fullStart); + var node = createNode(154 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - var method = createNode(146 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var method = createNode(147 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144 /* PropertySignature */, fullStart); + var property = createNode(145 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -14874,7 +14928,7 @@ var ts; function isTypeMemberStart() { var idToken; // Return true if we have the start of a signature member - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier @@ -14883,7 +14937,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -14894,21 +14948,21 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 17 /* OpenParenToken */ || - token() === 25 /* LessThanToken */ || - token() === 53 /* QuestionToken */ || - token() === 54 /* ColonToken */ || - token() === 24 /* CommaToken */ || + return token() === 18 /* OpenParenToken */ || + token() === 26 /* LessThanToken */ || + token() === 54 /* QuestionToken */ || + token() === 55 /* ColonToken */ || + token() === 25 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - return parseSignatureMember(151 /* CallSignature */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + return parseSignatureMember(152 /* CallSignature */); } - if (token() === 92 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(152 /* ConstructSignature */); + if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14919,18 +14973,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */; + return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(159 /* TypeLiteral */); + var node = createNode(160 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { members = createMissingList(); @@ -14938,31 +14992,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + var node = createNode(162 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164 /* ParenthesizedType */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(165 /* ParenthesizedType */); + parseExpected(18 /* OpenParenToken */); node.type = parseType(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157 /* ConstructorType */) { - parseExpected(92 /* NewKeyword */); + if (kind === 158 /* ConstructorType */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 /* DotToken */ ? undefined : node; + return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166 /* LiteralType */); + var node = createNode(167 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14972,42 +15026,42 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseLiteralTypeNode(); - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: return parseTokenNode(); - case 97 /* ThisKeyword */: { + case 98 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeQuery(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseTypeLiteral(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseTupleType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReference(); @@ -15015,29 +15069,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 97 /* ThisKeyword */: - case 101 /* TypeOfKeyword */: - case 127 /* NeverKeyword */: - case 15 /* OpenBraceToken */: - case 19 /* OpenBracketToken */: - case 25 /* LessThanToken */: - case 92 /* NewKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 98 /* ThisKeyword */: + case 102 /* TypeOfKeyword */: + case 128 /* NeverKeyword */: + case 16 /* OpenBraceToken */: + case 20 /* OpenBracketToken */: + case 26 /* LessThanToken */: + case 93 /* NewKeyword */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return true; - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -15047,13 +15101,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token() === 19 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { - parseExpected(20 /* CloseBracketToken */); - var node = createNode(160 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { + parseExpected(21 /* CloseBracketToken */); + var node = createNode(161 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -15074,27 +15128,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(164 /* IntersectionType */, parseArrayTypeOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(163 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { return true; } - return token() === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 97 /* ThisKeyword */) { + if (isIdentifier() || token() === 98 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 19 /* OpenBracketToken */ || token() === 15 /* OpenBraceToken */) { + if (token() === 20 /* OpenBracketToken */ || token() === 16 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -15104,7 +15158,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 /* CloseParenToken */ || token() === 22 /* DotDotDotToken */) { + if (token() === 19 /* CloseParenToken */ || token() === 23 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -15112,17 +15166,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || - token() === 53 /* QuestionToken */ || token() === 56 /* EqualsToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || + token() === 54 /* QuestionToken */ || token() === 57 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 18 /* CloseParenToken */) { + if (token() === 19 /* CloseParenToken */) { nextToken(); - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -15134,7 +15188,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(155 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15145,7 +15199,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -15157,37 +15211,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156 /* FunctionType */); + return parseFunctionOrConstructorType(157 /* FunctionType */); } - if (token() === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(157 /* ConstructorType */); + if (token() === 93 /* NewKeyword */) { + return parseFunctionOrConstructorType(158 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54 /* ColonToken */) ? parseType() : undefined; + return parseOptional(55 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 92 /* NewKeyword */: - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - case 69 /* Identifier */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 93 /* NewKeyword */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 70 /* Identifier */: return true; default: return isIdentifier(); @@ -15198,18 +15252,18 @@ var ts; return true; } switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: - case 25 /* LessThanToken */: - case 119 /* AwaitKeyword */: - case 114 /* YieldKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: + case 26 /* LessThanToken */: + case 120 /* AwaitKeyword */: + case 115 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -15227,10 +15281,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 15 /* OpenBraceToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && - token() !== 55 /* AtToken */ && + return token() !== 16 /* OpenBraceToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && + token() !== 56 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -15244,7 +15298,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(25 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -15253,7 +15307,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56 /* EqualsToken */) { + if (token() !== 57 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -15262,7 +15316,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -15270,7 +15324,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -15316,7 +15370,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -15332,7 +15386,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114 /* YieldKeyword */) { + if (token() === 115 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -15361,15 +15415,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190 /* YieldExpression */); + var node = createNode(191 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + (token() === 38 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15380,21 +15434,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180 /* ArrowFunction */, asyncModifier.pos); + node = createNode(181 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180 /* ArrowFunction */, identifier.pos); + node = createNode(181 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(142 /* Parameter */, identifier.pos); + var parameter = createNode(143 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -15419,8 +15473,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 /* EqualsGreaterThanToken */ || lastToken === 16 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); @@ -15430,10 +15484,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */ || token() === 118 /* AsyncKeyword */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */ || token() === 119 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -15443,28 +15497,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 17 /* OpenParenToken */ && token() !== 25 /* LessThanToken */) { + if (token() !== 18 /* OpenParenToken */ && token() !== 26 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 17 /* OpenParenToken */) { - if (second === 18 /* CloseParenToken */) { + if (first === 18 /* OpenParenToken */) { + if (second === 19 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 34 /* EqualsGreaterThanToken */: - case 54 /* ColonToken */: - case 15 /* OpenBraceToken */: + case 35 /* EqualsGreaterThanToken */: + case 55 /* ColonToken */: + case 16 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -15476,12 +15530,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { + if (second === 20 /* OpenBracketToken */ || second === 16 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 22 /* DotDotDotToken */) { + if (second === 23 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -15494,7 +15548,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 54 /* ColonToken */) { + if (nextToken() === 55 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -15502,7 +15556,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 25 /* LessThanToken */); + ts.Debug.assert(first === 26 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -15512,17 +15566,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83 /* ExtendsKeyword */) { + if (third === 84 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 56 /* EqualsToken */: - case 27 /* GreaterThanToken */: + case 57 /* EqualsToken */: + case 28 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 24 /* CommaToken */) { + else if (third === 25 /* CommaToken */) { return true; } return false; @@ -15541,7 +15595,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); @@ -15555,23 +15609,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a begining of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 34 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 35 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180 /* ArrowFunction */); + var node = createNode(181 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15581,7 +15635,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -15594,19 +15648,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 34 /* EqualsGreaterThanToken */ && token() !== 15 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 35 /* EqualsGreaterThanToken */ && token() !== 16 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token() !== 23 /* SemicolonToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && + if (token() !== 24 /* SemicolonToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -15631,17 +15685,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(53 /* QuestionToken */); + var questionToken = parseOptionalToken(54 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(188 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(189 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); + node.colonToken = parseExpectedToken(55 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(55 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15650,7 +15704,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 138 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 139 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15679,16 +15733,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 38 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 39 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 /* InKeyword */ && inDisallowInContext()) { + if (token() === 91 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -15709,48 +15763,48 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90 /* InKeyword */) { + if (inDisallowInContext() && token() === 91 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 1; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 2; - case 47 /* BarToken */: + case 48 /* BarToken */: return 3; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 4; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 5; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 6; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: return 7; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 9; - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 10; - case 38 /* AsteriskAsteriskToken */: + case 39 /* AsteriskAsteriskToken */: return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -15758,45 +15812,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187 /* BinaryExpression */, left.pos); + var node = createNode(188 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195 /* AsExpression */, left.pos); + var node = createNode(196 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185 /* PrefixUnaryExpression */); + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181 /* DeleteExpression */); + var node = createNode(182 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(182 /* TypeOfExpression */); + var node = createNode(183 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(183 /* VoidExpression */); + var node = createNode(184 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 119 /* AwaitKeyword */) { + if (token() === 120 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -15806,7 +15860,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184 /* AwaitExpression */); + var node = createNode(185 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15830,7 +15884,7 @@ var ts; */ if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 /* AsteriskAsteriskToken */ ? + return token() === 39 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } @@ -15847,9 +15901,9 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38 /* AsteriskAsteriskToken */) { + if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 178 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -15874,23 +15928,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 78 /* DeleteKeyword */: + case 79 /* DeleteKeyword */: return parseDeleteExpression(); - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return parseVoidExpression(); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 119 /* AwaitKeyword */: + case 120 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -15912,16 +15966,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - case 119 /* AwaitKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 120 /* AwaitKeyword */: return false; - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -15944,21 +15998,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseIncrementExpression() { - if (token() === 41 /* PlusPlusToken */ || token() === 42 /* MinusMinusToken */) { - var node = createNode(185 /* PrefixUnaryExpression */); + if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 /* PlusPlusToken */ || token() === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15997,7 +16051,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token() === 95 /* SuperKeyword */ + var expression = token() === 96 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -16057,14 +16111,14 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 /* OpenParenToken */ || token() === 21 /* DotToken */ || token() === 19 /* OpenBracketToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 22 /* DotToken */ || token() === 20 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(172 /* PropertyAccessExpression */, expression.pos); + var node = createNode(173 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } @@ -16072,10 +16126,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69 /* Identifier */) { + if (lhs.kind === 70 /* Identifier */) { return lhs.text === rhs.text; } - if (lhs.kind === 97 /* ThisKeyword */) { + if (lhs.kind === 98 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -16087,8 +16141,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243 /* JsxOpeningElement */) { - var node = createNode(241 /* JsxElement */, opening.pos); + if (opening.kind === 244 /* JsxOpeningElement */) { + var node = createNode(242 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16098,7 +16152,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16109,15 +16163,15 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 25 /* LessThanToken */) { + if (inExpressionContext && token() === 26 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187 /* BinaryExpression */, result.pos); + var badNode = createNode(188 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(25 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -16125,17 +16179,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244 /* JsxText */, scanner.getStartPos()); + var node = createNode(10 /* JsxText */, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244 /* JsxText */: + case 10 /* JsxText */: return parseJsxText(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -16146,7 +16200,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26 /* LessThanSlashToken */) { + if (token() === 27 /* LessThanSlashToken */) { // Closing tag break; } @@ -16164,27 +16218,27 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25 /* LessThanToken */); + parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (token() === 27 /* GreaterThanToken */) { + if (token() === 28 /* GreaterThanToken */) { // 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(243 /* JsxOpeningElement */, fullStart); + node = createNode(244 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(39 /* SlashToken */); + parseExpected(40 /* SlashToken */); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(242 /* JsxSelfClosingElement */, fullStart); + node = createNode(243 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16197,10 +16251,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 97 /* ThisKeyword */ ? + var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21 /* DotToken */)) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(22 /* DotToken */)) { + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16209,27 +16263,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248 /* JsxExpression */); - parseExpected(15 /* OpenBraceToken */); - if (token() !== 16 /* CloseBraceToken */) { + parseExpected(16 /* OpenBraceToken */); + if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { - parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(17 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -16243,71 +16297,71 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247 /* JsxSpreadAttribute */); - parseExpected(15 /* OpenBraceToken */); - parseExpected(22 /* DotDotDotToken */); + parseExpected(16 /* OpenBraceToken */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245 /* JsxClosingElement */); - parseExpected(26 /* LessThanSlashToken */); + parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177 /* TypeAssertionExpression */); - parseExpected(25 /* LessThanToken */); + var node = createNode(178 /* TypeAssertionExpression */); + parseExpected(26 /* LessThanToken */); node.type = parseType(); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21 /* DotToken */); + var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(19 /* OpenBracketToken */)) { - var indexedAccess = createNode(173 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { + var indexedAccess = createNode(174 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token() !== 20 /* CloseBracketToken */) { + if (token() !== 21 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token() === 11 /* NoSubstitutionTemplateLiteral */ || token() === 12 /* TemplateHead */) { - var tagExpression = createNode(176 /* TaggedTemplateExpression */, expression.pos); + if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { + var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -16319,7 +16373,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -16328,15 +16382,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(174 /* CallExpression */, expression.pos); + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17 /* OpenParenToken */) { - var callExpr = createNode(174 /* CallExpression */, expression.pos); + else if (token() === 18 /* OpenParenToken */) { + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16346,17 +16400,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25 /* LessThanToken */)) { + if (!parseOptional(26 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(27 /* GreaterThanToken */)) { + if (!parseExpected(28 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -16368,32 +16422,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17 /* OpenParenToken */: // foo( + case 18 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 21 /* DotToken */: // foo. - case 18 /* CloseParenToken */: // foo) - case 20 /* CloseBracketToken */: // foo] - case 54 /* ColonToken */: // foo: - case 23 /* SemicolonToken */: // foo; - case 53 /* QuestionToken */: // foo? - case 30 /* EqualsEqualsToken */: // foo == - case 32 /* EqualsEqualsEqualsToken */: // foo === - case 31 /* ExclamationEqualsToken */: // foo != - case 33 /* ExclamationEqualsEqualsToken */: // foo !== - case 51 /* AmpersandAmpersandToken */: // foo && - case 52 /* BarBarToken */: // foo || - case 48 /* CaretToken */: // foo ^ - case 46 /* AmpersandToken */: // foo & - case 47 /* BarToken */: // foo | - case 16 /* CloseBraceToken */: // foo } + case 22 /* DotToken */: // foo. + case 19 /* CloseParenToken */: // foo) + case 21 /* CloseBracketToken */: // foo] + case 55 /* ColonToken */: // foo: + case 24 /* SemicolonToken */: // foo; + case 54 /* QuestionToken */: // foo? + case 31 /* EqualsEqualsToken */: // foo == + case 33 /* EqualsEqualsEqualsToken */: // foo === + case 32 /* ExclamationEqualsToken */: // foo != + case 34 /* ExclamationEqualsEqualsToken */: // foo !== + case 52 /* AmpersandAmpersandToken */: // foo && + case 53 /* BarBarToken */: // foo || + case 49 /* CaretToken */: // foo ^ + case 47 /* AmpersandToken */: // foo & + case 48 /* BarToken */: // foo | + case 17 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 24 /* CommaToken */: // foo, - case 15 /* OpenBraceToken */: // foo { + case 25 /* CommaToken */: // foo, + case 16 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -16406,21 +16460,21 @@ var ts; switch (token()) { case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseTokenNode(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedExpression(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 118 /* AsyncKeyword */: + case 119 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -16428,60 +16482,60 @@ var ts; break; } return parseFunctionExpression(); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassExpression(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionExpression(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseNewExpression(); - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + if (reScanSlashToken() === 11 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178 /* ParenthesizedExpression */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(179 /* ParenthesizedExpression */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191 /* SpreadElementExpression */); - parseExpected(22 /* DotDotDotToken */); + var node = createNode(192 /* SpreadElementExpression */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 24 /* CommaToken */ ? createNode(193 /* OmittedExpression */) : + return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 25 /* CommaToken */ ? createNode(194 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170 /* ArrayLiteralExpression */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(171 /* ArrayLiteralExpression */); + parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(149 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(124 /* GetKeyword */)) { + return parseAccessorDeclaration(150 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(131 /* SetKeyword */)) { - return parseAccessorDeclaration(150 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(132 /* SetKeyword */)) { + return parseAccessorDeclaration(151 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -16493,12 +16547,12 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // check if it is short-hand property assignment or normal property assignment @@ -16506,12 +16560,12 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 /* CommaToken */ || token() === 16 /* CloseBraceToken */ || token() === 56 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56 /* EqualsToken */); + var equalsToken = parseOptionalToken(57 /* EqualsToken */); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -16523,19 +16577,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171 /* ObjectLiteralExpression */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(172 /* ObjectLiteralExpression */); + parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -16548,10 +16602,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(179 /* FunctionExpression */); + var node = createNode(180 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); node.name = @@ -16559,7 +16613,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -16570,24 +16624,24 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175 /* NewExpression */); - parseExpected(92 /* NewKeyword */); + var node = createNode(176 /* NewExpression */); + parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17 /* OpenParenToken */) { + if (node.typeArguments || token() === 18 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199 /* Block */); - if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200 /* Block */); + if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -16614,51 +16668,51 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201 /* EmptyStatement */); - parseExpected(23 /* SemicolonToken */); + var node = createNode(202 /* EmptyStatement */); + parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(203 /* IfStatement */); - parseExpected(88 /* IfKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(204 /* IfStatement */); + parseExpected(89 /* IfKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204 /* DoStatement */); - parseExpected(79 /* DoKeyword */); + var node = createNode(205 /* DoStatement */); + parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(23 /* SemicolonToken */); + parseOptional(24 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205 /* WhileStatement */); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(206 /* WhileStatement */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86 /* ForKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(87 /* ForKeyword */); + parseExpected(18 /* OpenParenToken */); var initializer = undefined; - if (token() !== 23 /* SemicolonToken */) { - if (token() === 102 /* VarKeyword */ || token() === 108 /* LetKeyword */ || token() === 74 /* ConstKeyword */) { + if (token() !== 24 /* SemicolonToken */) { + if (token() === 103 /* VarKeyword */ || token() === 109 /* LetKeyword */ || token() === 75 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -16666,32 +16720,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(207 /* ForInStatement */, pos); + if (parseOptional(91 /* InKeyword */)) { + var forInStatement = createNode(208 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138 /* OfKeyword */)) { - var forOfStatement = createNode(208 /* ForOfStatement */, pos); + else if (parseOptional(139 /* OfKeyword */)) { + var forOfStatement = createNode(209 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206 /* ForStatement */, pos); + var forStatement = createNode(207 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(23 /* SemicolonToken */); - if (token() !== 23 /* SemicolonToken */ && token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23 /* SemicolonToken */); - if (token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 19 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -16699,7 +16753,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16707,8 +16761,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211 /* ReturnStatement */); - parseExpected(94 /* ReturnKeyword */); + var node = createNode(212 /* ReturnStatement */); + parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -16716,42 +16770,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212 /* WithStatement */); - parseExpected(105 /* WithKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(213 /* WithStatement */); + parseExpected(106 /* WithKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249 /* CaseClause */); - parseExpected(71 /* CaseKeyword */); + parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250 /* DefaultClause */); - parseExpected(77 /* DefaultKeyword */); - parseExpected(54 /* ColonToken */); + parseExpected(78 /* DefaultKeyword */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213 /* SwitchStatement */); - parseExpected(96 /* SwitchKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(214 /* SwitchStatement */); + parseExpected(97 /* SwitchKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(227 /* CaseBlock */, scanner.getStartPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(19 /* CloseParenToken */); + var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -16763,39 +16817,39 @@ 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(215 /* ThrowStatement */); - parseExpected(98 /* ThrowKeyword */); + var node = createNode(216 /* ThrowStatement */); + parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(216 /* TryStatement */); - parseExpected(100 /* TryKeyword */); + var node = createNode(217 /* TryStatement */); + parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 85 /* FinallyKeyword */) { - parseExpected(85 /* FinallyKeyword */); + if (!node.catchClause || token() === 86 /* FinallyKeyword */) { + parseExpected(86 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252 /* CatchClause */); - parseExpected(72 /* CatchKeyword */); - if (parseExpected(17 /* OpenParenToken */)) { + parseExpected(73 /* CatchKeyword */); + if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217 /* DebuggerStatement */); - parseExpected(76 /* DebuggerKeyword */); + var node = createNode(218 /* DebuggerStatement */); + parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -16805,14 +16859,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(214 /* LabeledStatement */, fullStart); + if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { + var labeledStatement = createNode(215 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16824,7 +16878,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 88 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -16833,12 +16887,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -16861,41 +16915,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 107 /* InterfaceKeyword */: - case 134 /* TypeKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 128 /* ReadonlyKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 129 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137 /* GlobalKeyword */: + case 138 /* GlobalKeyword */: nextToken(); - return token() === 15 /* OpenBraceToken */ || token() === 69 /* Identifier */ || token() === 82 /* ExportKeyword */; - case 89 /* ImportKeyword */: + return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; + case 90 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 82 /* ExportKeyword */: + return token() === 9 /* StringLiteral */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 83 /* ExportKeyword */: nextToken(); - if (token() === 56 /* EqualsToken */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || token() === 77 /* DefaultKeyword */ || - token() === 116 /* AsKeyword */) { + if (token() === 57 /* EqualsToken */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || token() === 78 /* DefaultKeyword */ || + token() === 117 /* AsKeyword */) { return true; } continue; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: nextToken(); continue; default: @@ -16908,49 +16962,49 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55 /* AtToken */: - case 23 /* SemicolonToken */: - case 15 /* OpenBraceToken */: - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 88 /* IfKeyword */: - case 79 /* DoKeyword */: - case 104 /* WhileKeyword */: - case 86 /* ForKeyword */: - case 75 /* ContinueKeyword */: - case 70 /* BreakKeyword */: - case 94 /* ReturnKeyword */: - case 105 /* WithKeyword */: - case 96 /* SwitchKeyword */: - case 98 /* ThrowKeyword */: - case 100 /* TryKeyword */: - case 76 /* DebuggerKeyword */: + case 56 /* AtToken */: + case 24 /* SemicolonToken */: + case 16 /* OpenBraceToken */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 89 /* IfKeyword */: + case 80 /* DoKeyword */: + case 105 /* WhileKeyword */: + case 87 /* ForKeyword */: + case 76 /* ContinueKeyword */: + case 71 /* BreakKeyword */: + case 95 /* ReturnKeyword */: + case 106 /* WithKeyword */: + case 97 /* SwitchKeyword */: + case 99 /* ThrowKeyword */: + case 101 /* TryKeyword */: + case 77 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return true; - case 74 /* ConstKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: + case 75 /* ConstKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: return isStartOfDeclaration(); - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 107 /* InterfaceKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 134 /* TypeKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 108 /* InterfaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 135 /* TypeKeyword */: + case 138 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -16960,7 +17014,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */; + return isIdentifier() || token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -16969,67 +17023,67 @@ var ts; } function parseStatement() { switch (token()) { - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: return parseEmptyStatement(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 88 /* IfKeyword */: + case 89 /* IfKeyword */: return parseIfStatement(); - case 79 /* DoKeyword */: + case 80 /* DoKeyword */: return parseDoStatement(); - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return parseWhileStatement(); - case 86 /* ForKeyword */: + case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(209 /* ContinueStatement */); - case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(210 /* BreakStatement */); - case 94 /* ReturnKeyword */: + case 76 /* ContinueKeyword */: + return parseBreakOrContinueStatement(210 /* ContinueStatement */); + case 71 /* BreakKeyword */: + return parseBreakOrContinueStatement(211 /* BreakStatement */); + case 95 /* ReturnKeyword */: return parseReturnStatement(); - case 105 /* WithKeyword */: + case 106 /* WithKeyword */: return parseWithStatement(); - case 96 /* SwitchKeyword */: + case 97 /* SwitchKeyword */: return parseSwitchStatement(); - case 98 /* ThrowKeyword */: + case 99 /* ThrowKeyword */: return parseThrowStatement(); - case 100 /* TryKeyword */: + case 101 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return parseTryStatement(); - case 76 /* DebuggerKeyword */: + case 77 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 55 /* AtToken */: + case 56 /* AtToken */: return parseDeclaration(); - case 118 /* AsyncKeyword */: - case 107 /* InterfaceKeyword */: - case 134 /* TypeKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 122 /* DeclareKeyword */: - case 74 /* ConstKeyword */: - case 81 /* EnumKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 115 /* AbstractKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 82 /* EnumKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 116 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: + case 138 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17042,33 +17096,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107 /* InterfaceKeyword */: + case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134 /* TypeKeyword */: + case 135 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81 /* EnumKeyword */: + case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137 /* GlobalKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 138 /* GlobalKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89 /* ImportKeyword */: + case 90 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: nextToken(); switch (token()) { - case 77 /* DefaultKeyword */: - case 56 /* EqualsToken */: + case 78 /* DefaultKeyword */: + case 57 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); - case 116 /* AsKeyword */: + case 117 /* AsKeyword */: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); @@ -17077,7 +17131,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(239 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17090,7 +17144,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 16 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -17098,24 +17152,24 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 24 /* CommaToken */) { - return createNode(193 /* OmittedExpression */); + if (token() === 25 /* CommaToken */) { + return createNode(194 /* OmittedExpression */); } - var node = createNode(169 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + var node = createNode(170 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169 /* BindingElement */); + var node = createNode(170 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -17123,33 +17177,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167 /* ObjectBindingPattern */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(168 /* ObjectBindingPattern */); + parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168 /* ArrayBindingPattern */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(169 /* ArrayBindingPattern */); + parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */ || isIdentifier(); + return token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218 /* VariableDeclaration */); + var node = createNode(219 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17158,14 +17212,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219 /* VariableDeclarationList */); + var node = createNode(220 /* VariableDeclarationList */); switch (token()) { - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: break; - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 74 /* ConstKeyword */: + case 75 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -17181,7 +17235,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 138 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17193,10 +17247,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200 /* VariableStatement */, fullStart); + var node = createNode(201 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17204,29 +17258,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* FunctionDeclaration */, fullStart); + var node = createNode(221 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148 /* Constructor */, pos); + var node = createNode(149 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121 /* ConstructorKeyword */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(122 /* ConstructorKeyword */); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147 /* MethodDeclaration */, fullStart); + var method = createNode(148 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -17234,12 +17288,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145 /* PropertyDeclaration */, fullStart); + var property = createNode(146 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -17261,12 +17315,12 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -17281,17 +17335,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: return true; default: return false; @@ -17299,7 +17353,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -17316,7 +17370,7 @@ var ts; } nextToken(); } - if (token() === 37 /* AsteriskToken */) { + if (token() === 38 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -17326,23 +17380,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 131 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 132 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 17 /* OpenParenToken */: // Method declaration - case 25 /* LessThanToken */: // Generic Method declaration - case 54 /* ColonToken */: // Type Annotation for declaration - case 56 /* EqualsToken */: // Initializer for declaration - case 53 /* QuestionToken */: + case 18 /* OpenParenToken */: // Method declaration + case 26 /* LessThanToken */: // Generic Method declaration + case 55 /* ColonToken */: // Type Annotation for declaration + case 57 /* EqualsToken */: // Initializer for declaration + case 54 /* QuestionToken */: return true; default: // Covers @@ -17359,10 +17413,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55 /* AtToken */)) { + if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(143 /* Decorator */, decoratorStart); + var decorator = createNode(144 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17389,7 +17443,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 75 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -17416,7 +17470,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -17427,8 +17481,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23 /* SemicolonToken */) { - var result = createNode(198 /* SemicolonClassElement */); + if (token() === 24 /* SemicolonToken */) { + var result = createNode(199 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17439,7 +17493,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121 /* ConstructorKeyword */) { + if (token() === 122 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -17450,13 +17504,13 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 37 /* AsteriskToken */ || - token() === 19 /* OpenBracketToken */) { + token() === 38 /* AsteriskToken */ || + token() === 20 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_10 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_10 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -17466,24 +17520,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 192 /* ClassExpression */); + /*modifiers*/ undefined, 193 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73 /* ClassKeyword */); + parseExpected(74 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); - if (parseExpected(15 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17501,9 +17555,9 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { @@ -17512,7 +17566,7 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */) { + if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { var node = createNode(251 /* HeritageClause */); node.token = token(); nextToken(); @@ -17522,38 +17576,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194 /* ExpressionWithTypeArguments */); + var node = createNode(195 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222 /* InterfaceDeclaration */, fullStart); + var node = createNode(223 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107 /* InterfaceKeyword */); + parseExpected(108 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* TypeAliasDeclaration */, fullStart); + var node = createNode(224 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134 /* TypeKeyword */); + parseExpected(135 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -17569,14 +17623,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* EnumDeclaration */, fullStart); + var node = createNode(225 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81 /* EnumKeyword */); + parseExpected(82 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17584,10 +17638,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(15 /* OpenBraceToken */)) { + var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -17595,7 +17649,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* 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 */; @@ -17603,16 +17657,16 @@ var ts; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21 /* DotToken */) + node.body = parseOptional(22 /* DotToken */) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -17620,7 +17674,7 @@ var ts; else { node.name = parseLiteralNode(/*internName*/ true); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -17630,15 +17684,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126 /* NamespaceKeyword */)) { + else if (parseOptional(127 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(125 /* ModuleKeyword */); + parseExpected(126 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -17646,57 +17700,57 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 /* RequireKeyword */ && + return token() === 130 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17 /* OpenParenToken */; + return nextToken() === 18 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 39 /* SlashToken */; + return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116 /* AsKeyword */); - parseExpected(126 /* NamespaceKeyword */); + parseExpected(117 /* AsKeyword */); + parseExpected(127 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); - parseExpected(23 /* SemicolonToken */); + parseExpected(24 /* SemicolonToken */); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89 /* ImportKeyword */); + parseExpected(90 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 /* CommaToken */ && token() !== 136 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 137 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(229 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(230 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } // Import statement - var importDeclaration = createNode(230 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */) { + token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136 /* FromKeyword */); + parseExpected(137 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17709,7 +17763,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(231 /* ImportClause */, fullStart); + var importClause = createNode(232 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17718,8 +17772,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token() === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(233 /* NamedImports */); + parseOptional(25 /* CommaToken */)) { + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(234 /* NamedImports */); } return finishNode(importClause); } @@ -17729,11 +17783,11 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(240 /* ExternalModuleReference */); - parseExpected(129 /* RequireKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(241 /* ExternalModuleReference */); + parseExpected(130 /* RequireKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -17752,9 +17806,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(232 /* NamespaceImport */); - parseExpected(37 /* AsteriskToken */); - parseExpected(116 /* AsKeyword */); + var namespaceImport = createNode(233 /* NamespaceImport */); + parseExpected(38 /* AsteriskToken */); + parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -17767,14 +17821,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 233 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 234 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238 /* ExportSpecifier */); + return parseImportOrExportSpecifier(239 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234 /* ImportSpecifier */); + return parseImportOrExportSpecifier(235 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17788,9 +17842,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(116 /* AsKeyword */); + parseExpected(117 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -17799,27 +17853,27 @@ var ts; else { node.name = identifierName; } - if (kind === 234 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 235 /* 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(236 /* ExportDeclaration */, fullStart); + var node = createNode(237 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(136 /* FromKeyword */); + if (parseOptional(38 /* AsteriskToken */)) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(238 /* 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. - if (token() === 136 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(136 /* FromKeyword */); + if (token() === 137 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17827,14 +17881,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235 /* ExportAssignment */, fullStart); + var node = createNode(236 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(77 /* DefaultKeyword */); + parseExpected(78 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -17909,10 +17963,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */ - || node.kind === 230 /* ImportDeclaration */ - || node.kind === 235 /* ExportAssignment */ - || node.kind === 236 /* ExportDeclaration */ + || node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */ + || node.kind === 231 /* ImportDeclaration */ + || node.kind === 236 /* ExportAssignment */ + || node.kind === 237 /* ExportDeclaration */ ? node : undefined; }); @@ -17957,24 +18011,24 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37 /* AsteriskToken */: - case 53 /* QuestionToken */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 49 /* ExclamationToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 22 /* DotDotDotToken */: - case 92 /* NewKeyword */: - case 97 /* ThisKeyword */: + case 38 /* AsteriskToken */: + case 54 /* QuestionToken */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 50 /* ExclamationToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 23 /* DotDotDotToken */: + case 93 /* NewKeyword */: + case 98 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = createSourceFile("file.js", 2 /* Latest */, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = createSourceFile("file.js", 4 /* Latest */, 1 /* JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -17987,21 +18041,21 @@ var ts; /* @internal */ function parseJSDocTypeExpression() { var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47 /* BarToken */) { + if (token() === 48 /* BarToken */) { var unionType = createNode(261 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; @@ -18012,20 +18066,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { var arrayType = createNode(260 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token() === 53 /* QuestionToken */) { + else if (token() === 54 /* QuestionToken */) { var nullableType = createNode(263 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49 /* ExclamationToken */) { + else if (token() === 50 /* ExclamationToken */) { var nonNullableType = createNode(264 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); @@ -18039,40 +18093,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: return parseJSDocAllType(); - case 53 /* QuestionToken */: + case 54 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseJSDocUnionType(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseJSDocTupleType(); - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJSDocRecordType(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 22 /* DotDotDotToken */: + case 23 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseJSDocConstructorType(); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return parseJSDocThisType(); - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -18080,14 +18134,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272 /* JSDocThisType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271 /* JSDocConstructorType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } @@ -18100,34 +18154,34 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269 /* JSDocFunctionType */); nextToken(); - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18 /* CloseParenToken */); - if (token() === 54 /* ColonToken */) { + parseExpected(19 /* CloseParenToken */); + if (token() === 55 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142 /* Parameter */); + var parameter = createNode(143 /* Parameter */); parameter.type = parseJSDocType(); - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? - parameter.questionToken = createNode(56 /* EqualsToken */); + parameter.questionToken = createNode(57 /* EqualsToken */); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21 /* DotToken */)) { - if (token() === 25 /* LessThanToken */) { + while (parseOptional(22 /* DotToken */)) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -18144,7 +18198,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -18155,7 +18209,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139 /* QualifiedName */, left.pos); + var result = createNode(140 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -18176,7 +18230,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -18189,13 +18243,13 @@ var ts; var result = createNode(261 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47 /* BarToken */)) { + while (parseOptional(48 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -18224,12 +18278,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 24 /* CommaToken */ || - token() === 16 /* CloseBraceToken */ || - token() === 18 /* CloseParenToken */ || - token() === 27 /* GreaterThanToken */ || - token() === 56 /* EqualsToken */ || - token() === 47 /* BarToken */) { + if (token() === 25 /* CommaToken */ || + token() === 17 /* CloseBraceToken */ || + token() === 19 /* CloseParenToken */ || + token() === 28 /* GreaterThanToken */ || + token() === 57 /* EqualsToken */ || + token() === 48 /* BarToken */) { var result = createNode(259 /* JSDocUnknownType */, pos); return finishNode(result); } @@ -18240,7 +18294,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); sourceFile = { languageVariant: 0 /* Standard */, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -18309,7 +18363,7 @@ var ts; } while (token() !== 1 /* EndOfFileToken */) { switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); parseTag(indent); @@ -18330,7 +18384,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -18343,7 +18397,7 @@ var ts; indent += asterisk.length; } break; - case 69 /* Identifier */: + case 70 /* Identifier */: // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. @@ -18404,8 +18458,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getTokenPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18457,7 +18511,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 56 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { switch (token()) { case 4 /* NewLineTrivia */: if (state >= 1 /* SawAsterisk */) { @@ -18466,7 +18520,7 @@ var ts; } indent = 0; break; - case 55 /* AtToken */: + case 56 /* AtToken */: // Done break; case 5 /* WhitespaceTrivia */: @@ -18482,7 +18536,7 @@ var ts; indent += whitespace.length; } break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -18495,7 +18549,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { // Done break; } @@ -18524,7 +18578,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15 /* OpenBraceToken */) { + if (token() !== 16 /* OpenBraceToken */) { return undefined; } return parseJSDocTypeExpression(); @@ -18536,15 +18590,15 @@ var ts; var name; var isBracketed; // Looking for something like '[foo]' or 'foo' - if (parseOptionalToken(19 /* OpenBracketToken */)) { + if (parseOptionalToken(20 /* OpenBracketToken */)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(56 /* EqualsToken */)) { + if (parseOptionalToken(57 /* EqualsToken */)) { parseExpression(); } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -18621,7 +18675,7 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69 /* Identifier */) { + if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_11 = jsDocTypeReference.name; if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -18645,7 +18699,7 @@ var ts; while (token() !== 1 /* EndOfFileToken */ && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -18659,13 +18713,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69 /* Identifier */: + case 70 /* Identifier */: canParseTag = false; case 1 /* EndOfFileToken */: break; @@ -18676,8 +18730,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getStartPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18717,11 +18771,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141 /* TypeParameter */, name_12.pos); + var typeParameter = createNode(142 /* TypeParameter */, name_12.pos); typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24 /* CommaToken */) { + if (token() === 25 /* CommaToken */) { nextJSDocToken(); skipWhitespace(); } @@ -18750,7 +18804,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69 /* Identifier */, pos); + var result = createNode(70 /* Identifier */, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -18868,8 +18922,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -18878,7 +18932,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: return true; } return false; @@ -19006,8 +19060,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -19249,16 +19303,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 224 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 226 /* ModuleBlock */) { + else if (node.kind === 227 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19277,7 +19331,7 @@ var ts; }); return state_1; } - else if (node.kind === 225 /* ModuleDeclaration */) { + else if (node.kind === 226 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -19415,7 +19469,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19428,7 +19482,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -19440,21 +19494,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return "__constructor"; - case 156 /* FunctionType */: - case 151 /* CallSignature */: + case 157 /* FunctionType */: + case 152 /* CallSignature */: return "__call"; - case 157 /* ConstructorType */: - case 152 /* ConstructSignature */: + case 158 /* ConstructorType */: + case 153 /* ConstructSignature */: return "__new"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "__index"; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return "__export"; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19469,12 +19523,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; case 269 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142 /* Parameter */: + case 143 /* 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 === 269 /* JSDocFunctionType */); @@ -19484,10 +19538,10 @@ var ts; case 279 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { nameFromParentNode = nameIdentifier.text; } } @@ -19571,7 +19625,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 === 235 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19591,7 +19645,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 238 /* ExportSpecifier */ || (node.kind === 229 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 239 /* ExportSpecifier */ || (node.kind === 230 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19753,64 +19807,64 @@ var ts; return; } switch (node.kind) { - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: bindWhileStatement(node); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: bindDoStatement(node); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: bindForStatement(node); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: bindIfStatement(node); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: bindTryStatement(node); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: bindSwitchStatement(node); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: bindCaseBlock(node); break; case 249 /* CaseClause */: bindCaseClause(node); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: bindLabeledStatement(node); break; - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19820,25 +19874,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return hasNarrowableArgument(expr); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 185 /* PrefixUnaryExpression */: - return expr.operator === 49 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 186 /* PrefixUnaryExpression */: + return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 /* Identifier */ || - expr.kind === 97 /* ThisKeyword */ || - expr.kind === 172 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + return expr.kind === 70 /* Identifier */ || + expr.kind === 98 /* ThisKeyword */ || + expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19849,41 +19903,41 @@ var ts; } } } - if (expr.expression.kind === 172 /* PropertyAccessExpression */ && + if (expr.expression.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 183 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableReference(expr.left); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -19903,7 +19957,7 @@ var ts; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 256 /* Referenced */ ? 512 /* Shared */ : 256 /* Referenced */; + flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -19918,8 +19972,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 99 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 84 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 100 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 85 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -19953,6 +20007,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256 /* ArrayMutation */, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -19966,34 +20028,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203 /* IfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 204 /* IfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: return parent.expression === node; - case 206 /* ForStatement */: - case 188 /* ConditionalExpression */: + case 207 /* ForStatement */: + case 189 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 185 /* PrefixUnaryExpression */ && node.operator === 49 /* ExclamationToken */) { + else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 187 /* BinaryExpression */ && (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 52 /* BarBarToken */); + return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */ || - node.parent.kind === 185 /* PrefixUnaryExpression */ && - node.parent.operator === 49 /* ExclamationToken */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */ || + node.parent.kind === 186 /* PrefixUnaryExpression */ && + node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -20066,7 +20128,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219 /* VariableDeclarationList */) { + if (node.initializer.kind !== 220 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20088,7 +20150,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211 /* ReturnStatement */) { + if (node.kind === 212 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20108,7 +20170,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20128,24 +20190,41 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; // TODO: Every statement in try block is potentially an exit point! bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + // in finally flow is combined from pre-try/flow from try/flow from catch + // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + // if flow after finally is unreachable - keep it + // otherwise check if flows after try and after catch are unreachable + // if yes - convert current flow to unreachable + // i.e. + // try { return "1" } finally { console.log(1); } + // console.log(2); // this line should be unreachable even if flow falls out of finally block + if (!(currentFlow.flags & 1 /* Unreachable */)) { + if ((flowAfterTry.flags & 1 /* Unreachable */) && (flowAfterCatch.flags & 1 /* Unreachable */)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - // if try statement has finally block and flow after finally block is unreachable - keep it - // otherwise use whatever flow was accumulated at postFinallyLabel - if (!node.finallyBlock || !(currentFlow.flags & 1 /* Unreachable */)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -20224,7 +20303,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20235,10 +20314,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170 /* ArrayLiteralExpression */) { + else if (node.kind === 171 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191 /* SpreadElementExpression */) { + if (e.kind === 192 /* SpreadElementExpression */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20246,7 +20325,7 @@ var ts; } } } - else if (node.kind === 171 /* ObjectLiteralExpression */) { + else if (node.kind === 172 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253 /* PropertyAssignment */) { @@ -20260,7 +20339,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -20271,7 +20350,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49 /* ExclamationToken */) { + if (node.operator === 50 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -20281,20 +20360,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 /* AmpersandAmpersandToken */ || operator === 52 /* BarBarToken */) { + if (operator === 52 /* AmpersandAmpersandToken */ || operator === 53 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -20306,14 +20385,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { + if (operator === 57 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172 /* PropertyAccessExpression */) { + if (node.expression.kind === 173 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20344,7 +20429,7 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 /* ForInStatement */ || node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 208 /* ForInStatement */ || node.parent.parent.kind === 209 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20353,10 +20438,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 178 /* ParenthesizedExpression */) { + while (expr.kind === 179 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 179 /* FunctionExpression */ || expr.kind === 180 /* ArrowFunction */) { + if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20364,54 +20449,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173 /* PropertyAccessExpression */) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return 1 /* IsContainer */; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; case 269 /* JSDocFunctionType */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: return 1 /* IsContainer */ | 32 /* HasLocals */; case 256 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; case 252 /* CatchClause */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 227 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 228 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 199 /* Block */: + case 200 /* 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 @@ -20448,18 +20539,18 @@ 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 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159 /* TypeLiteral */: - case 171 /* ObjectLiteralExpression */: - case 222 /* InterfaceDeclaration */: + case 160 /* TypeLiteral */: + case 172 /* ObjectLiteralExpression */: + case 223 /* InterfaceDeclaration */: case 265 /* JSDocRecordType */: case 281 /* JSDocTypeLiteral */: // Interface/Object-types always have their children added to the 'members' of @@ -20468,21 +20559,21 @@ var ts; // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* JSDocFunctionType */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -20504,10 +20595,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */)) { + if (body && (body.kind === 256 /* SourceFile */ || body.kind === 227 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 /* ExportDeclaration */ || stat.kind === 235 /* ExportAssignment */) { + if (stat.kind === 237 /* ExportDeclaration */ || stat.kind === 236 /* ExportAssignment */) { return true; } } @@ -20600,7 +20691,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69 /* Identifier */) { + if (prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20612,7 +20703,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 === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 147 /* MethodDeclaration */ + var currentKind = prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 148 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20634,7 +20725,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256 /* SourceFile */: @@ -20658,8 +20749,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 107 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 115 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { // Report error only if there are no parse errors in file @@ -20695,7 +20786,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 69 /* Identifier */) { + if (inStrictMode && node.expression.kind === 70 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span_2 = ts.getErrorSpanForNode(file, node.expression); @@ -20703,11 +20794,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69 /* Identifier */) { + if (name && name.kind === 70 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -20746,10 +20837,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration if (blockScopeContainer.kind !== 256 /* SourceFile */ && - blockScopeContainer.kind !== 225 /* ModuleDeclaration */ && + blockScopeContainer.kind !== 226 /* 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. @@ -20775,7 +20866,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -20815,7 +20906,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 138 /* LastToken */) { + if (node.kind > 139 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -20856,18 +20947,18 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: if (currentFlow && (ts.isExpression(node) || parent.kind === 254 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -20893,30 +20984,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252 /* CatchClause */: return checkStrictModeCatchClause(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkStrictModeWithStatement(node); - case 165 /* ThisType */: + case 166 /* ThisType */: seenThisKeyword = true; return; - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 142 /* Parameter */: + case 143 /* Parameter */: return bindParameter(node); - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 266 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); case 280 /* JSDocPropertyTag */: @@ -20929,90 +21020,90 @@ var ts; case 247 /* JsxSpreadAttribute */: emitFlags |= 16384 /* HasJsxSpreadAttributes */; return; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // 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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: case 269 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return bindFunctionExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); case 279 /* JSDocTypedefTag */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 229 /* ImportEqualsDeclaration */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return bindImportClause(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return bindExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return bindExportAssignment(node); case 256 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69 /* Identifier */) { + if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165 /* ThisType */) { + if (parameterName && parameterName.kind === 166 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -21035,7 +21126,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 === 235 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21081,7 +21172,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -21098,12 +21191,12 @@ 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 === 220 /* FunctionDeclaration */ || container.kind === 179 /* FunctionExpression */) { + if (container.kind === 221 /* FunctionDeclaration */ || container.kind === 180 /* 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 */); } - else if (container.kind === 148 /* Constructor */) { + else if (container.kind === 149 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -21154,7 +21247,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21298,13 +21391,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 201 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 202 /* EmptyStatement */) || // report error on class declarations - node.kind === 221 /* ClassDeclaration */ || + node.kind === 222 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 225 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 224 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 225 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21318,7 +21411,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 !== 200 /* VariableStatement */ || + (node.kind !== 201 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21338,52 +21431,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 225 /* ModuleDeclaration */: + case 176 /* NewExpression */: + return computeNewExpression(node, subtreeFlags); + case 226 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 142 /* Parameter */: + case 143 /* Parameter */: return computeParameter(node, subtreeFlags); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); case 251 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148 /* Constructor */: + case 149 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21394,44 +21489,60 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */ + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */ || isSuperOrSuperProperty(expression, expressionKind)) { // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537133909 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return true; - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95 /* SuperKeyword */; + return expressionKind === 96 /* SuperKeyword */; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { + // If the this node contains a SpreadElementExpression then it is an ES6 + // node. + transformFlags |= 768 /* AssertES2015 */; + } + node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 /* EqualsToken */ - && (leftKind === 171 /* ObjectLiteralExpression */ - || leftKind === 170 /* ArrayLiteralExpression */)) { + if (operatorTokenKind === 57 /* EqualsToken */ + && (leftKind === 172 /* ObjectLiteralExpression */ + || leftKind === 171 /* ArrayLiteralExpression */)) { // Destructuring assignments are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 256 /* DestructuringAssignment */; + transformFlags |= 768 /* AssertES2015 */ | 1024 /* DestructuringAssignment */; } - else if (operatorTokenKind === 38 /* AsteriskAsteriskToken */ - || operatorTokenKind === 60 /* AsteriskAsteriskEqualsToken */) { - // Exponentiation is ES7 syntax. - transformFlags |= 48 /* AssertES7 */; + else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ + || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { + // Exponentiation is ES2016 syntax. + transformFlags |= 192 /* AssertES2016 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21439,25 +21550,25 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - // If the parameter has a question token, then it is TypeScript syntax. - if (node.questionToken) { - transformFlags |= 3 /* AssertTypeScript */; - } - // If the parameter's name is 'this', then it is TypeScript syntax. - if (subtreeFlags & 2048 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { + // The '?' token, type annotations, decorators, and 'this' parameters are TypeSCript + // syntax. + if (node.questionToken + || node.type + || subtreeFlags & 8192 /* ContainsDecorators */ + || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. if (modifierFlags & 92 /* ParameterPropertyModifier */) { - transformFlags |= 3 /* AssertTypeScript */ | 131072 /* ContainsParameterPropertyAssignments */; + transformFlags |= 3 /* AssertTypeScript */ | 524288 /* ContainsParameterPropertyAssignments */; } // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. - if (subtreeFlags & 2097152 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { - transformFlags |= 192 /* AssertES6 */ | 65536 /* ContainsDefaultValueAssignments */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { + transformFlags |= 768 /* AssertES2015 */ | 262144 /* ContainsDefaultValueAssignments */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* ParameterExcludes */; + return transformFlags & ~545262933 /* ParameterExcludes */; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21467,17 +21578,17 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 195 /* AsExpression */ - || expressionKind === 177 /* TypeAssertionExpression */) { + if (expressionKind === 196 /* AsExpression */ + || expressionKind === 178 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 256 /* DestructuringAssignment */; + if (expressionTransformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 1024 /* DestructuringAssignment */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -21488,47 +21599,49 @@ var ts; } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | 192 /* AssertES6 */; + transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. // An exported declaration may be TypeScript syntax. - if ((subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) - || (modifierFlags & 1 /* Export */)) { + if ((subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */) + || (modifierFlags & 1 /* Export */) + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeClassExpression(node, subtreeFlags) { // A ClassExpression is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - if (subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) { + if (subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */ + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83 /* ExtendsKeyword */: + case 84 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 106 /* ImplementsKeyword */: + case 107 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -21537,65 +21650,65 @@ var ts; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionWithTypeArguments(node, subtreeFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { - // An overload constructor is TypeScript syntax. + // TypeScript-specific modifiers and overloads are TypeScript syntax + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* ConstructorExcludes */; + return transformFlags & ~591760725 /* ConstructorExcludes */; } function computeMethod(node, subtreeFlags) { // A MethodDeclaration is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || typeParameters - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and + // overloads are TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } + // An async method declaration is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // Currently, we only support generators that were originally async function bodies. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + // Decorators, TypeScript-specific modifiers, type annotations, and overloads are + // TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computePropertyDeclaration(node, subtreeFlags) { // A PropertyDeclaration is TypeScript syntax. @@ -21603,88 +21716,105 @@ var ts; // If the PropertyDeclaration has an initializer, we need to inform its ancestor // so that it handle the transformation. if (node.initializer) { - transformFlags |= 4096 /* ContainsPropertyInitializer */; + transformFlags |= 16384 /* ContainsPropertyInitializer */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2 /* Ambient */)) { // An ambient declaration is TypeScript syntax. // A FunctionDeclaration without a body is an overload and is TypeScript syntax. transformFlags = 3 /* AssertTypeScript */; } else { - transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; + transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 3 /* AssertTypeScript */ | 192 /* AssertES6 */; + transformFlags |= 3 /* AssertTypeScript */ | 768 /* AssertES2015 */; } - // If a FunctionDeclaration is async, then it is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (modifierFlags & 2270 /* TypeScriptModifier */ + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function declaration is ES2017 syntax. + if (modifierFlags & 256 /* Async */) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionDeclaration is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - // An async function expression is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function expression is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeArrowFunction(node, subtreeFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - // An async arrow function is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async arrow function is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { - transformFlags |= 16384 /* ContainsCapturedLexicalThis */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { + transformFlags |= 65536 /* ContainsCapturedLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550710101 /* ArrowFunctionExcludes */; + return transformFlags & ~592227669 /* ArrowFunctionExcludes */; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21692,21 +21822,25 @@ var ts; var expressionKind = expression.kind; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (expressionKind === 95 /* SuperKeyword */) { - transformFlags |= 8192 /* ContainsLexicalThis */; + if (expressionKind === 96 /* SuperKeyword */) { + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; // A VariableDeclaration with a binding pattern is ES6 syntax. - if (nameKind === 167 /* ObjectBindingPattern */ || nameKind === 168 /* ArrayBindingPattern */) { - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + if (nameKind === 168 /* ObjectBindingPattern */ || nameKind === 169 /* ArrayBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + } + // Type annotations are TypeScript syntax. + if (node.type) { + transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -21720,24 +21854,24 @@ var ts; transformFlags = subtreeFlags; // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; } - if (declarationListTransformFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + if (declarationListTransformFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */ + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */ && ts.isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21746,18 +21880,18 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // If the expression of an expression statement is a destructuring assignment, // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. - if (node.expression.transformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 192 /* AssertES6 */; + if (node.expression.transformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3 /* AssertTypeScript */; @@ -21766,46 +21900,49 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~546335573 /* ModuleExcludes */; + return transformFlags & ~574729557 /* ModuleExcludes */; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; - if (subtreeFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & 3 /* BlockScoped */) { - transformFlags |= 192 /* AssertES6 */ | 1048576 /* ContainsBlockScopedBinding */; + transformFlags |= 768 /* AssertES2015 */ | 4194304 /* ContainsBlockScopedBinding */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* VariableDeclarationListExcludes */; + return transformFlags & ~545262933 /* VariableDeclarationListExcludes */; } function computeOther(node, kind, subtreeFlags) { // Mark transformations needed for each node var transformFlags = subtreeFlags; - var excludeFlags = 536871765 /* NodeExcludes */; + var excludeFlags = 536874325 /* NodeExcludes */; switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 122 /* DeclareKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 184 /* AwaitExpression */: - case 224 /* EnumDeclaration */: + case 119 /* AsyncKeyword */: + case 185 /* AwaitExpression */: + // async/await is ES2017 syntax + transformFlags |= 48 /* AssertES2017 */; + break; + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: - case 196 /* NonNullExpression */: - case 128 /* ReadonlyKeyword */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: + case 197 /* NonNullExpression */: + case 129 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: - case 244 /* JsxText */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: + case 10 /* JsxText */: case 245 /* JsxClosingElement */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: @@ -21813,64 +21950,64 @@ var ts; // These nodes are Jsx syntax. transformFlags |= 12 /* AssertJsx */; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: // This node is both ES6 and TypeScript syntax. - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; break; - case 77 /* DefaultKeyword */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - case 189 /* TemplateExpression */: - case 176 /* TaggedTemplateExpression */: + case 78 /* DefaultKeyword */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + case 190 /* TemplateExpression */: + case 177 /* TaggedTemplateExpression */: case 254 /* ShorthandPropertyAssignment */: - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 4194304 /* ContainsYield */; + transformFlags |= 768 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 154 /* TypePredicate */: - case 155 /* TypeReference */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 155 /* TypePredicate */: + case 156 /* TypeReference */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. - transformFlags |= 524288 /* ContainsComputedPropertyName */; - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { + transformFlags |= 2097152 /* ContainsComputedPropertyName */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { // A computed method name like `[this.getName()](x: string) { ... }` needs to // distinguish itself from the normal case of a method body containing `this`: // `this` inside a method doesn't need to be rewritten (the method provides `this`), @@ -21879,70 +22016,70 @@ var ts; // `_this = this; () => class K { [_this.getName()]() { ... } }` // To make this distinction, use ContainsLexicalThisInComputedPropertyName // instead of ContainsLexicalThis for computed property names - transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; + transformFlags |= 131072 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: // This node is ES6 syntax, but is handled by a containing node. - transformFlags |= 262144 /* ContainsSpreadElementExpression */; + transformFlags |= 1048576 /* ContainsSpreadElementExpression */; break; - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; break; - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. - transformFlags |= 3 /* AssertTypeScript */ | 2048 /* ContainsDecorators */; + transformFlags |= 3 /* AssertTypeScript */ | 8192 /* ContainsDecorators */; break; - case 171 /* ObjectLiteralExpression */: - excludeFlags = 537430869 /* ObjectLiteralExcludes */; - if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { + case 172 /* ObjectLiteralExpression */: + excludeFlags = 539110741 /* ObjectLiteralExcludes */; + if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } break; - case 170 /* ArrayLiteralExpression */: - case 175 /* NewExpression */: - excludeFlags = 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */) { + case 171 /* ArrayLiteralExpression */: + case 176 /* NewExpression */: + excludeFlags = 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { // If the this node contains a SpreadElementExpression, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } break; - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { + transformFlags |= 768 /* AssertES2015 */; } break; case 256 /* SourceFile */: - if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 65536 /* ContainsCapturedLexicalThis */) { + transformFlags |= 768 /* AssertES2015 */; } break; - case 211 /* ReturnStatement */: - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: - transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; + case 212 /* ReturnStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: + transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21953,7 +22090,7 @@ var ts; /// var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -22724,6 +22861,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); @@ -22774,6 +22912,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; // The library files are only loaded when the feature is used. // This allows users to just specify library files they want to used through --lib @@ -23018,7 +23157,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 225 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 226 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 226 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23174,7 +23313,7 @@ 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 !== 218 /* VariableDeclaration */ || + return declaration.kind !== 219 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -23183,9 +23322,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200 /* VariableStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 201 /* VariableStatement */: + case 207 /* ForStatement */: + case 209 /* 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)) { @@ -23194,8 +23333,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23214,7 +23353,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 /* PropertyDeclaration */ && + current.parent.kind === 146 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -23250,8 +23389,8 @@ var ts; if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 273 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 142 /* Parameter */ || - lastLocation.kind === 141 /* TypeParameter */ + lastLocation.kind === 143 /* Parameter */ || + lastLocation.kind === 142 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -23260,9 +23399,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 142 /* Parameter */ || + lastLocation.kind === 143 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 142 /* Parameter */); + result.valueDeclaration.kind === 143 /* Parameter */); } } if (useResult) { @@ -23278,7 +23417,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local @@ -23303,7 +23442,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 238 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 239 /* ExportSpecifier */)) { break; } } @@ -23311,13 +23450,13 @@ var ts; break loop; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -23334,9 +23473,9 @@ var ts; } } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* 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 @@ -23347,7 +23486,7 @@ var ts; } break loop; } - if (location.kind === 192 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23363,9 +23502,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223 /* 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); @@ -23373,19 +23512,19 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23398,7 +23537,7 @@ var ts; } } break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -23407,7 +23546,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 142 /* Parameter */) { + if (location.parent && location.parent.kind === 143 /* Parameter */) { location = location.parent; } // @@ -23470,7 +23609,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 === 228 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 229 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23478,7 +23617,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); @@ -23523,10 +23662,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23548,7 +23687,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, 218 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23569,10 +23708,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 230 /* ImportDeclaration */) { + while (node && node.kind !== 231 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23582,10 +23721,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -23707,19 +23846,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return getTargetOfImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -23766,11 +23905,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235 /* ExportAssignment */) { + if (node.kind === 236 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 238 /* ExportSpecifier */) { + else if (node.kind === 239 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -23781,24 +23920,24 @@ var ts; } } // This function is only for imports with entity names - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { // There are three things we might try to look for. In the following examples, // the search term is enclosed in |...|: // // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 70 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 139 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 140 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 229 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 230 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -23811,16 +23950,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69 /* Identifier */) { + if (name.kind === 70 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 /* QualifiedName */ || name.kind === 172 /* PropertyAccessExpression */) { - var left = name.kind === 139 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 139 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 140 /* QualifiedName */ || name.kind === 173 /* PropertyAccessExpression */) { + var left = name.kind === 140 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 140 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -24027,7 +24166,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -24106,7 +24245,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24147,7 +24286,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24186,7 +24325,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, 238 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24201,10 +24340,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: continue; default: return false; @@ -24235,7 +24374,7 @@ var ts; return { accessibility: 1 /* NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined, }; } return hasAccessibleDeclarations; @@ -24272,7 +24411,7 @@ var ts; // Just a local name that is not accessible return { accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 /* Accessible */ }; @@ -24326,12 +24465,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 158 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 139 /* QualifiedName */ || entityName.kind === 172 /* PropertyAccessExpression */ || - entityName.parent.kind === 229 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 140 /* QualifiedName */ || entityName.kind === 173 /* PropertyAccessExpression */ || + entityName.parent.kind === 230 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24427,10 +24566,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164 /* ParenthesizedType */) { + while (node.kind === 165 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 224 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24438,7 +24577,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 /* ModuleBlock */ && + node.parent.kind === 227 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24452,10 +24591,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return "(Anonymous class)"; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24478,17 +24617,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); writer.writeSymbol(symbolName, symbol); } } @@ -24587,7 +24726,7 @@ var ts; } else if (type.flags & 256 /* EnumLiteral */) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 /* Class */ | 65536 /* Interface */ | 16 /* Enum */ | 16384 /* TypeParameter */)) { @@ -24617,23 +24756,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24 /* CommaToken */) { + if (delimiter !== 25 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 25 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -24642,29 +24781,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } if (pos < end) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); writeType(typeArguments[pos], 256 /* InFirstTypeArgument */); pos++; while (pos < end) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos], 0 /* None */); pos++; } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 19 /* OpenBracketToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else if (type.target.flags & 262144 /* Tuple */) { - writePunctuation(writer, 19 /* OpenBracketToken */); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24 /* CommaToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { // Write the type reference in the format f
.g.C where A and B are type arguments @@ -24685,7 +24824,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); } } } @@ -24695,16 +24834,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } if (type.flags & 524288 /* Union */) { - writeTypeList(formatUnionTypes(type.types), 47 /* BarToken */); + writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); } else { - writeTypeList(type.types, 46 /* AmpersandToken */); + writeTypeList(type.types, 47 /* AmpersandToken */); } if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -24726,7 +24865,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 117 /* AnyKeyword */); + writeKeyword(writer, 118 /* AnyKeyword */); } } else { @@ -24750,7 +24889,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 226 /* ModuleBlock */; + return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 227 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -24760,37 +24899,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101 /* TypeOfKeyword */); + writeKeyword(writer, 102 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(info.type, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -24809,53 +24948,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15 /* OpenBraceToken */); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1 /* Construct */, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 130 /* NumberKeyword */); + writeIndexSignature(resolved.stringIndexInfo, 133 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 131 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -24865,21 +25004,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -24894,7 +25033,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83 /* ExtendsKeyword */); + writeKeyword(writer, 84 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -24902,7 +25041,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -24911,37 +25050,37 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 167 /* ObjectBindingPattern */) { - writePunctuation(writer, 15 /* OpenBraceToken */); + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { - writePunctuation(writer, 19 /* OpenBracketToken */); + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -24949,75 +25088,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - var flags_1 = 256 /* InFirstTypeArgument */; + writePunctuation(writer, 26 /* LessThanToken */); + var flags = 256 /* InFirstTypeArgument */; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); - flags_1 = 0 /* None */; + flags = 0 /* None */; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97 /* ThisKeyword */); + writeKeyword(writer, 98 /* ThisKeyword */); } writeSpace(writer); - writeKeyword(writer, 124 /* IsKeyword */); + writeKeyword(writer, 125 /* IsKeyword */); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 34 /* EqualsGreaterThanToken */); + writePunctuation(writer, 35 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); } writeSpace(writer); if (signature.typePredicate) { @@ -25030,7 +25169,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); } if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -25068,22 +25207,22 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 218 /* VariableDeclaration */: + case 219 /* 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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 220 /* FunctionDeclaration */: - case 224 /* EnumDeclaration */: - case 229 /* ImportEqualsDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 225 /* EnumDeclaration */: + case 230 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -25091,52 +25230,52 @@ var ts; var parent_10 = 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 !== 229 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_10); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 148 /* Constructor */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: - case 142 /* Parameter */: - case 226 /* ModuleBlock */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: - case 155 /* TypeReference */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: + case 149 /* Constructor */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: + case 143 /* Parameter */: + case 227 /* ModuleBlock */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: + case 156 /* TypeReference */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: return false; // Type parameters are always visible - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: // Source file and namespace export are always visible case 256 /* SourceFile */: - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return false; default: return false; @@ -25145,10 +25284,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 236 /* 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 === 238 /* ExportSpecifier */) { + else if (node.parent.kind === 239 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25242,12 +25381,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218 /* VariableDeclaration */: - case 219 /* VariableDeclarationList */: - case 234 /* ImportSpecifier */: - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - case 231 /* ImportClause */: + case 219 /* VariableDeclaration */: + case 220 /* VariableDeclarationList */: + case 235 /* ImportSpecifier */: + case 234 /* NamedImports */: + case 233 /* NamespaceImport */: + case 232 /* ImportClause */: node = node.parent; break; default: @@ -25282,12 +25421,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return name.text; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -25295,7 +25434,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { @@ -25315,7 +25454,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 167 /* ObjectBindingPattern */) { + if (pattern.kind === 168 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_14 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_14)) { @@ -25383,16 +25522,16 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 /* VariableDeclaration */ && - declaration.parent.kind === 219 /* VariableDeclarationList */ && - declaration.parent.parent.kind === 200 /* VariableStatement */) { + if (declaration.kind === 219 /* VariableDeclaration */ && + declaration.parent.kind === 220 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 201 /* VariableStatement */) { // @type annotation might have been on the variable statement, try that instead. var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142 /* Parameter */) { + else if (declaration.kind === 143 /* Parameter */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); @@ -25402,9 +25541,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 /* NullKeyword */ || expr.kind === 69 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 /* NullKeyword */ || expr.kind === 70 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; @@ -25421,10 +25564,10 @@ var ts; } } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 207 /* ForInStatement */) { + if (declaration.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 208 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 209 /* 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, @@ -25438,18 +25581,24 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - // Use control flow type inference for non-ambient, non-exported var or let variables with no initializer - // or a 'null' or 'undefined' initializer. - if (declaration.kind === 218 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { + // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no + // initializer or a 'null' or 'undefined' initializer. + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array + // literal initializer. + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 150 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149 /* GetAccessor */); + if (func.kind === 151 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -25464,8 +25613,7 @@ var ts; // Use contextual parameter type if one is available var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -25537,7 +25685,7 @@ var ts; var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { - return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); @@ -25556,7 +25704,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 /* ObjectBindingPattern */ + return pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25595,7 +25743,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 143 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -25611,7 +25759,7 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 235 /* ExportAssignment */) { + if (declaration.kind === 236 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) { @@ -25627,8 +25775,8 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 187 /* BinaryExpression */ || - declaration.kind === 172 /* PropertyAccessExpression */ && declaration.parent.kind === 187 /* BinaryExpression */) { + if (declaration.kind === 188 /* BinaryExpression */ || + declaration.kind === 173 /* PropertyAccessExpression */ && declaration.parent.kind === 188 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement if (declaration.flags & 1048576 /* JavaScriptFile */) { var typeTag = ts.getJSDocTypeTag(declaration.parent); @@ -25636,7 +25784,7 @@ var ts; return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 /* BinaryExpression */ ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -25664,7 +25812,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -25684,8 +25832,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 150 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 151 /* SetAccessor */); if (getter && getter.flags & 1048576 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -25729,7 +25877,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -25740,7 +25888,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -25836,9 +25984,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */ || - node.kind === 220 /* FunctionDeclaration */ || node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */ || node.kind === 180 /* ArrowFunction */) { + if (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */ || + node.kind === 221 /* FunctionDeclaration */ || node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */ || node.kind === 181 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -25848,7 +25996,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, 222 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -25857,8 +26005,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 221 /* ClassDeclaration */ || - node.kind === 192 /* ClassExpression */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 222 /* ClassDeclaration */ || + node.kind === 193 /* ClassExpression */ || node.kind === 224 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26001,7 +26149,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 === 222 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -26033,7 +26181,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 223 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26102,7 +26250,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -26128,14 +26276,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 69 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26163,7 +26311,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 === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26201,7 +26349,7 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -26254,20 +26402,20 @@ var ts; // considered independent. function isIndependentType(node) { switch (node.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 167 /* LiteralType */: return true; - case 160 /* ArrayType */: + case 161 /* ArrayType */: return isIndependentType(node.elementType); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26280,7 +26428,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -26301,12 +26449,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -26933,7 +27081,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69 /* Identifier */) { + if (node.parameterName.kind === 70 /* Identifier */) { var parameterName = node.parameterName; return { kind: 1 /* Identifier */, @@ -26976,7 +27124,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166 /* LiteralType */) { + if (param.type && param.type.kind === 167 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -26990,10 +27138,10 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 149 /* GetAccessor */ || declaration.kind === 150 /* SetAccessor */) && + if ((declaration.kind === 150 /* GetAccessor */ || declaration.kind === 151 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = declaration.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -27005,24 +27153,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 /* Constructor */ ? + var classType = declaration.kind === 149 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 /* TypePredicate */ ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -27040,8 +27185,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 149 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150 /* SetAccessor */); + if (declaration.kind === 150 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -27055,19 +27200,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* 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 @@ -27155,7 +27300,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 /* Constructor */ || signature.declaration.kind === 152 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 149 /* Constructor */ || signature.declaration.kind === 153 /* ConstructSignature */; var type = createObjectType(2097152 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -27169,7 +27314,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 130 /* NumberKeyword */ : 132 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 131 /* NumberKeyword */ : 133 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -27196,7 +27341,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 142 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -27229,7 +27374,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -27341,11 +27486,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; case 267 /* JSDocTypeReference */: return node.name; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27355,7 +27500,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -27386,12 +27531,12 @@ var ts; var type = void 0; if (node.kind === 267 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 155 /* TypeReference */ + var typeNameOrExpression = node.kind === 156 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -27426,9 +27571,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: return declaration; } } @@ -27838,9 +27983,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 148 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -27859,25 +28004,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117 /* AnyKeyword */: + case 118 /* AnyKeyword */: case 258 /* JSDocAllType */: case 259 /* JSDocUnknownType */: return anyType; - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return stringType; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return numberType; - case 120 /* BooleanKeyword */: + case 121 /* BooleanKeyword */: return booleanType; - case 133 /* SymbolKeyword */: + case 134 /* SymbolKeyword */: return esSymbolType; - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return voidType; - case 135 /* UndefinedKeyword */: + case 136 /* UndefinedKeyword */: return undefinedType; - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullType; - case 127 /* NeverKeyword */: + case 128 /* NeverKeyword */: return neverType; case 283 /* JSDocNullKeyword */: return nullType; @@ -27885,33 +28030,33 @@ var ts; return undefinedType; case 285 /* JSDocNeverKeyword */: return neverType; - case 165 /* ThisType */: - case 97 /* ThisKeyword */: + case 166 /* ThisType */: + case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 282 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 155 /* TypeReference */: + case 156 /* TypeReference */: case 267 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return booleanType; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: case 260 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 162 /* UnionType */: + case 163 /* UnionType */: case 261 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: case 263 /* JSDocNullableType */: case 264 /* JSDocNonNullableType */: case 271 /* JSDocConstructorType */: @@ -27920,16 +28065,16 @@ var ts; return getTypeFromTypeNode(node.type); case 265 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 269 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262 /* JSDocTupleType */: @@ -28097,23 +28242,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28123,14 +28268,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: return false; } @@ -28173,35 +28318,50 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187 /* BinaryExpression */: - return node.operatorToken.kind === 52 /* BarBarToken */ && + case 188 /* BinaryExpression */: + return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 /* ArrowFunction */ && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + // Functions with type parameters are not context sensitive. + if (node.typeParameters) { + return false; + } + // Functions with any parameters that lack type annotations are context sensitive. + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + // For arrow functions we now know we're not context sensitive. + if (node.kind === 181 /* ArrowFunction */) { + return false; + } + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. Otherwise we + // know that all parameters (including 'this') have type annotations and nothing is + // subject to contextual typing. + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -28691,8 +28851,8 @@ var ts; } if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ || source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target, /*reportErrors*/ false)) { - if (result &= eachTypeRelatedToSomeType(target, source, /*reportErrors*/ false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -28750,7 +28910,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -29414,7 +29574,7 @@ var ts; type.flags & 64 /* NumberLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -29422,7 +29582,7 @@ var ts; type.flags & 64 /* NumberLiteral */ && type.flags & 16777216 /* FreshLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } /** @@ -29549,10 +29709,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -29604,25 +29764,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142 /* Parameter */: + case 143 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169 /* BindingElement */: + case 170 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -29668,7 +29828,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -29676,7 +29836,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } // Return true if the given type could possibly reference a type parameter for which @@ -29957,7 +30117,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; // Infer widened union or supertype, or the unknown type for no common supertype var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, /*subtypeReduction*/ true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; @@ -30011,10 +30171,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return true; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: node = node.parent; continue; default: @@ -30028,14 +30188,14 @@ var ts; // leftmost identifier followed by zero or more property names separated by dots. // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97 /* ThisKeyword */) { + if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 173 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30043,31 +30203,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69 /* Identifier */: - return target.kind === 69 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 /* VariableDeclaration */ || target.kind === 169 /* BindingElement */) && + case 70 /* Identifier */: + return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 /* VariableDeclaration */ || target.kind === 170 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97 /* ThisKeyword */: - return target.kind === 97 /* ThisKeyword */; - case 172 /* PropertyAccessExpression */: - return target.kind === 172 /* PropertyAccessExpression */ && + case 98 /* ThisKeyword */: + return target.kind === 98 /* ThisKeyword */; + case 173 /* PropertyAccessExpression */: + return target.kind === 173 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172 /* PropertyAccessExpression */) { + while (source.kind === 173 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30080,15 +30240,15 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 /* PropertyAccessExpression */ && + return target.kind === 173 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69 /* Identifier */) { + if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -30118,7 +30278,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30249,7 +30409,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? + return node.parent.kind === 171 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -30268,17 +30428,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return stringType; - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return undefinedType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return getAssignedTypeOfSpreadElement(parent); case 253 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); @@ -30290,7 +30450,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 /* ObjectBindingPattern */ ? + var type = pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -30308,38 +30468,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207 /* ForInStatement */) { + if (node.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.parent.kind === 209 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 /* VariableDeclaration */ ? + return node.kind === 219 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */ ? + return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 /* VariableDeclaration */ && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return getReferenceCandidate(node.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 /* ParenthesizedExpression */ || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -30415,24 +30588,105 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + // An evolving array type tracks the element types that have so far been seen in an + // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving + // array types are ultimately converted into manifest array types (using getFinalArrayType) + // and never escape the getFlowTypeOfReference function. + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152 /* Anonymous */); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + // When adding evolving array element types we do not perform subtype reduction. Instead, + // we defer subtype reduction until the evolving array type is finalized into a manifest + // array type. + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 /* Anonymous */ && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 /* Never */ ? + autoArrayType : + createArrayType(elementType.flags & 524288 /* Union */ ? + getUnionType(elementType.types, /*subtypeReduction*/ true) : + elementType); + } + // We perform subtype reduction upon obtaining the final array type from an evolving array type. + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192 /* Never */)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + // At flow control branch or loop junctions, if the type along every antecedent code path + // is an evolving array type, we construct a combined evolving array type. Otherwise we + // finalize all evolving array types. + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + // Return true if the given node is 'x' in an 'x.length', x.push(value)', 'x.unshift(value)' or + // 'x[n] = value' operation, where 'n' is an expression of type any, undefined, or a number-like type. + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 175 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 /* ElementAccessExpression */ && + parent.expression === root && + parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 57 /* EqualsToken */ && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 /* NonNullExpression */ && getTypeWithFacts(result, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, + // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations + // on empty arrays are possible without implicit any errors and new element types can be inferred without + // type mismatch errors. + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -30465,10 +30719,17 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256 /* ArrayMutation */) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 173 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30477,10 +30738,10 @@ var ts; } else { // Unreachable code errors are reported in the binding phase. Here we - // simply return the declared type to reduce follow-on errors. - type = declaredType; + // simply return the non-auto declared type to reduce follow-on errors. + type = convertAutoToAny(declaredType); } - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // Record visited node and the associated type in the cache. visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; @@ -30494,13 +30755,21 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */) { + if (node.parent.kind === 186 /* PrefixUnaryExpression */ || node.parent.kind === 187 /* PostfixUnaryExpression */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 /* Union */ ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288 /* Union */) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } // We didn't have a direct match. However, if the reference is a dotted name, this // may be an assignment to a left hand part of the reference. For example, for a @@ -30512,24 +30781,56 @@ var ts; // Assignment doesn't affect reference return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 /* CallExpression */ ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175 /* CallExpression */) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */ | 2048 /* Undefined */)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192 /* Never */)) { - // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the never type, and if - // the antecedent type is incomplete (i.e. a transient type in a loop), then we - // take the type guard as an indication that control *could* reach here once we - // have the complete type. We proceed by switching to the silent never type which - // doesn't report errors when operators are applied to it. Note that this is the - // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 /* Never */ && isIncomplete(flowType)) { - type = silentNeverType; - } - } - return createFlowType(type, isIncomplete(flowType)); + if (type.flags & 8192 /* Never */) { + return flowType; + } + // If we have an antecedent type (meaning we're reachable in some way), we first + // attempt to narrow the antecedent type. If that produces the never type, and if + // the antecedent type is incomplete (i.e. a transient type in a loop), then we + // take the type guard as an indication that control *could* reach here once we + // have the complete type. We proceed by switching to the silent never type which + // doesn't report errors when operators are applied to it. Note that this is the + // *only* place a silent never type is ever generated. + var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 /* Never */ ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -30571,7 +30872,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -30586,11 +30887,15 @@ var ts; } // 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. - // We should never see an empty array here because the first antecedent of a loop - // junction is always the non-looping control flow path that leads to the top. + // It is possible to see an empty array in cases where loops are nested and the + // back edge of the outer loop reaches an inner loop that is already being analyzed. + // In such cases we restart the analysis of the inner loop, which will then see + // a non-empty in-process array for the outer loop and eventually terminate because + // the first antecedent of a loop junction is always the non-looping control flow + // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], /*subtypeReduction*/ false), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -30634,14 +30939,14 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 /* PropertyAccessExpression */ && + return expr.kind === 173 /* PropertyAccessExpression */ && declaredType.flags & 524288 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -30666,19 +30971,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 183 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 183 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -30697,9 +31002,9 @@ var ts; return declaredType; } break; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -30708,7 +31013,7 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -30716,10 +31021,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 /* EqualsEqualsToken */ || operator === 31 /* ExclamationEqualsToken */; + var doubleEquals = operator === 31 /* EqualsEqualsToken */ || operator === 32 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - value.kind === 93 /* NullKeyword */ ? + value.kind === 94 /* NullKeyword */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); @@ -30748,7 +31053,7 @@ var ts; } return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288 /* Union */)) { @@ -30877,7 +31182,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 /* ElementAccessExpression */ || invokedExpression.kind === 172 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 174 /* ElementAccessExpression */ || invokedExpression.kind === 173 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -30894,18 +31199,18 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185 /* PrefixUnaryExpression */: - if (expr.operator === 49 /* ExclamationToken */) { + case 186 /* PrefixUnaryExpression */: + if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -30918,7 +31223,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 69 /* Identifier */) { + if (location.kind === 70 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -30937,7 +31242,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178 /* ParenthesizedExpression */) { + while (expression.kind === 179 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -30946,9 +31251,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 /* ModuleBlock */ || + node.kind === 227 /* ModuleBlock */ || node.kind === 256 /* SourceFile */ || - node.kind === 145 /* PropertyDeclaration */) { + node.kind === 146 /* PropertyDeclaration */) { return node; } } @@ -30977,10 +31282,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143 /* Parameter */) { symbol.isAssigned = true; } } @@ -30989,6 +31294,9 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. @@ -30999,8 +31307,8 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES6 */) { - if (container.kind === 180 /* ArrowFunction */) { + if (languageVersion < 2 /* ES2015 */) { + if (container.kind === 181 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -31020,8 +31328,8 @@ 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 (languageVersion === 2 /* ES6 */ - && declaration_1.kind === 221 /* ClassDeclaration */ + if (languageVersion === 2 /* ES2015 */ + && declaration_1.kind === 222 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31033,14 +31341,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192 /* ClassExpression */) { + else if (declaration_1.kind === 193 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 146 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -31063,37 +31371,35 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 142 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 143 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 /* FunctionExpression */ || - flowContainer.kind === 180 /* ArrowFunction */ || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 /* FunctionExpression */ || + flowContainer.kind === 181 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // 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 && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || 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 // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { @@ -31114,7 +31420,7 @@ var ts; return false; } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES6 */ || + if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || symbol.valueDeclaration.parent.kind === 252 /* CatchClause */) { return; @@ -31141,8 +31447,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 === 206 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 219 /* VariableDeclarationList */).parent === container && + if (container.kind === 207 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 220 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31156,7 +31462,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 178 /* ParenthesizedExpression */) { + while (current.parent.kind === 179 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31164,9 +31470,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 /* PrefixUnaryExpression */ || current.parent.kind === 186 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 186 /* PrefixUnaryExpression */ || current.parent.kind === 187 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 41 /* PlusPlusToken */ || expr.operator === 42 /* MinusMinusToken */; + isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -31185,7 +31491,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 145 /* PropertyDeclaration */ || container.kind === 148 /* Constructor */) { + if (container.kind === 146 /* PropertyDeclaration */ || container.kind === 149 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -31233,7 +31539,7 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 148 /* Constructor */) { + if (container.kind === 149 /* Constructor */) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); // If a containing class does not have extends clause or the class extends null @@ -31254,32 +31560,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 180 /* ArrowFunction */) { + if (container.kind === 181 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code - needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); + needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* 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 224 /* EnumDeclaration */: + case 225 /* 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; - case 148 /* Constructor */: + case 149 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -31291,7 +31597,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 179 /* FunctionExpression */ && + if (container.kind === 180 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31304,7 +31610,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -31337,21 +31643,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142 /* Parameter */) { + if (n.kind === 143 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 180 /* ArrowFunction */) { + while (container && container.kind === 181 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -31363,16 +31669,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 140 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 141 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 140 /* ComputedPropertyName */) { + if (current && current.kind === 141 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31443,7 +31749,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 147 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 148 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -31457,8 +31763,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES6 */) { + if (container.parent.kind === 172 /* ObjectLiteralExpression */) { + if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; } @@ -31477,7 +31783,7 @@ var ts; } return unknownType; } - if (container.kind === 148 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; @@ -31492,7 +31798,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 148 /* Constructor */; + return container.kind === 149 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -31500,32 +31806,35 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */; } else { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */ || - container.kind === 145 /* PropertyDeclaration */ || - container.kind === 144 /* PropertySignature */ || - container.kind === 148 /* Constructor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */ || + container.kind === 146 /* PropertyDeclaration */ || + container.kind === 145 /* PropertySignature */ || + container.kind === 149 /* Constructor */; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180 /* ArrowFunction */) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -31585,7 +31894,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -31637,7 +31946,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 143 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -31648,8 +31957,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 148 /* Constructor */ || - functionDecl.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150 /* SetAccessor */))) { + functionDecl.kind === 149 /* Constructor */ || + functionDecl.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -31671,7 +31980,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176 /* TaggedTemplateExpression */) { + if (template.parent.kind === 177 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -31679,7 +31988,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // Don't do this for special property assignments to avoid circularity if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0 /* None */) { return undefined; @@ -31689,7 +31998,7 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52 /* BarBarToken */) { + else if (operator === 53 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -31698,7 +32007,7 @@ var ts; } return type; } - else if (operator === 51 /* AmpersandAmpersandToken */ || operator === 24 /* CommaToken */) { + else if (operator === 52 /* AmpersandAmpersandToken */ || operator === 25 /* CommaToken */) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -31715,8 +32024,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -31786,7 +32095,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -31843,36 +32152,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 170 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 180 /* ArrowFunction */: - case 211 /* ReturnStatement */: + case 181 /* ArrowFunction */: + case 212 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 197 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 189 /* TemplateExpression */); + case 198 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getContextualType(parent); case 248 /* JsxExpression */: return getContextualType(parent); @@ -31894,7 +32203,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -31913,7 +32222,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -31923,8 +32232,8 @@ var ts; } var signatureList; var types = type.types; - 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 signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -31980,8 +32289,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 169 /* BindingElement */ && !!node.initializer) || - (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 170 /* BindingElement */ && !!node.initializer) || + (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -31990,7 +32299,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 192 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32005,7 +32314,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -32014,7 +32323,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32029,7 +32338,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 168 /* ArrayBindingPattern */ || pattern.kind === 170 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 169 /* ArrayBindingPattern */ || pattern.kind === 171 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32037,7 +32346,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193 /* OmittedExpression */) { + if (patternElement.kind !== 194 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32054,7 +32363,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -32124,7 +32433,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 /* ObjectBindingPattern */ || contextualType.pattern.kind === 171 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 168 /* ObjectBindingPattern */ || contextualType.pattern.kind === 172 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32139,7 +32448,7 @@ var ts; if (memberDecl.kind === 253 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147 /* MethodDeclaration */) { + else if (memberDecl.kind === 148 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -32187,7 +32496,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 149 /* GetAccessor */ || memberDecl.kind === 150 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 150 /* GetAccessor */ || memberDecl.kind === 151 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -32251,10 +32560,10 @@ var ts; case 248 /* JsxExpression */: checkJsxExpression(child); break; - case 241 /* JsxElement */: + case 242 /* JsxElement */: checkJsxElement(child); break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32273,7 +32582,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 172 /* PropertyAccessExpression */ || tagName.kind === 97 /* ThisKeyword */) { + if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32400,7 +32709,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), /*subtypeReduction*/ true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -32444,7 +32753,7 @@ var ts; } if (elemType.flags & 524288 /* Union */) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), /*subtypeReduction*/ true); } @@ -32654,7 +32963,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 146 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; @@ -32673,10 +32982,10 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 /* PropertyAccessExpression */ || node.kind === 218 /* VariableDeclaration */ ? + var errorNode = node.kind === 173 /* PropertyAccessExpression */ || node.kind === 219 /* VariableDeclaration */ ? node.name : node.right; - if (left.kind === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or // instance member variable initializer where this references a derived class instance, @@ -32684,7 +32993,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 147 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 148 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -32715,7 +33024,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { return true; } // Get the enclosing class that has the declaring class as its base type @@ -32799,7 +33108,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 172 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || + if (node.kind !== 173 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 524288 /* Union */)) { return propType; @@ -32821,7 +33130,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 /* PropertyAccessExpression */ + var left = node.kind === 173 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -32838,13 +33147,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219 /* VariableDeclarationList */) { + if (initializer.kind === 220 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69 /* Identifier */) { + else if (initializer.kind === 70 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -32861,13 +33170,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 /* ForInStatement */ && + if (node.kind === 208 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -32884,7 +33193,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 176 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -32970,7 +33279,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 /* ElementAccessExpression */ || indexArgumentExpression.kind === 172 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 174 /* ElementAccessExpression */ || indexArgumentExpression.kind === 173 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -33025,10 +33334,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 143 /* Decorator */) { + else if (node.kind !== 144 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33094,7 +33403,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191 /* SpreadElementExpression */) { + if (arg && arg.kind === 192 /* SpreadElementExpression */) { return i; } } @@ -33107,13 +33416,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189 /* TemplateExpression */) { + if (tagExpression.template.kind === 190 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -33126,11 +33435,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 12 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -33139,7 +33448,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 175 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 176 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33223,9 +33532,9 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33280,7 +33589,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 176 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -33297,10 +33606,10 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33319,12 +33628,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 174 /* CallExpression */) { + if (node.kind === 175 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 172 /* PropertyAccessExpression */) { + if (callee.kind === 173 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 173 /* ElementAccessExpression */) { + else if (callee.kind === 174 /* ElementAccessExpression */) { return callee.expression; } } @@ -33340,16 +33649,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -33374,19 +33683,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) // If we are emitting decorators for ES3, we will only pass two arguments. @@ -33396,7 +33705,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 142 /* Parameter */: + case 143 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -33420,25 +33729,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* 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); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -33465,32 +33774,32 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -33516,21 +33825,21 @@ 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 === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 145 /* PropertyDeclaration */) { + if (node.kind === 146 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -33558,14 +33867,14 @@ var ts; /** * Gets the effective argument type for an argument in a call expression. */ - function getEffectiveArgumentType(node, argIndex, arg) { + function getEffectiveArgumentType(node, argIndex) { // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -33577,8 +33886,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 143 /* Decorator */ || - (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */)) { + if (node.kind === 144 /* Decorator */ || + (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -33587,11 +33896,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -33600,13 +33909,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 143 /* Decorator */; + var isTaggedTemplate = node.kind === 177 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 144 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 95 /* SuperKeyword */) { + if (node.expression.kind !== 96 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -33672,7 +33981,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -33818,7 +34127,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -34020,16 +34329,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -34059,13 +34368,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143 /* Decorator */: + case 144 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34111,22 +34420,22 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 175 /* NewExpression */) { + if (node.kind === 176 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 /* Constructor */ && - declaration.kind !== 152 /* ConstructSignature */ && - declaration.kind !== 157 /* ConstructorType */ && + declaration.kind !== 149 /* Constructor */ && + declaration.kind !== 153 /* ConstructSignature */ && + declaration.kind !== 158 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations // in a JS file // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - var funcSymbol = node.expression.kind === 69 /* Identifier */ ? + var funcSymbol = node.expression.kind === 70 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -34139,7 +34448,10 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && + // Make sure require is not a local function + !resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -34179,21 +34491,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push @@ -34203,7 +34530,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69 /* Identifier */) { + if (element.name.kind === 70 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -34217,8 +34544,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 168 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 168 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 169 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34288,7 +34615,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199 /* Block */) { + if (func.body.kind !== 200 /* 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 @@ -34378,7 +34705,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -34411,7 +34738,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */)) { + func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -34440,7 +34767,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 !== 199 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -34473,10 +34800,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 180 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -34517,14 +34844,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 148 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -34540,7 +34867,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199 /* Block */) { + if (node.body.kind === 200 /* Block */) { checkSourceElement(node.body); } else { @@ -34587,11 +34914,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) && - expr.expression.kind === 97 /* ThisKeyword */) { + (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) && + expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148 /* Constructor */)) + if (!(func && func.kind === 149 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -34603,13 +34930,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232 /* NamespaceImport */; + return declaration && declaration.kind === 233 /* NamespaceImport */; } } } @@ -34618,7 +34945,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 /* Identifier */ && node.kind !== 172 /* PropertyAccessExpression */ && node.kind !== 173 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 173 /* PropertyAccessExpression */ && node.kind !== 174 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -34631,7 +34958,7 @@ var ts; if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { // Only variables (and not functions, classes, namespaces, enum objects, or enum members) // are considered references when referenced using a simple identifier. - if (node.kind === 69 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { + if (node.kind === 70 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { error(expr, invalidReferenceMessage); return false; } @@ -34641,7 +34968,7 @@ var ts; } } } - else if (node.kind === 173 /* ElementAccessExpression */) { + else if (node.kind === 174 /* ElementAccessExpression */) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -34679,24 +35006,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 37 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, "" + -node.operand.text)); } switch (node.operator) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); return facts === 1048576 /* Truthy */ ? falseType : facts === 2097152 /* Falsy */ ? trueType : booleanType; - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.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 @@ -34726,8 +35053,8 @@ var ts; } if (type.flags & 1572864 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -34744,8 +35071,8 @@ var ts; } if (type.flags & 524288 /* Union */) { 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 (!isTypeOfKind(t, kind)) { return false; } @@ -34754,8 +35081,8 @@ var ts; } if (type.flags & 1048576 /* Intersection */) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -34803,18 +35130,18 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 /* PropertyAssignment */ || property.kind === 254 /* ShorthandPropertyAssignment */) { var name_17 = property.name; - if (name_17.kind === 140 /* ComputedPropertyName */) { + if (name_17.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(name_17); } if (isComputedNonLiteralName(name_17)) { @@ -34857,8 +35184,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193 /* OmittedExpression */) { - if (element.kind !== 191 /* SpreadElementExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { + if (element.kind !== 192 /* SpreadElementExpression */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -34886,7 +35213,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 188 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -34915,14 +35242,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171 /* ObjectLiteralExpression */) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170 /* ArrayLiteralExpression */) { + if (target.kind === 171 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -34945,52 +35272,52 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 176 /* TaggedTemplateExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 177 /* TaggedTemplateExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 182 /* TypeOfExpression */: - case 196 /* NonNullExpression */: - case 242 /* JsxSelfClosingElement */: - case 241 /* JsxElement */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 183 /* TypeOfExpression */: + case 197 /* NonNullExpression */: + case 243 /* JsxSelfClosingElement */: + case 242 /* JsxElement */: return true; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 49 /* ExclamationToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 183 /* VoidExpression */: // Explicit opt-out - case 177 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 195 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 184 /* VoidExpression */: // Explicit opt-out + case 178 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 196 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35010,34 +35337,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 171 /* ObjectLiteralExpression */ || left.kind === 170 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 172 /* ObjectLiteralExpression */ || left.kind === 171 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37 /* AsteriskToken */: - case 38 /* AsteriskAsteriskToken */: - case 59 /* AsteriskEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - case 40 /* PercentToken */: - case 62 /* PercentEqualsToken */: - case 36 /* MinusToken */: - case 58 /* MinusEqualsToken */: - case 43 /* LessThanLessThanToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* BarToken */: - case 67 /* BarEqualsToken */: - case 48 /* CaretToken */: - case 68 /* CaretEqualsToken */: - case 46 /* AmpersandToken */: - case 66 /* AmpersandEqualsToken */: + case 38 /* AsteriskToken */: + case 39 /* AsteriskAsteriskToken */: + case 60 /* AsteriskEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 41 /* PercentToken */: + case 63 /* PercentEqualsToken */: + case 37 /* MinusToken */: + case 59 /* MinusEqualsToken */: + case 44 /* LessThanLessThanToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35070,8 +35397,8 @@ var ts; } } return numberType; - case 35 /* PlusToken */: - case 57 /* PlusEqualsToken */: + case 36 /* PlusToken */: + case 58 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35110,24 +35437,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57 /* PlusEqualsToken */) { + if (operator === 58 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -35138,22 +35465,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90 /* InKeyword */: + case 91 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 1048576 /* Truthy */ ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return getTypeFacts(leftType) & 2097152 /* Falsy */ ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24 /* CommaToken */: + case 25 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -35172,21 +35499,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 47 /* BarToken */: - case 67 /* BarEqualsToken */: - return 52 /* BarBarToken */; - case 48 /* CaretToken */: - case 68 /* CaretEqualsToken */: - return 33 /* ExclamationEqualsEqualsToken */; - case 46 /* AmpersandToken */: - case 66 /* AmpersandEqualsToken */: - return 51 /* AmpersandAmpersandToken */; + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + return 53 /* BarBarToken */; + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + return 34 /* ExclamationEqualsEqualsToken */; + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: + return 52 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (produceDiagnostics && operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -35273,9 +35600,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32 /* StringLiteral */, node.text)); case 8 /* NumericLiteral */: return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, node.text)); - case 99 /* TrueKeyword */: + case 100 /* TrueKeyword */: return trueType; - case 84 /* FalseKeyword */: + case 85 /* FalseKeyword */: return falseType; } } @@ -35312,7 +35639,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 /* TypeAssertionExpression */ || node.kind === 195 /* AsExpression */; + return node.kind === 178 /* TypeAssertionExpression */ || node.kind === 196 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35344,7 +35671,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -35355,7 +35682,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -35385,7 +35712,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139 /* QualifiedName */) { + if (node.kind === 140 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -35397,9 +35724,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -35408,79 +35735,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return checkIdentifier(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return checkThisExpression(node); - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return checkSuperExpression(node); - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullWideningType; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return checkTemplateExpression(node); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return stringType; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return checkCallExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return checkClassExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return checkAssertion(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return checkNonNullAssertion(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkDeleteExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return checkVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return checkAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return undefinedWideningType; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return checkYieldExpression(node); case 248 /* JsxExpression */: return checkJsxExpression(node); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return checkJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -35508,7 +35835,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -35519,7 +35846,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 /* Constructor */ || func.kind === 152 /* ConstructSignature */ || func.kind === 157 /* ConstructorType */) { + if (func.kind === 149 /* Constructor */ || func.kind === 153 /* ConstructSignature */ || func.kind === 158 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -35533,15 +35860,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 /* MethodDeclaration */ || - node.kind === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */; + return node.kind === 148 /* MethodDeclaration */ || + node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 /* Identifier */ && + if (param.name.kind === 70 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -35593,13 +35920,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 180 /* ArrowFunction */: - case 151 /* CallSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 156 /* FunctionType */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 181 /* ArrowFunction */: + case 152 /* CallSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 157 /* FunctionType */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -35613,13 +35940,13 @@ var ts; continue; } var name_19 = element.name; - if (name_19.kind === 69 /* Identifier */ && + if (name_19.kind === 70 /* Identifier */ && name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 168 /* ArrayBindingPattern */ || - name_19.kind === 167 /* ObjectBindingPattern */) { + else if (name_19.kind === 169 /* ArrayBindingPattern */ || + name_19.kind === 168 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } @@ -35628,12 +35955,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 /* FunctionType */ || node.kind === 220 /* FunctionDeclaration */ || node.kind === 157 /* ConstructorType */ || - node.kind === 151 /* CallSignature */ || node.kind === 148 /* Constructor */ || - node.kind === 152 /* ConstructSignature */) { + else if (node.kind === 157 /* FunctionType */ || node.kind === 221 /* FunctionDeclaration */ || node.kind === 158 /* ConstructorType */ || + node.kind === 152 /* CallSignature */ || node.kind === 149 /* Constructor */ || + node.kind === 153 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -35645,16 +35972,16 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 /* ES6 */ && isSyntacticallyValidGenerator(node)) { + if (languageVersion >= 2 /* ES2015 */ && isSyntacticallyValidGenerator(node)) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -35691,7 +36018,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -35700,18 +36027,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113 /* StaticKeyword */; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; } @@ -35737,12 +36064,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144 /* PropertySignature */) { + if (member.kind == 145 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: memberName = member.name.text; break; default: @@ -35759,7 +36086,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222 /* InterfaceDeclaration */) { + if (node.kind === 223 /* 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 @@ -35779,7 +36106,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -35787,7 +36114,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -35852,15 +36179,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97 /* ThisKeyword */) { + if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 /* FunctionExpression */ && n.kind !== 220 /* FunctionDeclaration */) { + else if (n.kind !== 180 /* FunctionExpression */ && n.kind !== 221 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 /* PropertyDeclaration */ && + return n.kind === 146 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -35890,7 +36217,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -35914,7 +36241,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -35924,13 +36251,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = node.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -35946,11 +36273,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 172 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36040,9 +36367,9 @@ 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 !== 222 /* InterfaceDeclaration */ && - n.parent.kind !== 221 /* ClassDeclaration */ && - n.parent.kind !== 192 /* ClassExpression */ && + if (n.parent.kind !== 223 /* InterfaceDeclaration */ && + n.parent.kind !== 222 /* ClassDeclaration */ && + n.parent.kind !== 193 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36130,7 +36457,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */) && + var reportError = (node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -36169,7 +36496,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 /* InterfaceDeclaration */ || node.parent.kind === 159 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 /* InterfaceDeclaration */ || node.parent.kind === 160 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -36180,7 +36507,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 === 220 /* FunctionDeclaration */ || node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */ || node.kind === 148 /* Constructor */) { + if (node.kind === 221 /* FunctionDeclaration */ || node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */ || node.kind === 149 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36302,16 +36629,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -36515,7 +36842,7 @@ var ts; * callable `then` signature. */ function checkAsyncFunctionReturnType(node) { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { var returnType = getTypeFromTypeNode(node.type); return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); } @@ -36594,22 +36921,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142 /* Parameter */: + case 143 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -36622,9 +36949,9 @@ var ts; // When we are emitting type metadata for decorators, we need to try to check the type // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 155 /* TypeReference */) { + if (node && node.kind === 156 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = root.parent.kind === 156 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; // Resolve type so we know which symbol is referenced var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); // Resolved symbol is alias @@ -36671,20 +36998,20 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } @@ -36707,7 +37034,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 141 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -36768,42 +37095,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256 /* SourceFile */: - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -36812,11 +37139,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142 /* Parameter */) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143 /* Parameter */) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -36836,19 +37163,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; + return parameter.name && parameter.name.kind === 70 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 /* MethodDeclaration */ || member.kind === 145 /* PropertyDeclaration */) { + if (member.kind === 148 /* MethodDeclaration */ || member.kind === 146 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148 /* Constructor */) { + else if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -36896,7 +37223,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 199 /* Block */) { + if (node.kind === 200 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -36919,12 +37246,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 144 /* PropertySignature */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 146 /* MethodSignature */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 145 /* PropertySignature */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 147 /* MethodSignature */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -36933,7 +37260,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -36949,7 +37276,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 69 /* Identifier */; + var isDeclaration_1 = node.kind !== 70 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -36972,7 +37299,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69 /* Identifier */; + var isDeclaration_2 = node.kind !== 70 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -36983,14 +37310,14 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37005,7 +37332,7 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37045,7 +37372,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 === 218 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 219 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37055,16 +37382,16 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 200 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 201 /* 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 === 199 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 226 /* ModuleBlock */ || - container.kind === 225 /* ModuleDeclaration */ || + (container.kind === 200 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 227 /* ModuleBlock */ || + container.kind === 226 /* ModuleDeclaration */ || container.kind === 256 /* 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 @@ -37080,7 +37407,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 143 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -37091,11 +37418,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 172 /* PropertyAccessExpression */) { + if (n.kind === 173 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 69 /* Identifier */) { + else if (n.kind === 70 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -37110,7 +37437,7 @@ 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 === 142 /* Parameter */) { + if (symbol.valueDeclaration.kind === 143 /* Parameter */) { // 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) { @@ -37124,7 +37451,7 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 145 /* PropertyDeclaration */ && + if (current.parent.kind === 146 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; @@ -37141,7 +37468,7 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { @@ -37151,15 +37478,15 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169 /* BindingElement */) { + if (node.kind === 170 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 140 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -37176,14 +37503,14 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 142 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // 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 !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37194,7 +37521,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 !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37214,10 +37541,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */) { + if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */) { + if (node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37227,8 +37554,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 /* Parameter */ && right.kind === 218 /* VariableDeclaration */) || - (left.kind === 218 /* VariableDeclaration */ && right.kind === 142 /* Parameter */)) { + if ((left.kind === 143 /* Parameter */ && right.kind === 219 /* VariableDeclaration */) || + (left.kind === 219 /* VariableDeclaration */ && right.kind === 143 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37258,7 +37585,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 171 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37279,7 +37606,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201 /* EmptyStatement */) { + if (node.thenStatement.kind === 202 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37299,12 +37626,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 220 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37327,14 +37654,14 @@ 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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -37366,7 +37693,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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* 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); @@ -37380,7 +37707,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */)) { @@ -37418,7 +37745,7 @@ var ts; if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { return checkElementTypeOfIterable(inputType, errorNode); } if (allowStringInput) { @@ -37578,7 +37905,7 @@ var ts; * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). */ function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2 /* ES6 */); + ts.Debug.assert(languageVersion < 2 /* ES2015 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. var arrayType = arrayOrStringType; @@ -37630,7 +37957,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150 /* SetAccessor */))); + return !!(node.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -37657,12 +37984,12 @@ var ts; // for generators. return; } - if (func.kind === 150 /* SetAccessor */) { + if (func.kind === 151 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148 /* Constructor */) { + else if (func.kind === 149 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -37683,7 +38010,7 @@ var ts; } } } - else if (func.kind !== 148 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -37749,7 +38076,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 215 /* 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; @@ -37779,7 +38106,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 70 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -37854,7 +38181,7 @@ var ts; // 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 var errorNode; - if (prop.valueDeclaration.name.kind === 140 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -37912,7 +38239,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 /* ClassDeclaration */ || declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 222 /* ClassDeclaration */ || declaration.kind === 223 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38076,7 +38403,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 192 /* ClassExpression */) { + if (derivedClassDecl.kind === 193 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38124,7 +38451,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 /* GetAccessor */ || kind === 150 /* SetAccessor */; + return kind === 150 /* GetAccessor */ || kind === 151 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -38196,7 +38523,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38302,18 +38629,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35 /* PlusToken */: return value_1; - case 36 /* MinusToken */: return -value_1; - case 50 /* TildeToken */: return ~value_1; + case 36 /* PlusToken */: return value_1; + case 37 /* MinusToken */: return -value_1; + case 51 /* TildeToken */: return ~value_1; } return undefined; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38323,31 +38650,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 47 /* BarToken */: return left | right; - case 46 /* AmpersandToken */: return left & right; - case 44 /* GreaterThanGreaterThanToken */: return left >> right; - case 45 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 43 /* LessThanLessThanToken */: return left << right; - case 48 /* CaretToken */: return left ^ right; - case 37 /* AsteriskToken */: return left * right; - case 39 /* SlashToken */: return left / right; - case 35 /* PlusToken */: return left + right; - case 36 /* MinusToken */: return left - right; - case 40 /* PercentToken */: return left % right; + case 48 /* BarToken */: return left | right; + case 47 /* AmpersandToken */: return left & right; + case 45 /* GreaterThanGreaterThanToken */: return left >> right; + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 44 /* LessThanLessThanToken */: return left << right; + case 49 /* CaretToken */: return left ^ right; + case 38 /* AsteriskToken */: return left * right; + case 40 /* SlashToken */: return left / right; + case 36 /* PlusToken */: return left + right; + case 37 /* MinusToken */: return left - right; + case 41 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 69 /* Identifier */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -38355,7 +38682,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 173 /* ElementAccessExpression */) { + if (e.kind === 174 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38370,10 +38697,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 69 /* Identifier */) { + if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 172 /* PropertyAccessExpression */) { + else if (current.kind === 173 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -38445,7 +38772,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 !== 224 /* EnumDeclaration */) { + if (declaration.kind !== 225 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -38468,8 +38795,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 === 221 /* ClassDeclaration */ || - (declaration.kind === 220 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 /* ClassDeclaration */ || + (declaration.kind === 221 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -38533,7 +38860,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, 221 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 222 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -38584,23 +38911,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* 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 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var name_22 = node.name; if (ts.isBindingPattern(name_22)) { for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { @@ -38611,12 +38938,12 @@ var ts; break; } // fallthrough - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 220 /* FunctionDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -38637,17 +38964,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; } } @@ -38657,9 +38984,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 /* ExportDeclaration */ ? + error(moduleName, node.kind === 237 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -38692,7 +39019,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 === 238 /* ExportSpecifier */ ? + var message = node.kind === 239 /* 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)); @@ -38720,7 +39047,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -38757,7 +39084,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.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); } @@ -38777,7 +39104,7 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -38792,7 +39119,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 225 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 226 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -38819,7 +39146,7 @@ var ts; return; } var container = node.parent.kind === 256 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 225 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (container.kind === 226 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -38827,7 +39154,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { markExportAsReferenced(node); } else { @@ -38835,7 +39162,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -38894,7 +39221,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 /* FunctionDeclaration */ && declaration.kind !== 147 /* MethodDeclaration */) || + return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || !!declaration.body; } } @@ -38907,118 +39234,118 @@ 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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return checkTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return checkParameter(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return checkPropertyDeclaration(node); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return checkSignatureDeclaration(node); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return checkMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return checkConstructorDeclaration(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return checkAccessorDeclaration(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return checkTypeReferenceNode(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return checkTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return checkTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return checkArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return checkTupleType(node); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return checkSourceElement(node.type); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return checkBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return checkVariableStatement(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return checkExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return checkIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return checkDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return checkWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return checkForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return checkForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkForOfStatement(node); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return checkReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return checkSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return checkLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return checkThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return checkTryStatement(node); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return checkBindingElement(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return checkClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return checkImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return checkExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return checkExportAssignment(node); - case 201 /* EmptyStatement */: + case 202 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39040,17 +39367,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkAccessorDeferred(node); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39131,7 +39458,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 213 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39158,21 +39485,21 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* 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. @@ -39181,7 +39508,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39224,34 +39551,34 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 /* Identifier */ && + return name.kind === 70 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141 /* TypeParameter */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 142 /* TypeParameter */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139 /* QualifiedName */) { + while (node.parent && node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 155 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 156 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 194 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39268,13 +39595,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 140 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 230 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39286,7 +39613,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39298,15 +39625,15 @@ var ts; default: } } - if (entityName.parent.kind === 235 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 172 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 173 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 229 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 230 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; @@ -39314,7 +39641,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 194 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 195 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39332,20 +39659,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 172 /* PropertyAccessExpression */) { + else if (entityName.kind === 173 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139 /* QualifiedName */) { + else if (entityName.kind === 140 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -39354,13 +39681,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 156 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } else if (entityName.parent.kind === 246 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154 /* TypePredicate */) { + if (entityName.parent.kind === 155 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -39381,12 +39708,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 /* BindingElement */ && - node.parent.parent.kind === 167 /* ObjectBindingPattern */ && + else if (node.parent.kind === 170 /* BindingElement */ && + node.parent.parent.kind === 168 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -39396,11 +39723,11 @@ var ts; } } switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -39409,15 +39736,15 @@ var ts; } } // fallthrough - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165 /* ThisType */: + case 166 /* ThisType */: return getTypeFromTypeNode(node).symbol; - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 149 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -39425,7 +39752,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 === 230 /* ImportDeclaration */ || node.parent.kind === 236 /* ExportDeclaration */) && + ((node.parent.kind === 231 /* ImportDeclaration */ || node.parent.kind === 237 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -39435,7 +39762,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -39514,17 +39841,17 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 /* ObjectLiteralExpression */ || expr.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 172 /* ObjectLiteralExpression */ || expr.kind === 171 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 208 /* ForOfStatement */) { + if (expr.parent.kind === 209 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 187 /* BinaryExpression */) { + if (expr.parent.kind === 188 /* BinaryExpression */) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -39535,7 +39862,7 @@ var ts; return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 171 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -39724,7 +40051,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 === 199 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 200 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -39770,18 +40097,18 @@ var ts; return true; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.expression - && node.expression.kind === 69 /* Identifier */ + && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -40043,7 +40370,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 172 /* PropertyAccessExpression */) || (node.kind === 69 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 173 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40192,7 +40519,7 @@ var ts; getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", /*arity*/ 1); }); getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", /*arity*/ 1); }); @@ -40205,6 +40532,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -40218,7 +40546,7 @@ var ts; // If we found the module, report errors if it does not have the necessary exports. if (helpersModule) { var exports = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES6 */) { + if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__extends", 107455 /* Value */); } if (requestedExternalEmitHelpers & 16384 /* HasJsxSpreadAttributes */ && compilerOptions.jsx !== 1 /* Preserve */) { @@ -40235,7 +40563,7 @@ var ts; } if (requestedExternalEmitHelpers & 8192 /* HasAsyncFunctions */) { verifyHelperSymbol(exports, "__awaiter", 107455 /* Value */); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__generator", 107455 /* Value */); } } @@ -40272,14 +40600,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */) { + else if (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -40296,28 +40624,28 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128 /* ReadonlyKeyword */) { - if (node.kind === 144 /* PropertySignature */ || node.kind === 146 /* MethodSignature */) { + if (modifier.kind !== 129 /* ReadonlyKeyword */) { + if (node.kind === 145 /* PropertySignature */ || node.kind === 147 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74 /* ConstKeyword */: - if (node.kind !== 224 /* EnumDeclaration */ && node.parent.kind === 221 /* ClassDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); + case 75 /* ConstKeyword */: + if (node.kind !== 225 /* EnumDeclaration */ && node.parent.kind === 222 /* ClassDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; - case 112 /* PublicKeyword */: - case 111 /* ProtectedKeyword */: - case 110 /* PrivateKeyword */: + case 113 /* PublicKeyword */: + case 112 /* ProtectedKeyword */: + case 111 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111 /* ProtectedKeyword */) { + if (modifier.kind === 112 /* ProtectedKeyword */) { lastProtected = modifier; } - else if (modifier.kind === 110 /* PrivateKeyword */) { + else if (modifier.kind === 111 /* PrivateKeyword */) { lastPrivate = modifier; } if (flags & 28 /* AccessibilityModifier */) { @@ -40332,11 +40660,11 @@ 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 === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 110 /* PrivateKeyword */) { + if (modifier.kind === 111 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -40345,7 +40673,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -40355,10 +40683,10 @@ 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 === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -40367,18 +40695,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 128 /* ReadonlyKeyword */: + case 129 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */ && node.kind !== 153 /* IndexSignature */ && node.kind !== 142 /* Parameter */) { + else if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */ && node.kind !== 154 /* IndexSignature */ && node.kind !== 143 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -40391,45 +40719,45 @@ 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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } 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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221 /* ClassDeclaration */) { - if (node.kind !== 147 /* MethodDeclaration */ && - node.kind !== 145 /* PropertyDeclaration */ && - node.kind !== 149 /* GetAccessor */ && - node.kind !== 150 /* SetAccessor */) { + if (node.kind !== 222 /* ClassDeclaration */) { + if (node.kind !== 148 /* MethodDeclaration */ && + node.kind !== 146 /* PropertyDeclaration */ && + node.kind !== 150 /* GetAccessor */ && + node.kind !== 151 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 222 /* 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 */) { @@ -40441,14 +40769,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 118 /* AsyncKeyword */: + case 119 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -40456,7 +40784,7 @@ var ts; break; } } - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -40471,13 +40799,13 @@ var ts; } return; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -40497,38 +40825,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 225 /* ModuleDeclaration */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 142 /* Parameter */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 226 /* ModuleDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 143 /* Parameter */: return false; default: - if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return false; } switch (node.kind) { - case 220 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 118 /* AsyncKeyword */); - case 221 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 115 /* AbstractKeyword */); - case 222 /* InterfaceDeclaration */: - case 200 /* VariableStatement */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); + case 222 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); + case 223 /* InterfaceDeclaration */: + case 201 /* VariableStatement */: + case 224 /* TypeAliasDeclaration */: return true; - case 224 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 74 /* ConstKeyword */); + case 225 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -40540,10 +40868,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -40559,7 +40887,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -40602,11 +40930,11 @@ var ts; function checkGrammarFunctionLikeDeclaration(node) { // Prevent cascading error by short-circuit var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180 /* ArrowFunction */) { + if (node.kind === 181 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -40641,7 +40969,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 132 /* StringKeyword */ && parameter.type.kind !== 130 /* NumberKeyword */) { + if (parameter.type.kind !== 133 /* StringKeyword */ && parameter.type.kind !== 131 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -40669,7 +40997,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193 /* OmittedExpression */) { + if (arg.kind === 194 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -40695,7 +41023,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -40708,7 +41036,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -40724,14 +41052,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -40742,31 +41070,31 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 140 /* ComputedPropertyName */) { + if (node.kind !== 141 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 188 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -40780,7 +41108,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (name_24.kind === 140 /* ComputedPropertyName */) { + if (name_24.kind === 141 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_24); } @@ -40793,7 +41121,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 147 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 148 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -40809,19 +41137,19 @@ var ts; var currentKind = void 0; if (prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_24.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147 /* MethodDeclaration */) { + else if (prop.kind === 148 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 149 /* GetAccessor */) { + else if (prop.kind === 150 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 150 /* SetAccessor */) { + else if (prop.kind === 151 /* SetAccessor */) { currentKind = SetAccessor; } else { @@ -40878,7 +41206,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -40893,20 +41221,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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); @@ -40930,11 +41258,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 150 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150 /* SetAccessor */) { + else if (kind === 151 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -40957,10 +41285,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -40975,8 +41303,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171 /* ObjectLiteralExpression */) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -40996,10 +41324,10 @@ 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 === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* 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 === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -41010,11 +41338,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214 /* LabeledStatement */: + case 215 /* 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 === 209 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 210 /* 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); @@ -41022,8 +41350,8 @@ var ts; return false; } break; - case 213 /* SwitchStatement */: - if (node.kind === 210 /* BreakStatement */ && !node.label) { + case 214 /* SwitchStatement */: + if (node.kind === 211 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41038,13 +41366,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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 === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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); @@ -41056,7 +41384,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); } - if (node.name.kind === 168 /* ArrayBindingPattern */ || node.name.kind === 167 /* ObjectBindingPattern */) { + if (node.name.kind === 169 /* ArrayBindingPattern */ || node.name.kind === 168 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -41067,11 +41395,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 /* ForInStatement */ && node.parent.parent.kind !== 208 /* ForOfStatement */) { + if (node.parent.parent.kind !== 208 /* ForInStatement */ && node.parent.parent.kind !== 209 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41110,8 +41438,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69 /* Identifier */) { - if (name.originalKeywordKind === 108 /* LetKeyword */) { + if (name.kind === 70 /* Identifier */) { + if (name.originalKeywordKind === 109 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -41136,15 +41464,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return false; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41199,7 +41527,7 @@ var ts; return true; } } - else if (node.parent.kind === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41207,7 +41535,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41232,13 +41560,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 222 /* InterfaceDeclaration */ || - node.kind === 223 /* TypeAliasDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 236 /* ExportDeclaration */ || - node.kind === 235 /* ExportAssignment */ || - node.kind === 228 /* NamespaceExportDeclaration */ || + if (node.kind === 223 /* InterfaceDeclaration */ || + node.kind === 224 /* TypeAliasDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 237 /* ExportDeclaration */ || + node.kind === 236 /* ExportAssignment */ || + node.kind === 229 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41247,7 +41575,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 === 200 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 201 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41273,7 +41601,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 === 199 /* Block */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 200 /* Block */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41333,46 +41661,46 @@ var ts; * significantly impacted. */ var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139 /* QualifiedName */] = [ + _a[140 /* QualifiedName */] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143 /* Decorator */] = [ + _a[144 /* Decorator */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177 /* TypeAssertionExpression */] = [ + _a[178 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195 /* AsExpression */] = [ + _a[196 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196 /* NonNullExpression */] = [ + _a[197 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224 /* EnumDeclaration */] = [ + _a[225 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225 /* ModuleDeclaration */] = [ + _a[226 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226 /* ModuleBlock */] = [ + _a[227 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[229 /* ImportEqualsDeclaration */] = [ + _a[230 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240 /* ExternalModuleReference */] = [ + _a[241 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255 /* EnumMember */] = [ @@ -41398,47 +41726,47 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: case 287 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: result = reduceNode(node.expression, f, result); break; // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 143 /* Decorator */: + case 144 /* Decorator */: result = reduceNode(node.expression, f, result); break; // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41447,12 +41775,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148 /* Constructor */: + case 149 /* Constructor */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41460,7 +41788,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41468,45 +41796,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 169 /* BindingElement */: + case 170 /* BindingElement */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 175 /* NewExpression */: + case 176 /* NewExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -41514,119 +41842,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178 /* ParenthesizedExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 184 /* AwaitExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: - case 196 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 185 /* AwaitExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: + case 197 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 199 /* Block */: + case 200 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 205 /* WhileStatement */: - case 212 /* WithStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41635,7 +41963,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41643,50 +41971,50 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -41841,163 +42169,163 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return node; } switch (node.kind) { - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return ts.updateMethod(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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 148 /* Constructor */: + case 149 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 179 /* FunctionExpression */: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); + case 181 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, /*optional*/ true), context.endLexicalEnvironment())); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return ts.updateClassExpression(node, 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 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 199 /* Block */: + case 200 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* IfStatement */: + case 204 /* 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 204 /* DoStatement */: + case 205 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 206 /* ForStatement */: + case 207 /* 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 207 /* ForInStatement */: + case 208 /* 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 208 /* ForOfStatement */: + case 209 /* 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 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216 /* TryStatement */: + case 217 /* 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 218 /* VariableDeclaration */: + case 219 /* 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 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 220 /* FunctionDeclaration */: + case 221 /* 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), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 221 /* ClassDeclaration */: + case 222 /* 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 227 /* CaseBlock */: + case 228 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230 /* ImportDeclaration */: + case 231 /* 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 231 /* ImportClause */: + case 232 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* ExportDeclaration */: + case 237 /* 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 237 /* NamedExports */: + case 238 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -42142,67 +42470,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) { + if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 170 /* ArrayLiteralExpression */: - return 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - case 225 /* ModuleDeclaration */: - return 546335573 /* ModuleExcludes */; - case 142 /* Parameter */: - return 538968917 /* ParameterExcludes */; - case 180 /* ArrowFunction */: - return 550710101 /* ArrowFunctionExcludes */; - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - return 550726485 /* FunctionExcludes */; - case 219 /* VariableDeclarationList */: - return 538968917 /* VariableDeclarationListExcludes */; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - return 537590613 /* ClassExcludes */; - case 148 /* Constructor */: - return 550593365 /* ConstructorExcludes */; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return 550593365 /* MethodOrAccessorExcludes */; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 171 /* ArrayLiteralExpression */: + return 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + case 226 /* ModuleDeclaration */: + return 574729557 /* ModuleExcludes */; + case 143 /* Parameter */: + return 545262933 /* ParameterExcludes */; + case 181 /* ArrowFunction */: + return 592227669 /* ArrowFunctionExcludes */; + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + return 592293205 /* FunctionExcludes */; + case 220 /* VariableDeclarationList */: + return 545262933 /* VariableDeclarationListExcludes */; + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + return 539749717 /* ClassExcludes */; + case 149 /* Constructor */: + return 591760725 /* ConstructorExcludes */; + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return 591760725 /* MethodOrAccessorExcludes */; + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 171 /* ObjectLiteralExpression */: - return 537430869 /* ObjectLiteralExcludes */; + case 172 /* ObjectLiteralExpression */: + return 539110741 /* ObjectLiteralExcludes */; default: - return 536871765 /* NodeExcludes */; + return 536874325 /* NodeExcludes */; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1 /* Normal */) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -42264,7 +42592,7 @@ var ts; // location should point to the right-hand value of the expression. location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -42293,9 +42621,9 @@ var ts; * @param value The rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); @@ -42319,10 +42647,10 @@ var ts; * @param value An optional rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -42364,9 +42692,9 @@ var ts; * @param nameSubstitution An optional callback used to substitute binding names. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -42390,7 +42718,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -42412,7 +42740,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56 /* EqualsToken */) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57 /* EqualsToken */) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -42422,10 +42750,10 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171 /* ObjectLiteralExpression */) { + if (target.kind === 172 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170 /* ArrayLiteralExpression */) { + else if (target.kind === 171 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, location); } else { @@ -42464,9 +42792,9 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193 /* OmittedExpression */) { + if (e.kind !== 194 /* OmittedExpression */) { // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 191 /* SpreadElementExpression */) { + if (e.kind !== 192 /* SpreadElementExpression */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -42502,7 +42830,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167 /* ObjectBindingPattern */) { + else if (name.kind === 168 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); @@ -42524,7 +42852,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53 /* QuestionToken */), defaultValue, ts.createToken(54 /* ColonToken */), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54 /* QuestionToken */), defaultValue, ts.createToken(55 /* ColonToken */), value); } /** * Creates either a PropertyAccessExpression or an ElementAccessExpression for the @@ -42594,8 +42922,6 @@ var ts; TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; /** Enables substitutions for namespace exports. */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; - /** Enables substitutions for async methods with `super` calls. */ - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["AsyncMethodsWithSuper"] = 4] = "AsyncMethodsWithSuper"; /* Enables substitutions for unqualified enum members */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); @@ -42612,8 +42938,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -42636,11 +42962,6 @@ var ts; * just-in-time substitution while printing an expression identifier. */ var applicableSubstitutions; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - var currentSuperContainer; return transformSourceFile; /** * Transform TypeScript-specific syntax in a SourceFile. @@ -42699,6 +43020,33 @@ var ts; } return node; } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } /** * Specialized visitor that visits the immediate children of a namespace. * @@ -42713,11 +43061,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 236 /* ExportDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 231 /* ImportClause */ || - (node.kind === 229 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 240 /* ExternalModuleReference */)) { + if (node.kind === 237 /* ExportDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 232 /* ImportClause */ || + (node.kind === 230 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 241 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -42747,19 +43095,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 145 /* PropertyDeclaration */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + case 146 /* PropertyDeclaration */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 198 /* SemicolonClassElement */: + case 199 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -42778,57 +43126,55 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82 /* ExportKeyword */: - case 77 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 122 /* DeclareKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 129 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 159 /* TypeLiteral */: - case 154 /* TypePredicate */: - case 141 /* TypeParameter */: - case 117 /* AnyKeyword */: - case 120 /* BooleanKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 103 /* VoidKeyword */: - case 133 /* SymbolKeyword */: - case 157 /* ConstructorType */: - case 156 /* FunctionType */: - case 158 /* TypeQuery */: - case 155 /* TypeReference */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 160 /* TypeLiteral */: + case 155 /* TypePredicate */: + case 142 /* TypeParameter */: + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 104 /* VoidKeyword */: + case 134 /* SymbolKeyword */: + case 158 /* ConstructorType */: + case 157 /* FunctionType */: + case 159 /* TypeQuery */: + case 156 /* TypeReference */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // TypeScript type nodes are elided. - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: // TypeScript index signatures are elided. - case 143 /* Decorator */: + case 144 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // TypeScript property declarations are elided. - case 148 /* Constructor */: - // TypeScript constructors are transformed in `visitClassDeclaration`. - return undefined; - case 222 /* InterfaceDeclaration */: + case 149 /* Constructor */: + return visitConstructor(node); + case 223 /* 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 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42838,9 +43184,8 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassDeclaration(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42850,7 +43195,6 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassExpression(node); case 251 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. @@ -42858,29 +43202,29 @@ var ts; // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 147 /* MethodDeclaration */: - // TypeScript method declarations may be 'async', and may have decorators, modifiers + case 148 /* MethodDeclaration */: + // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 150 /* SetAccessor */: - // Set Accessors can have TypeScript modifiers, decorators, and type annotations. + case 151 /* SetAccessor */: + // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 220 /* FunctionDeclaration */: - // TypeScript function declarations may be 'async' + case 221 /* FunctionDeclaration */: + // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: - // TypeScript function expressions may be 'async' + case 180 /* FunctionExpression */: + // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 180 /* ArrowFunction */: - // TypeScript arrow functions may be 'async' + case 181 /* ArrowFunction */: + // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 142 /* Parameter */: + case 143 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -42890,30 +43234,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 196 /* NonNullExpression */: + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 197 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 184 /* AwaitExpression */: - // TypeScript 'await' expressions must be transformed. - return visitAwaitExpression(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 225 /* ModuleDeclaration */: + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 226 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -42929,14 +43276,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: - case 226 /* ModuleBlock */: - case 199 /* Block */: + case 228 /* CaseBlock */: + case 227 /* ModuleBlock */: + case 200 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 221 /* ClassDeclaration */: - case 220 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -42967,14 +43314,14 @@ var ts; externalHelpersModuleImport.flags &= ~8 /* Synthesized */; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 /* EmitEmitHelpers */ | ts.getEmitFlags(node)); return node; @@ -43048,7 +43395,7 @@ var ts; // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); } // Write any decorators of the node. addClassElementDecorationStatements(statements, node, /*isStatic*/ false); @@ -43224,7 +43571,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); var classExpression = ts.setOriginalNode(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members, @@ -43241,7 +43588,7 @@ var ts; // the body of a class with static initializers. ts.setEmitFlags(classExpression, 524288 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -43273,7 +43620,7 @@ var ts; // If there is a property assignment, we need to emit constructor whether users define it or not // If there is no property assignment, we can omit constructor if users do not define it var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072 /* ContainsParameterPropertyAssignments */; + var hasParameterPropertyAssignments = node.transformFlags & 524288 /* ContainsParameterPropertyAssignments */; var constructor = ts.getFirstConstructorWithBody(node); // If the class does not contain nodes that require a synthesized constructor, // accept the current constructor if it exists. @@ -43281,7 +43628,7 @@ var ts; return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); // constructor(${parameters}) { // ${body} // } @@ -43324,9 +43671,8 @@ var ts; * @param node The current class. * @param constructor The current class constructor. * @param hasExtendsClause A value indicating whether the class has an extends clause. - * @param parameters The transformed parameters for the constructor. */ - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; // The body of a constructor is a new lexical environment @@ -43367,7 +43713,7 @@ var ts; // } // var properties = getInitializedProperties(node, /*isStatic*/ false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { // The class already had a constructor, so we should add the existing statements, skipping the initial super call. ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -43394,7 +43740,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -43467,21 +43813,20 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 145 /* PropertyDeclaration */ + return member.kind === 146 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } /** * Generates assignment statements for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -43490,15 +43835,14 @@ var ts; /** * Generates assignment expressions for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -43509,11 +43853,10 @@ var ts; /** * Transforms a property initializer into an assignment statement. * - * @param node The class containing the property. * @param property The property declaration. * @param receiver The object receiving the property assignment. */ - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); @@ -43605,12 +43948,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -43762,7 +44105,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 145 /* PropertyDeclaration */ + ? member.kind === 146 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -43895,10 +44238,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 145 /* PropertyDeclaration */; + return kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -43908,7 +44251,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -43919,11 +44262,11 @@ var ts; */ function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; + return kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -43932,15 +44275,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: - case 149 /* GetAccessor */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: + case 150 /* GetAccessor */: return serializeTypeNode(node.type); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 148 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -43953,10 +44296,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 160 /* ArrayType */) { + if (node && node.kind === 161 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 155 /* TypeReference */) { + else if (node && node.kind === 156 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -44030,45 +44373,45 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return ts.createVoidZero(); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return ts.createIdentifier("Function"); - case 160 /* ArrayType */: - case 161 /* TupleType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: return ts.createIdentifier("Array"); - case 154 /* TypePredicate */: - case 120 /* BooleanKeyword */: + case 155 /* TypePredicate */: + case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return ts.createIdentifier("String"); - case 166 /* LiteralType */: + case 167 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 133 /* SymbolKeyword */: - return languageVersion < 2 /* ES6 */ + case 134 /* SymbolKeyword */: + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return serializeTypeReferenceNode(node); - case 163 /* IntersectionType */: - case 162 /* UnionType */: + case 164 /* IntersectionType */: + case 163 /* UnionType */: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -44076,7 +44419,7 @@ var ts; var typeNode = _a[_i]; var serializedIndividual = serializeTypeNode(typeNode); // Non identifier - if (serializedIndividual.kind !== 69 /* Identifier */) { + if (serializedIndividual.kind !== 70 /* Identifier */) { serializedUnion = undefined; break; } @@ -44097,10 +44440,10 @@ var ts; } } // Fallthrough - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 117 /* AnyKeyword */: - case 165 /* ThisType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 118 /* AnyKeyword */: + case 166 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44133,7 +44476,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES6 */ + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -44154,7 +44497,7 @@ var ts; */ function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name_27 = ts.getMutableClone(node); @@ -44165,7 +44508,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } return name_27; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -44178,7 +44521,7 @@ var ts; */ function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69 /* Identifier */) { + if (node.left.kind === 70 /* Identifier */) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -44195,7 +44538,7 @@ var ts; * available. */ function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(54 /* ColonToken */), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(55 /* ColonToken */), ts.createIdentifier("Object")); } /** * Gets an expression that represents a property name. For a computed property, a @@ -44249,9 +44592,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 83 /* ExtendsKeyword */) { + if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83 /* ExtendsKeyword */, types, node); + return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); } return undefined; } @@ -44277,12 +44620,18 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a method declaration of a class. * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked as abstract, async, public, private, protected, or readonly + * - The node is marked as abstract, public, private, protected, or readonly * - The node has both a decorator and a computed property name * * @param node The method node. @@ -44364,8 +44713,8 @@ var ts; * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked async * - The node is exported from a TypeScript namespace + * - The node has decorators * * @param node The function node. */ @@ -44390,7 +44739,7 @@ var ts; * Visits a function expression node. * * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations * * @param node The function expression node. */ @@ -44398,7 +44747,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44408,11 +44757,10 @@ var ts; /** * @remarks * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations */ function visitArrowFunction(node) { - var func = ts.createArrowFunction( - /*modifiers*/ undefined, + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), /*location*/ node); @@ -44420,26 +44768,23 @@ var ts; return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -44461,49 +44806,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 /* ES6 */ ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; - // An async function is emit as an outer function that calls an inner - // generator function. To preserve lexical bindings, we pass the current - // `this` and `arguments` objects to `__awaiter`. The generator function - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= 2 /* ES6 */) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); - } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4 /* EmitSuperHelper */); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); - } - } /** * Visits a parameter declaration node. * @@ -44555,24 +44857,16 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), /*location*/ node); } } - /** - * Visits an await expression. - * - * This function will be called any time a TypeScript await expression is encountered. - * - * @param node The await expression node. - */ - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } /** * Visits a parenthesized expression that contains either a type assertion or an `as` @@ -44611,6 +44905,14 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } /** * Determines whether to emit an enum declaration. * @@ -44673,6 +44975,7 @@ var ts; // ... // })(x || (x = {})); var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44748,7 +45051,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } /** * Records that a declaration was emitted in the current scope, if it was the first @@ -44796,7 +45099,7 @@ var ts; ]); ts.setOriginalNode(statement, /*original*/ node); // Adjust the source map emit to match the old emitter. - if (node.kind === 224 /* EnumDeclaration */) { + if (node.kind === 225 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -44871,6 +45174,7 @@ var ts; // x_1.y = ...; // })(x || (x = {})); var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44899,7 +45203,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226 /* ModuleBlock */) { + if (body.kind === 227 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -44945,17 +45249,127 @@ 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 !== 226 /* ModuleBlock */) { + if (body.kind !== 227 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + /** + * Visits an import declaration, eliding it if it is not referenced. + * + * @param node The import declaration node. + */ + function visitImportDeclaration(node) { + if (!node.importClause) { + // Do not elide a side-effect only import declaration. + // import "foo"; + return node; + } + // Elide the declaration if the import clause was elided. + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, /*optional*/ true); + return importClause + ? ts.updateImportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, importClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits an import clause, eliding it if it is not referenced. + * + * @param node The import clause node. + */ + function visitImportClause(node) { + // Elide the import clause if we elide both its name and its named bindings. + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, /*optional*/ true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + /** + * Visits named import bindings, eliding it if it is not referenced. + * + * @param node The named import bindings node. + */ + function visitNamedImportBindings(node) { + if (node.kind === 233 /* NamespaceImport */) { + // Elide a namespace import if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + // Elide named imports if all of its import specifiers are elided. + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + /** + * Visits an import specifier, eliding it if it is not referenced. + * + * @param node The import specifier node. + */ + function visitImportSpecifier(node) { + // Elide an import specifier if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + /** + * Visits an export assignment, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export assignment node. + */ + function visitExportAssignment(node) { + // Elide the export assignment if it does not reference a value. + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + /** + * Visits an export declaration, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export declaration node. + */ + function visitExportDeclaration(node) { + if (!node.exportClause) { + // Elide a star export if the module it references does not export a value. + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + // Elide the export declaration if it does not export a value. + return undefined; + } + // Elide the export declaration if all of its named exports are elided. + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, /*optional*/ true); + return exportClause + ? ts.updateExportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, exportClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits named exports, eliding it if it does not contain an export specifier that + * resolves to a value. + * + * @param node The named exports node. + */ + function visitNamedExports(node) { + // Elide the named exports if all of its export specifiers were elided. + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + /** + * Visits an export specifier, eliding it if it does not resolve to a value. + * + * @param node The export specifier node. + */ + function visitExportSpecifier(node) { + // Elide an export specifier if it does not reference a value. + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } /** * Determines whether to emit an import equals declaration. * @@ -44976,7 +45390,10 @@ var ts; */ function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + // Elide external module `import=` if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -45152,23 +45569,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(69 /* Identifier */); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 4 /* AsyncMethodsWithSuper */; - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(174 /* CallExpression */); - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(221 /* ClassDeclaration */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(148 /* Constructor */); + context.enableSubstitution(70 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -45176,7 +45577,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. classAliases = ts.createMap(); } @@ -45186,25 +45587,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // 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(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); context.enableSubstitution(254 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(225 /* ModuleDeclaration */); + context.enableEmitNotification(226 /* ModuleDeclaration */); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 148 /* Constructor */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; } /** * Hook for node emit. @@ -45214,12 +45607,6 @@ var ts; */ function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; } @@ -45228,7 +45615,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } /** * Hooks node substitutions. @@ -45265,17 +45651,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 174 /* CallExpression */: - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { - return substituteCallExpression(node); - } - break; } return node; } @@ -45313,8 +45694,8 @@ var ts; // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); if (container) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 225 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 224 /* EnumDeclaration */); + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 226 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 225 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45322,38 +45703,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -45381,2605 +45734,3416 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); -/// -/// +/// +/// /*@internal*/ var ts; (function (ts) { - function transformES6Module(context) { + var entities = createEntitiesMap(); + function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); var currentSourceFile; return transformSourceFile; + /** + * Transform JSX-specific syntax in a SourceFile. + * + * @param node A SourceFile node. + */ function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - return ts.visitEachChild(node, visitor, context); - } + currentSourceFile = node; + node = ts.visitEachChild(node, visitor, context); + currentSourceFile = undefined; return node; } function visitor(node) { + if (node.transformFlags & 4 /* Jsx */) { + return visitorWorker(node); + } + else if (node.transformFlags & 8 /* ContainsJsx */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 231 /* ImportClause */: - return visitImportClause(node); - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - return visitNamedBindings(node); - case 234 /* ImportSpecifier */: - return visitImportSpecifier(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 237 /* NamedExports */: - return visitNamedExports(node); - case 238 /* ExportSpecifier */: - return visitExportSpecifier(node); + case 242 /* JsxElement */: + return visitJsxElement(node, /*isChild*/ false); + case 243 /* JsxSelfClosingElement */: + return visitJsxSelfClosingElement(node, /*isChild*/ false); + case 248 /* JsxExpression */: + return visitJsxExpression(node); + default: + ts.Debug.failBadSyntaxKind(node); + return undefined; } - return node; } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; // do not emit export equals for ES6 + function transformJsxChildToExpression(node) { + switch (node.kind) { + case 10 /* JsxText */: + return visitJsxText(node); + case 248 /* JsxExpression */: + return visitJsxExpression(node); + case 242 /* JsxElement */: + return visitJsxElement(node, /*isChild*/ true); + case 243 /* JsxSelfClosingElement */: + return visitJsxSelfClosingElement(node, /*isChild*/ true); + default: + ts.Debug.failBadSyntaxKind(node); + return undefined; } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + function visitJsxElement(node, isChild) { + return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, /*location*/ node); + } + function visitJsxSelfClosingElement(node, isChild) { + return visitJsxOpeningLikeElement(node, /*children*/ undefined, isChild, /*location*/ node); + } + function visitJsxOpeningLikeElement(node, children, isChild, location) { + var tagName = getTagName(node); + var objectProperties; + var attrs = node.attributes; + if (attrs.length === 0) { + // When there are no attributes, React wants "null" + objectProperties = ts.createNull(); } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; + else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument. + segments.unshift(ts.createObjectLiteral()); + } + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments) + || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true); - if (node.exportClause === newExportClause) { - return node; + var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + if (isChild) { + ts.startOnNewLine(element); } - return newExportClause - ? ts.createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newExportClause, node.moduleSpecifier) - : undefined; + return element; } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; + function transformJsxSpreadAttributeToExpression(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; + function transformJsxAttributeToObjectLiteralElement(node) { + var name = getAttributeName(node); + var expression = transformJsxAttributeInitializer(node.initializer); + return ts.createPropertyAssignment(name, expression); } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; + function transformJsxAttributeInitializer(node) { + if (node === undefined) { + return ts.createLiteral(true); + } + else if (node.kind === 9 /* StringLiteral */) { + var decoded = tryDecodeEntities(node.text); + return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + } + else if (node.kind === 248 /* JsxExpression */) { + return visitJsxExpression(node); + } + else { + ts.Debug.failBadSyntaxKind(node); + } } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; + function visitJsxText(node) { + var text = ts.getTextOfNode(node, /*includeTrivia*/ true); + var parts; + var firstNonWhitespace = 0; + var 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 (var i = 0; i < text.length; i++) { + var c = text.charCodeAt(i); + if (ts.isLineBreak(c)) { + if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { + var 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(ts.createLiteral(decodeEntities(part))); + } + firstNonWhitespace = -1; } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newImportClause, node.moduleSpecifier); + else if (!ts.isWhiteSpace(c)) { + lastNonWhitespace = i; + if (firstNonWhitespace === -1) { + firstNonWhitespace = i; + } } } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; + if (firstNonWhitespace !== -1) { + var 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(ts.createLiteral(decodeEntities(part))); + } + if (parts) { + return ts.reduceLeft(parts, aggregateJsxTextParts); } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; + return undefined; } - function visitNamedBindings(node) { - if (node.kind === 232 /* NamespaceImport */) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + /** + * Aggregates two expressions by interpolating them with a whitespace literal. + */ + function aggregateJsxTextParts(left, right) { + return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + } + /** + * Replace entities like " ", "{", and "�" with the characters they encode. + * See https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references + */ + function decodeEntities(text) { + return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { + if (decimal) { + return String.fromCharCode(parseInt(decimal, 10)); + } + else if (hex) { + return String.fromCharCode(parseInt(hex, 16)); + } + else { + var ch = entities[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; + } + }); + } + /** Like `decodeEntities` but returns `undefined` if there were no entities to decode. */ + function tryDecodeEntities(text) { + var decoded = decodeEntities(text); + return decoded === text ? undefined : decoded; + } + function getTagName(node) { + if (node.kind === 242 /* JsxElement */) { + return getTagName(node.openingElement); } else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } - if (newNamedImportElements === node.elements) { - return node; + else { + return ts.createExpressionFromEntityName(name_31); } - return ts.createNamedImports(newNamedImportElements); } } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - } - ts.transformES6Module = transformES6Module; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableEmitNotification(256 /* SourceFile */); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; + /** + * Emit an attribute name, which is quoted if it needs to be quoted. Because + * these emit into an object literal property name, we don't need to be worried + * about keywords, just non-identifier characters + */ + function getAttributeName(node) { + var name = node.name; + if (/^[A-Za-z_]\w*$/.test(name.text)) { + return name; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - // Perform the transformation. - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; + else { + return ts.createLiteral(name.text); } - return node; } - function transformSystemModuleWorker(node) { - // System modules have the following shape: - // - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // - // The parameter 'exports' here is a callback '(name: string, value: T) => T' that - // is used to publish exported values. 'exports' returns its 'value' argument so in - // most cases expressions that mutate exported values can be rewritten as: - // - // expr -> exports('name', expr) - // - // The only exception in this rule is postfix unary operators, - // see comment to 'substitutePostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // Collect information about the external module and dependency groups. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Make sure that the name of the 'exports' function does not conflict with - // existing identifiers. - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - // Add the body of the module. - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], - /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); - // Write the call to `System.register` - // Clear the emit-helpers flag for later passes since we'll have already used it in the module body - // So the helper will be emit at the correct position instead of at the top of the source-file - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), - /*typeArguments*/ undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); - var _a; + function visitJsxExpression(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); } - /** - * Adds the statements for the module body function for the source file. - * - * @param statements The output statements for the module body. - * @param node The source file for the module. - * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. - */ - function addSystemModuleBody(statements, node, dependencyGroups) { - // Shape of the body in system modules: - // - // function (exports) { - // - // - // - // return { - // setters: [ - // - // ], - // execute: function() { - // - // } - // } - // - // } - // - // i.e: - // - // import {x} from 'file1' - // var y = 1; - // export function foo() { return y + x(); } - // console.log(y); - // - // Will be transformed to: - // - // function(exports) { - // var file_1; // local alias - // var y; - // function foo() { return y + file_1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file_1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - // We start a new lexical environment in this function body, but *not* in the - // body of the execute function. This allows us to emit temporary declarations - // only in the outer module body and not in the inner one. - startLexicalEnvironment(); - // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); - // var __moduleName = context_1 && context_1.id; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", - /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - // Visit the statements of the source file, emitting any transformations into - // the `executeStatements` array. We do this *before* we fill the `setters` array - // as we both emit transformations as well as aggregate some data used when creating - // setters. This allows us to reduce the number of times we need to loop through the - // statements of the source file. - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - // We emit the lexical environment (hoisted variables and function declarations) - // early to align roughly with our previous emit output. - // Two key differences in this approach are: - // - Temporary variables will appear at the top rather than at the bottom of the file - // - Calls to the exporter for exported function declarations are grouped after - // the declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Emit early exports for function declarations. - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); + } + ts.transformJsx = transformJsx; + function createEntitiesMap() { + return ts.createMap({ + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }); + } +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + // These variables contain state that changes as we descend into the tree. + var currentSourceFileExternalHelpersModuleName; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + var enabledSubstitutions; + /** + * Keeps track of whether we are within any containing namespaces when performing + * just-in-time substitution while printing an expression identifier. + */ + var applicableSubstitutions; + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + var currentSuperContainer; + // Save the previous transformation hooks. + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; + return ts.visitEachChild(node, visitor, context); } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; + function visitor(node) { + if (node.transformFlags & 16 /* ES2017 */) { + return visitorWorker(node); } - // when resolving exports local exported entries/indirect exported entries in the module - // should always win over entries with similar names that were added via star exports - // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. - // local names set should only be added if we have anything exported - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - // no exported declarations (export var ...) or export specifiers (export {x}) - // check if we have any non star export declarations. - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 236 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; + else if (node.transformFlags & 32 /* ContainsES2017 */) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119 /* AsyncKeyword */: + // ES2017 async modifier should be elided for targets < ES2017 + return undefined; + case 185 /* AwaitExpression */: + // ES2017 'await' expressions must be transformed for targets < ES2017. + return visitAwaitExpression(node); + case 148 /* MethodDeclaration */: + // ES2017 method declarations may be 'async' + return visitMethodDeclaration(node); + case 221 /* FunctionDeclaration */: + // ES2017 function declarations may be 'async' + return visitFunctionDeclaration(node); + case 180 /* FunctionExpression */: + // ES2017 function expressions may be 'async' + return visitFunctionExpression(node); + case 181 /* ArrowFunction */: + // ES2017 arrow functions may be 'async' + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + /** + * Visits an await expression. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The await expression node. + */ + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), + /*location*/ node), node); + } + /** + * Visits a method declaration of a class. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The method node. + */ + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + // While we emit the source map for the node after skipping decorators and modifiers, + // we need to emit the comments for the original range. + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + /** + * Visits a function declaration. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function node. + */ + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * Visits a function expression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function expression node. + */ + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * @remarks + * This function will be called when one of the following conditions are met: + * - The node is marked async + */ + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4 /* EmitSuperHelper */); } } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return addExportStarFunction(statements, /*localNames*/ undefined); + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; } } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; } } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 236 /* ExportDeclaration */) { - continue; + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(175 /* CallExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(222 /* ClassDeclaration */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(149 /* Constructor */); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 174 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 175 /* CallExpression */: + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); } } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 /* ClassDeclaration */ + || kind === 149 /* Constructor */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; } /** - * Emits a setter callback for each dependency group. - * @param write The callback used to write each callback. + * Hook for node emit. + * + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. */ - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 230 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 229 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 236 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // - // emit as: - // - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); - } - else { - // export * from 'foo' - // - // emit as: - // - // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, - /*typeArguments*/ undefined, [parameterName]))); - } - break; - } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64 /* ES2016 */) { + return visitorWorker(node); + } + else if (node.transformFlags & 128 /* ContainsES2016 */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 188 /* BinaryExpression */: + return visitBinaryExpression(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function visitBinaryExpression(node) { + // We are here because ES2016 adds support for the exponentiation operator. + var left = ts.visitNode(node.left, visitor, ts.isExpression); + var right = ts.visitNode(node.right, visitor, ts.isExpression); + if (node.operatorToken.kind === 61 /* AsteriskAsteriskEqualsToken */) { + var target = void 0; + var value = void 0; + if (ts.isElementAccessExpression(left)) { + // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), + /*location*/ left); + value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, + /*location*/ left); } - setters.push(ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + else if (ts.isPropertyAccessExpression(left)) { + // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, + /*location*/ left); + value = ts.createPropertyAccess(expressionTemp, left.name, + /*location*/ left); + } + else { + // Transforms `a **= b` into `a = Math.pow(a, b)` + target = left; + value = left; + } + return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + } + else if (node.operatorToken.kind === 39 /* AsteriskAsteriskToken */) { + // Transforms `a ** b` into `Math.pow(a, b)` + return ts.createMathPow(left, right, /*location*/ node); + } + else { + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + } + ts.transformES2016 = transformES2016; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + /** Enables substitutions for captured `this` */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + /** Enables substitutions for block-scoped bindings. */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + /** + * A capture may have been added for calls to 'super', but + * the caller should emit subsequent statements normally. + */ + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * var _this = _super.call(...) || this; + * + * Callers should skip the current statement. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * return _super.call(...) || this; + * + * Callers should skip the current statement and avoid any returns of '_this'. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentSourceFile; + var currentText; + var currentParent; + var currentNode; + var enclosingVariableStatement; + var enclosingBlockScopeContainer; + var enclosingBlockScopeContainerParent; + var enclosingFunction; + var enclosingNonArrowFunction; + var enclosingNonAsyncFunctionBody; + /** + * Used to track if we are emitting body of the converted loop + */ + var convertedLoopState; + /** + * Keeps track of whether substitutions have been enabled for specific cases. + * They are persisted between each SourceFile transformation and should not + * be reset. + */ + var enabledSubstitutions; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + currentSourceFile = node; + currentText = node.text; + return ts.visitNode(node, visitor, ts.isSourceFile); } - function visitSourceElement(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } + function visitor(node) { + return saveStateAndInvoke(node, dispatcher); } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + 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 currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; + var savedConvertedLoopState = convertedLoopState; + if (ts.nodeStartsNewLexicalEnvironment(node)) { + // don't treat content of nodes that start new lexical environment as part of converted loop copy + convertedLoopState = undefined; } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + onBeforeVisitNode(node); + var visited = f(node); + convertedLoopState = savedConvertedLoopState; + enclosingFunction = savedEnclosingFunction; + enclosingNonArrowFunction = savedEnclosingNonArrowFunction; + enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; + enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; + enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; + enclosingVariableStatement = savedEnclosingVariableStatement; currentParent = savedCurrentParent; currentNode = savedCurrentNode; + return visited; + } + function shouldCheckNode(node) { + return (node.transformFlags & 256 /* ES2015 */) !== 0 || + node.kind === 215 /* LabeledStatement */ || + (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + } + function visitorWorker(node) { + if (shouldCheckNode(node)) { + return visitJavaScript(node); + } + else if (node.transformFlags & 512 /* ContainsES2015 */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorForConvertedLoopWorker(node) { + var result; + if (shouldCheckNode(node)) { + result = visitJavaScript(node); + } + else { + result = visitNodesInConvertedLoop(node); + } return result; } - function visitNestedNodeWorker(node) { + function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 200 /* VariableStatement */: + case 212 /* ReturnStatement */: + return visitReturnStatement(node); + case 201 /* VariableStatement */: return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 70 /* Identifier */: + return visitIdentifier(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitJavaScript(node) { + switch (node.kind) { + case 83 /* ExportKeyword */: + return node; + case 222 /* ClassDeclaration */: return visitClassDeclaration(node); - case 206 /* ForStatement */: + case 193 /* ClassExpression */: + return visitClassExpression(node); + case 143 /* Parameter */: + return visitParameter(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 181 /* ArrowFunction */: + return visitArrowFunction(node); + case 180 /* FunctionExpression */: + return visitFunctionExpression(node); + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 70 /* Identifier */: + return visitIdentifier(node); + case 220 /* VariableDeclarationList */: + return visitVariableDeclarationList(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 207 /* ForStatement */: return visitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return visitForOfStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 212 /* WithStatement */: - return visitWithStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 227 /* CaseBlock */: - return visitCaseBlock(node); - case 249 /* CaseClause */: - return visitCaseClause(node); - case 250 /* DefaultClause */: - return visitDefaultClause(node); - case 216 /* TryStatement */: - return visitTryStatement(node); - case 252 /* CatchClause */: - return visitCatchClause(node); - case 199 /* Block */: - return visitBlock(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return visitExpressionStatement(node); + case 172 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 254 /* ShorthandPropertyAssignment */: + return visitShorthandPropertyAssignment(node); + case 171 /* ArrayLiteralExpression */: + return visitArrayLiteralExpression(node); + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 179 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); + case 188 /* BinaryExpression */: + return visitBinaryExpression(node, /*needsDestructuringValue*/ true); + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + return visitTemplateLiteral(node); + case 177 /* TaggedTemplateExpression */: + return visitTaggedTemplateExpression(node); + case 190 /* TemplateExpression */: + return visitTemplateExpression(node); + case 191 /* YieldExpression */: + return visitYieldExpression(node); + case 96 /* SuperKeyword */: + return visitSuperKeyword(); + case 191 /* YieldExpression */: + // `yield` will be handled by a generators transform. + return ts.visitEachChild(node, visitor, context); + case 148 /* MethodDeclaration */: + return visitMethodDeclaration(node); + case 256 /* SourceFile */: + return visitSourceFileNode(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); default: - return node; + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); } } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + function onBeforeVisitNode(node) { + if (currentNode) { + if (ts.isBlockScope(currentNode, currentParent)) { + enclosingBlockScopeContainer = currentNode; + enclosingBlockScopeContainerParent = currentParent; + } + if (ts.isFunctionLike(currentNode)) { + enclosingFunction = currentNode; + if (currentNode.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = currentNode; + if (!(ts.getEmitFlags(currentNode) & 2097152 /* 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 201 /* VariableStatement */: + enclosingVariableStatement = currentNode; + break; + case 220 /* VariableDeclarationList */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: + break; + default: + enclosingVariableStatement = undefined; + } } - return undefined; + currentParent = currentNode; + currentNode = node; } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - // NOTE(rbuckton): Do we support export import = require('') in System? - return undefined; + 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; } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; + 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()) + ])); + } + function visitThisKeyword(node) { + ts.Debug.assert(convertedLoopState !== undefined); + if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; } - return undefined; + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); } - function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + function visitIdentifier(node) { + if (!convertedLoopState) { + return node; } - return undefined; + if (ts.isGeneratedIdentifier(node)) { + return node; + } + if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + return node; + } + return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); + function visitBreakOrContinueStatement(node) { + if (convertedLoopState) { + // check if we can emit break/continue as is + // 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 === 211 /* 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 === 211 /* BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Break */; + labelMarker = "break"; + } + else { + convertedLoopState.nonLocalJumps |= 4 /* Continue */; + // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. + labelMarker = "continue"; + } + } + else { + if (node.kind === 211 /* BreakStatement */) { + labelMarker = "break-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); + } + else { + labelMarker = "continue-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); + } + } + var returnExpression = ts.createLiteral(labelMarker); + if (convertedLoopState.loopOutParameters.length) { + var outParams = convertedLoopState.loopOutParameters; + var expr = void 0; + for (var i = 0; i < outParams.length; i++) { + var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + if (i === 0) { + expr = copyExpr; + } + else { + expr = ts.createBinary(expr, 25 /* CommaToken */, copyExpr); + } + } + returnExpression = ts.createBinary(expr, 25 /* CommaToken */, returnExpression); + } + return ts.createReturn(returnExpression); } } - return undefined; + return ts.visitEachChild(node, visitor, context); } /** - * Visits a variable statement, hoisting declared names to the top-level module body. - * Each declaration is rewritten into an assignment expression. + * Visits a ClassDeclaration and transforms it into a variable statement. * - * @param node The variable statement to visit. + * @param node A ClassDeclaration node. */ - function visitVariableStatement(node) { - // hoist only non-block scoped declarations or block scoped declarations parented by source file - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || - enclosingBlockScopedContainer.kind === 256 /* SourceFile */; - if (!shouldHoist) { - return node; + function visitClassDeclaration(node) { + // [source] + // class C { } + // + // [output] + // var C = (function () { + // function C() { + // } + // return C; + // }()); + var modifierFlags = ts.getModifierFlags(node); + var isExported = modifierFlags & 1 /* Export */; + var isDefault = modifierFlags & 512 /* Default */; + // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) + var modifiers = isExported && !isDefault + ? ts.filter(node.modifiers, isExportModifier) + : undefined; + var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), + /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) + ]), + /*location*/ node); + ts.setOriginalNode(statement, node); + ts.startOnNewLine(statement); + // Add an `export default` statement for default exports (for `--target es5 --module es6`) + if (isExported && isDefault) { + var statements = [statement]; + statements.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); + return statements; } - var isExported = ts.hasModifier(node, 1 /* Export */); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } + return statement; + } + function isExportModifier(node) { + return node.kind === 83 /* ExportKeyword */; + } + /** + * Visits a ClassExpression and transforms it into an expression. + * + * @param node A ClassExpression node. + */ + function visitClassExpression(node) { + // [source] + // C = class { } + // + // [output] + // C = (function () { + // function class_1() { + // } + // return class_1; + // }()) + return transformClassLikeDeclarationToExpression(node); + } + /** + * Transforms a ClassExpression or ClassDeclaration into an expression. + * + * @param node A ClassExpression or ClassDeclaration node. + */ + function transformClassLikeDeclarationToExpression(node) { + // [source] + // class C extends D { + // constructor() {} + // method() {} + // get prop() {} + // set prop(v) {} + // } + // + // [output] + // (function (_super) { + // __extends(C, _super); + // function C() { + // } + // C.prototype.method = function () {} + // Object.defineProperty(C.prototype, "prop", { + // get: function() {}, + // set: function() {}, + // enumerable: true, + // configurable: true + // }); + // return C; + // }(D)) + if (node.name) { + enableSubstitutionsForBlockScopedBindings(); } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); + var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var classFunction = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], + /*type*/ undefined, transformClassBody(node, extendsClauseElement)); + // To preserve the behavior of the old emitter, we explicitly indent + // the body of the function here if it was requested in an earlier + // transformation. + if (ts.getEmitFlags(node) & 524288 /* Indented */) { + ts.setEmitFlags(classFunction, 524288 /* Indented */); } - return undefined; + // "inner" and "outer" below are added purely to preserve source map locations from + // the old emitter + var inner = ts.createPartiallyEmittedExpression(classFunction); + inner.end = node.end; + ts.setEmitFlags(inner, 49152 /* NoComments */); + var outer = ts.createPartiallyEmittedExpression(inner); + outer.end = ts.skipTrivia(currentText, node.pos); + ts.setEmitFlags(outer, 49152 /* NoComments */); + return ts.createParen(ts.createCall(outer, + /*typeArguments*/ undefined, extendsClauseElement + ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] + : [])); } /** - * Transforms a VariableDeclaration into one or more assignment expressions. + * Transforms a ClassExpression or ClassDeclaration into a function body. * - * @param node The VariableDeclaration to transform. - * @param isExported A value used to indicate whether the containing statement was exported. + * @param node A ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. */ - function transformVariable(node, isExported) { - // Hoist any bound names within the declaration. - hoistBindingElement(node, isExported); - if (!node.initializer) { - // If the variable has no initializer, ignore it. - return; + function transformClassBody(node, extendsClauseElement) { + var statements = []; + startLexicalEnvironment(); + addExtendsHelperIfNeeded(statements, node, extendsClauseElement); + addConstructor(statements, node, extendsClauseElement); + addClassMembers(statements, node); + // Create a synthetic text range for the return statement. + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); + var localName = getLocalName(node); + // The following partially-emitted expression exists purely to align our sourcemap + // emit with the original emitter. + var outer = ts.createPartiallyEmittedExpression(localName); + outer.end = closingBraceLocation.end; + ts.setEmitFlags(outer, 49152 /* NoComments */); + var statement = ts.createReturn(outer); + statement.pos = closingBraceLocation.pos; + ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); + statements.push(statement); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + ts.setEmitFlags(block, 49152 /* NoComments */); + return block; + } + /** + * Adds a call to the `__extends` helper if needed for a class. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { + if (extendsClauseElement) { + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), + /*location*/ extendsClauseElement)); + } + } + /** + * Adds the constructor of the class to a class body function. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addConstructor(statements, node, extendsClauseElement) { + var constructor = ts.getFirstConstructorWithBody(node); + var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); + var constructorFunction = ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, getDeclarationName(node), + /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), + /*location*/ constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); + } + statements.push(constructorFunction); + } + /** + * Transforms the parameters of the constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorParameters(constructor, hasSynthesizedSuper) { + // If the TypeScript transformer needed to synthesize a constructor for property + // initializers, it would have also added a synthetic `...args` parameter and + // `super` call. + // If this is the case, we do not include the synthetic `...args` parameter and + // will instead use the `arguments` object in ES5/3. + if (constructor && !hasSynthesizedSuper) { + return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); + } + return []; + } + /** + * Transforms the body of a constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param node The node which contains the constructor. + * @param extendsClauseElement The expression for the class `extends` clause. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + // If a super call has already been synthesized, + // we're going to assume that we should just transform everything after that. + // The assumption is that no prior step in the pipeline has added any prologue directives. + statementOffset = 1; + } + else if (constructor) { + // Otherwise, try to emit all potential prologue directives first. + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + } + if (constructor) { + addDefaultValueAssignmentsIfNeeded(statements, constructor); + addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // The last statement expression was replaced. Skip it. + if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { + statementOffset++; } - var name = node.name; - if (ts.isIdentifier(name)) { - // If the variable has an IdentifierName, write out an assignment expression in its place. - return ts.createAssignment(name, node.initializer); + if (constructor) { + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); + ts.addRange(statements, body); } - else { - // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + // 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 + && superCaptureStatus !== 2 /* ReplaceWithReturn */ + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); } + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, + /*location*/ constructor ? constructor.body.statements : node.members), + /*location*/ constructor ? constructor.body : node, + /*multiLine*/ true); + if (!constructor) { + ts.setEmitFlags(block, 49152 /* NoComments */); + } + return block; } /** - * Visits a FunctionDeclaration, hoisting it to the outer module body function. - * - * @param node The function declaration to visit. + * We want to try to avoid emitting a return statement in certain cases if a user already returned something. + * It would generate obviously dead code, so we'll try to make things a little bit prettier + * by doing a minimal check on whether some common patterns always explicitly return. */ - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1 /* Export */)) { - // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_31 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name_31, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node); - // Record a declaration export in the outer module body function. - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_31); + function isSufficientlyCoveredByReturnStatements(statement) { + // A return statement is considered covered. + if (statement.kind === 212 /* ReturnStatement */) { + return true; + } + else if (statement.kind === 204 /* IfStatement */) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } - ts.setOriginalNode(newNode, node); - node = newNode; } - // Hoist the function declaration to the outer module body function. - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 /* ModuleDeclaration */ || originalNode.kind === 224 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_32 = getDeclarationName(originalNode); - // We only need to hoistVariableDeclaration for EnumDeclaration - // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement - // which then call transformsVariable for each declaration in declarationList - if (originalNode.kind === 224 /* EnumDeclaration */) { - hoistVariableDeclaration(name_32); + else if (statement.kind === 200 /* Block */) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; } - return [ - node, - createExportStatement(name_32, name_32) - ]; } - return node; + return false; } /** - * Visits a ClassDeclaration, hoisting its name to the outer module body function. + * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. * - * @param node The class declaration to visit. + * @returns The new statement offset into the `statements` array. */ - function visitClassDeclaration(node) { - // Hoist the name of the class declaration to the outer module body function. - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - // Rewrite the class declaration into an assignment of a class expression. - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node)), - /*location*/ node)); - // If the class was exported, write a declaration export to the inner module body function. - if (ts.hasModifier(node, 1 /* Export */)) { - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name); + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + // If this isn't a derived class, just capture 'this' for arrow functions if necessary. + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); } - statements.push(createDeclarationExport(node)); + return 0 /* NoReplacement */; } - return statements; + // We must be here because the user didn't write a constructor + // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. + // If that's the case we can just immediately return the result of a 'super()' call. + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2 /* ReplaceWithReturn */; + } + // The constructor exists, but it and the 'super()' call it contains were generated + // for something like property initializers. + // Create a captured '_this' variable and assume it will subsequently be used. + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1 /* ReplaceSuperCapture */; + } + // Most of the time, a 'super' call will be the first real statement in a constructor body. + // In these cases, we'd like to transform these into a *single* statement instead of a declaration + // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, + // we'd get: + // + // var _this; + // _this = _super.call(...) || this; + // + // instead of + // + // var _this = _super.call(...) || this; + // + // Additionally, if the 'super()' call is the last statement, we should just avoid capturing + // entirely and immediately return the result like so: + // + // return _super.call(...) || this; + // + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + // Return the result if we have an immediate super() call on the last statement. + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2 /* ReplaceWithReturn */; + } + // Perform the capture. + captureThisForNode(statements, ctor, superCallExpression, 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 shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } /** - * Visits the body of a ForStatement to hoist declarations. + * Visits a parameter declaration. * - * @param node The statement to visit. + * @param node A ParameterDeclaration node. */ - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, /*isExported*/ false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), - /*location*/ node); + function visitParameter(node) { + if (node.dotDotDotToken) { + // rest parameters are elided + return undefined; + } + else if (ts.isBindingPattern(node.name)) { + // Binding patterns are converted into a generated name and are + // evaluated inside the function body. + return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); + } + else if (node.initializer) { + // Initializers are elided + return ts.setOriginalNode(ts.createParameter(node.name, + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); } else { - return ts.visitEachChild(node, visitNestedNode, context); + return node; } } /** - * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. + * Gets a value indicating whether we need to add default value assignments for a + * function-like node. * - * @param node The decalaration list to transform. + * @param node A function-like node. */ - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, /*isExported*/ false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 262144 /* ContainsDefaultValueAssignments */) !== 0; } /** - * Visits the body of a ForInStatement to hoist declarations. + * Adds statements to the body of a function-like node if it contains parameters with + * binding patterns or initializers. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param node A function-like node. */ - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; + function addDefaultValueAssignmentsIfNeeded(statements, node) { + if (!shouldAddDefaultValueAssignments(node)) { + return; } - else { - return ts.visitEachChild(node, visitNestedNode, context); + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); + } } } /** - * Visits the body of a ForOfStatement to hoist declarations. + * Adds statements to the body of a function-like node for parameters with binding patterns * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. */ - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { + var temp = ts.getGeneratedNameForNode(parameter); + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + if (name.elements.length > 0) { + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608 /* CustomPrologue */)); } - else { - return ts.visitEachChild(node, visitNestedNode, context); + else if (initializer) { + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); } } /** - * Visits the body of a DoStatement to hoist declarations. + * Adds statements to the body of a function-like node for parameters with initializers. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. */ - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), + /*location*/ parameter)) + ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), + /*elseStatement*/ undefined, + /*location*/ parameter); + statement.startsOnNewLine = true; + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + statements.push(statement); } /** - * Visits the body of a WhileStatement to hoist declarations. + * Gets a value indicating whether we need to add statements to handle a rest parameter. * - * @param node The statement to visit. + * @param node A ParameterDeclaration node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` */ - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** - * Visits the body of a LabeledStatement to hoist declarations. + * Adds statements to the body of a function-like node if it contains a rest parameter. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param node A function-like node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` */ - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; } - return node; + // `declarationName` is the name of the local declaration for the parameter. + var declarationName = ts.getMutableClone(parameter.name); + ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); + // `expressionName` is the name of the parameter used in expressions. + var expressionName = ts.getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = ts.createLoopVariable(); + // var param = []; + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declarationName, + /*type*/ undefined, ts.createArrayLiteral([])) + ]), + /*location*/ parameter), 8388608 /* CustomPrologue */)); + // for (var _i = restIndex; _i < arguments.length; _i++) { + // param[_i - restIndex] = arguments[_i]; + // } + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) + ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), + /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ + ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + /*location*/ parameter)) + ])); + ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); + ts.startOnNewLine(forStatement); + statements.push(forStatement); } /** - * Visits the body of a WithStatement to hoist declarations. + * Adds a statement to capture the `this` of a function declaration if it is needed. * - * @param node The statement to visit. + * @param statements The statements for the new function body. + * @param node A node. */ - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; + function addCaptureThisForNodeIfNeeded(statements, node) { + if (node.transformFlags & 65536 /* ContainsCapturedLexicalThis */ && node.kind !== 181 /* ArrowFunction */) { + captureThisForNode(statements, node, ts.createThis()); } - return node; } - /** - * Visits the body of a SwitchStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); } /** - * Visits the body of a CaseBlock to hoist declarations. + * Adds statements to the class body function for a class to define the members of the + * class. * - * @param node The node to visit. + * @param statements The statements for the class body function. + * @param node The ClassExpression or ClassDeclaration node. */ - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; + function addClassMembers(statements, node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + switch (member.kind) { + case 199 /* SemicolonClassElement */: + statements.push(transformSemicolonClassElementToStatement(member)); + break; + case 148 /* MethodDeclaration */: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + break; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + } + break; + case 149 /* Constructor */: + // Constructors are handled in visitClassExpression/visitClassDeclaration + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } } - return node; } /** - * Visits the body of a CaseClause to hoist declarations. + * Transforms a SemicolonClassElement into a statement for a class body function. * - * @param node The clause to visit. + * @param member The SemicolonClassElement node. */ - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; + function transformSemicolonClassElementToStatement(member) { + return ts.createEmptyStatement(/*location*/ member); } /** - * Visits the body of a DefaultClause to hoist declarations. + * Transforms a MethodDeclaration into a statement for a class body function. * - * @param node The clause to visit. + * @param receiver The receiver for the member. + * @param member The MethodDeclaration node. */ - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); + function transformClassMethodDeclarationToStatement(receiver, member) { + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); + var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + ts.setEmitFlags(func, 49152 /* NoComments */); + ts.setSourceMapRange(func, sourceMapRange); + var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), + /*location*/ member.name), func), + /*location*/ member); + ts.setOriginalNode(statement, member); + ts.setCommentRange(statement, commentRange); + // The location for the statement is used to emit comments only. + // No source map should be emitted for this statement to align with the + // old emitter. + ts.setEmitFlags(statement, 1536 /* NoSourceMap */); + return statement; } /** - * Visits the body of a TryStatement to hoist declarations. + * Transforms a set of related of get/set accessors into a statement for a class body function. * - * @param node The statement to visit. + * @param receiver The receiver for the member. + * @param accessors The set of related get/set accessors. */ - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); + function transformAccessorsToStatement(receiver, accessors) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*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 + // old emitter. + ts.setEmitFlags(statement, 49152 /* NoComments */); + return statement; } /** - * Visits the body of a CatchClause to hoist declarations. + * Transforms a set of related get/set accessors into an expression for either a class + * body function or an ObjectLiteralExpression with computed properties. * - * @param node The clause to visit. + * @param receiver The receiver for the member. */ - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; + function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + // 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); + ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); + ts.setSourceMapRange(target, firstAccessor.name); + var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); + ts.setSourceMapRange(propertyName, firstAccessor.name); + var properties = []; + if (getAccessor) { + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); + properties.push(getter); + } + if (setAccessor) { + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); + properties.push(setter); + } + properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + target, + propertyName, + ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ]); + if (startsOnNewLine) { + call.startsOnNewLine = true; } - return node; + return call; } /** - * Visits the body of a Block to hoist declarations. + * Visits an ArrowFunction and transforms it into a FunctionExpression. * - * @param node The block to visit. + * @param node An ArrowFunction node. */ - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - // - // Substitutions - // - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); + function visitArrowFunction(node) { + if (node.transformFlags & 32768 /* ContainsLexicalThis */) { + enableSubstitutionsForCapturedThis(); } + var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); + ts.setEmitFlags(func, 256 /* CapturesThis */); + return func; } /** - * Hooks node substitutions. + * Visits a FunctionExpression node. * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. + * @param node a FunctionExpression node. */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - return node; + function visitFunctionExpression(node) { + return transformFunctionLikeToExpression(node, /*location*/ node, node.name); } /** - * Substitute the expression, if necessary. + * Visits a FunctionDeclaration node. * - * @param node The node to substitute. + * @param node a FunctionDeclaration node. */ - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; + function visitFunctionDeclaration(node) { + return ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node), + /*original*/ node); } /** - * Substitution for identifiers exported at the top level of a module. + * Transforms a function-like node into a FunctionExpression. + * + * @param node The function-like node to transform. + * @param location The source-map location for the new FunctionExpression. + * @param name The name of the new FunctionExpression. */ - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var left = node.left; - switch (left.kind) { - case 69 /* Identifier */: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 171 /* ObjectLiteralExpression */: - case 170 /* ArrayLiteralExpression */: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256 /* SourceFile */; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 69 /* Identifier */: - return isExportedBinding(node); - case 171 /* ObjectLiteralExpression */: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 170 /* ArrayLiteralExpression */: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); + function transformFunctionLikeToExpression(node, location, name) { + var savedContainingNonArrowFunction = enclosingNonArrowFunction; + if (node.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = node; } + var expression = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*original*/ node); + enclosingNonArrowFunction = savedContainingNonArrowFunction; + return expression; } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 56 /* EqualsToken */ - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); + /** + * Transforms the body of a function-like node. + * + * @param node A function-like node. + */ + function transformFunctionBody(node) { + var multiLine = false; // indicates whether the block *must* be emitted as multiple lines + var singleLine = false; // indicates whether the block *may* be emitted as a single line + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + startLexicalEnvironment(); + if (ts.isBlock(body)) { + // ensureUseStrict is false because no new prologue-directive should be added. + // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array + statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); + addCaptureThisForNodeIfNeeded(statements, node); + addDefaultValueAssignmentsIfNeeded(statements, node); + addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); + // If we added any generated statements, this must be a multi-line block. + if (!multiLine && statements.length > 0) { + multiLine = true; } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + // If the original body was a multi-line block, this must be a multi-line block. + if (!multiLine && body.multiLine) { + multiLine = true; + } } else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 186 /* PostfixUnaryExpression */ || - (node.kind === 185 /* PrefixUnaryExpression */ && (operator === 41 /* PlusPlusToken */ || operator === 42 /* MinusMinusToken */))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128 /* NoSubstitution */); - var call = createExportExpression(operand, expr); - if (node.kind === 185 /* PrefixUnaryExpression */) { - return call; + ts.Debug.assert(node.kind === 181 /* ArrowFunction */); + // To align with the old emitter, we use a synthetic end position on the location + // for the statement list we synthesize when we down-level an arrow function with + // an expression function body. This prevents both comments and source maps from + // being emitted for the end position only. + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; } else { - // export function returns the value that was passes as the second argument - // however for postfix unary expressions result value should be the value before modification. - // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' - return operator === 41 /* PlusPlusToken */ - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); + multiLine = true; } } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = ts.createReturn(expression, /*location*/ body); + ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + statements.push(returnStatement); + // To align with the source map emit for the old emitter, we set a custom + // source map location for the close brace. + closeBraceLocation = body; } - return node; - } - /** - * Gets a name to use for a DeclarationStatement. - * @param node The declaration statement. - */ - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, exportStarFunction, - /*typeParameters*/ undefined, [ts.createParameter(m)], - /*type*/ undefined, ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, - /*type*/ undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, /*type*/ undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true))); - return exportStarFunction; - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - /** - * Creates a call to the current file's export function to export a declaration. - * @param node The declaration to export. - */ - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - if (name.originalKeywordKind && languageVersion === 0 /* ES3 */) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } + var lexicalEnvironment = endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + // If we added any final generated statements, this must be a multi-line block + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; + var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + ts.setEmitFlags(block, 32 /* SingleLine */); } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; + if (closeBraceLocation) { + ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); } - exportedFunctionDeclarations.push(createDeclarationExport(node)); + ts.setOriginalNode(block, node.body); + return block; } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + /** + * Visits an ExpressionStatement that contains a destructuring assignment. + * + * @param node An ExpressionStatement node. + */ + function visitExpressionStatement(node) { + // If we are here it is most likely because our expression is a destructuring assignment. + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 188 /* BinaryExpression */: + return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } + return ts.visitEachChild(node, visitor, context); } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); - context.enableEmitNotification(256 /* SourceFile */); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - // Subset of exportSpecifiers that is a binding-name. - // This is to reduce amount of memory we have to keep around even after we done with module-transformer - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; /** - * Transforms the module aspects of a SourceFile. + * Visits a ParenthesizedExpression that may contain a destructuring assignment. * - * @param node The SourceFile node. + * @param node A ParenthesizedExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - // Collect information about the external module. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Perform the transformation. - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; + function visitParenthesizedExpression(node, needsDestructuringValue) { + // If we are here it is most likely because our expression is a destructuring assignment. + if (needsDestructuringValue) { + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + case 188 /* BinaryExpression */: + return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + } } - return node; - var _a; + return ts.visitEachChild(node, visitor, context); } /** - * Transforms a SourceFile into a CommonJS module. + * Visits a BinaryExpression that contains a destructuring assignment. * - * @param node The SourceFile node. + * @param node A BinaryExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); + function visitBinaryExpression(node, needsDestructuringValue) { + // If we are here it is because this is a destructuring assignment. + ts.Debug.assert(ts.isDestructuringAssignment(node)); + return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + } + function visitVariableStatement(node) { + if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 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++) { + var decl = _a[_i]; + hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); + if (decl.initializer) { + var assignment = void 0; + if (ts.isBindingPattern(decl.name)) { + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); + } + else { + assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + } + (assignments || (assignments = [])).push(assignment); + } + } + if (assignments) { + return 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; + } } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); + return ts.visitEachChild(node, visitor, context); } /** - * Transforms a SourceFile into a UMD module. + * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). * - * @param node The SourceFile node. + * @param node A VariableDeclarationList node. */ - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16 /* UMDDefine */); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); + function visitVariableDeclarationList(node) { + 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; } /** - * Transforms a SourceFile into an AMD or UMD module. + * Gets a value indicating whether we should emit an explicit initializer for a variable + * declaration in a `let` declaration list. * - * @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. + * @param node A VariableDeclaration node. */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: + function shouldEmitExplicitInitializerForLetDeclaration(node) { + // Nested let bindings might need to be initialized explicitly to preserve + // ES6 semantic: // - // define(id?, dependencies?, factory); + // { let x = 1; } + // { let x; } // x here should be undefined. not 1 // - // This has the shape of the following: + // Top level bindings never collide with anything and thus don't require + // explicit initialization. As for nested let bindings there are two cases: // - // define(name, ["module1", "module2"], function (module1Alias) { ... } + // - Nested let bindings that were not renamed definitely should be + // initialized explicitly: // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. + // { let x = 1; } + // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } // - // To ensure this is true in cases of modules with no aliases, e.g.: + // Without explicit initialization code in /*1*/ can be executed even if + // some-condition is evaluated to false. // - // import "module" + // - Renaming introduces fresh name that should not collide with any + // existing names, however renamed bindings sometimes also should be + // explicitly initialized. One particular case: non-captured binding + // declared inside loop body (but not in loop initializer): // - // or + // let x; + // for (;;) { + // let x; + // } // - // /// + // In downlevel codegen inner 'x' will be renamed so it won't collide + // with outer 'x' however it will should be reset on every iteration as + // if it was declared anew. // - // 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; - // Create an updated SourceFile: + // * Why non-captured binding? + // - Because if loop contains block scoped binding captured in some + // function then loop body will be rewritten to have a fresh scope + // on every iteration so everything will just work. // - // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); + // * Why loop initializer is excluded? + // - Since we've introduced a fresh name it already will be undefined. + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + || (isCapturedInFunction + && isDeclaredInLoop + && ts.isBlock(enclosingBlockScopeContainer) + && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + var emitExplicitInitializer = !emittedAsTopLevel + && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && (!resolver.isDeclarationWithCollidingName(node) + || (isDeclaredInLoop + && !isCapturedInFunction + && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + return emitExplicitInitializer; } /** - * Transforms a SourceFile into an AMD or UMD module body. + * Visits a VariableDeclaration in a `let` declaration list. * - * @param node The SourceFile node. + * @param node A VariableDeclaration node. */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - // Visit each statement of the module body. - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.setEmitFlags(body, 2 /* EmitExportStar */); + function visitVariableDeclarationInLetDeclarationList(node) { + // For binding pattern names that lack initializers there is no point to emit + // explicit initializer since downlevel codegen for destructuring will fail + // in the absence of initializer so all binding elements will say uninitialized + var name = node.name; + if (ts.isBindingPattern(name)) { + return visitVariableDeclaration(node); } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, - /*location*/ exportEquals); - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), - /*location*/ exportEquals); - ts.setEmitFlags(statement, 49152 /* NoComments */); - statements.push(statement); - } + if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { + var clone_5 = ts.getMutableClone(node); + clone_5.initializer = ts.createVoidZero(); + return clone_5; } + return ts.visitEachChild(node, visitor, context); } /** - * Visits a node at the top level of the source file. + * Visits a VariableDeclaration node with a binding pattern. * - * @param node The node. + * @param node A VariableDeclaration node. */ - function visitor(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; + function visitVariableDeclaration(node) { + // If we are here it is because the name contains a binding pattern. + if (ts.isBindingPattern(node.name)) { + var recordTempVariablesInLine = !enclosingVariableStatement + || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); + return ts.flattenVariableDestructuring(node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + } + 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); + } + else { + result = ts.visitEachChild(node, visitor, context); + } + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; } + return result; + } + function visitDoStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitWhileStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForInStatement(node) { + return convertIterationStatementBodyIfNecessary(node); } /** - * Visits an ImportDeclaration node. + * Visits a ForOfStatement and converts it into a compatible ForStatement. * - * @param node The ImportDeclaration node. + * @param node A ForOfStatement. */ - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } + function visitForOfStatement(node) { + return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + } + function convertForOfToFor(node, convertedLoopBodyStatements) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (var _i = 0, _a = expr; _i < _a.length; _i++) { + // var v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - statements.push(ts.createStatement(createRequireCall(node), - /*location*/ node)); + // In the case where the user wrote an identifier as the RHS, like this: + // + // for (let v of arr) { } + // + // we don't want to emit a temporary variable for the RHS, just use it directly. + var counter = ts.createLoopVariable(); + var rhsReference = expression.kind === 70 /* Identifier */ + ? ts.createUniqueName(expression.text) + : ts.createTempVariable(/*recordTempVariable*/ undefined); + // Initialize LHS + // var v = _a[_i]; + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + ts.setOriginalNode(declarationList, initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createConstDeclarationList(variables), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - // Set emitFlags on the name of the importEqualsDeclaration - // This is so the printer will not substitute the identifier - ts.setEmitFlags(node.name, 128 /* NoSubstitution */); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), - /*location*/ node)); + /*modifiers*/ undefined, declarationList)); } else { + // The following call does not include the initializer, so we have + // to emit it separately. statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES6 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) + ], /*location*/ ts.moveRangePos(initializer, -1)), + /*location*/ ts.moveRangeEnd(initializer, -1))); } } else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), - /*location*/ node)); + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); + if (ts.isDestructuringAssignment(assignment)) { + // This is a destructuring pattern, so we flatten the destructuring instead. + statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, + /*needsValue*/ false, hoistVariableDeclaration, visitor))); + } + else { + // Currently there is not way to check that assignment is binary expression of destructing assignment + // so we have to cast never type to binaryExpression + assignment.end = initializer.end; + statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); } } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier)); - } + else { + statements.push(statement); } - return ts.singleOrMany(statements); - } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); } + // The old emitter does not emit source maps for the expression + ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), + /*location*/ bodyLocation); + ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), + ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) + ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), + /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, + /*location*/ node); + // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. + ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + return forStatement; } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; + /** + * Visits an ObjectLiteralExpression with computed propety names. + * + * @param node An ObjectLiteralExpression node. + */ + function visitObjectLiteralExpression(node) { + // We are here because a ComputedPropertyName was used somewhere in the expression. + var properties = node.properties; + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialProperties = numProperties; + for (var i = 0; i < numProperties; i++) { + var property = properties[i]; + if (property.transformFlags & 16777216 /* ContainsYield */ + || property.name.kind === 141 /* ComputedPropertyName */) { + numInitialProperties = i; + break; } } - return undefined; + 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), 524288 /* 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); } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + function shouldConvertIterationStatementBody(node) { + return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256 /* SourceFile */); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + /** + * Records constituents of name for the given variable to be hoisted in the outer scope. + */ + function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(node.name); + function visit(node) { + if (node.kind === 70 /* Identifier */) { + state.hoistedLocalVariables.push(node); } else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); + for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + visit(element.name); + } + } + } + } + } + function convertIterationStatementBodyIfNecessary(node, convert) { + if (!shouldConvertIterationStatementBody(node)) { + var saveAllowedNonLabeledJumps = void 0; + if (convertedLoopState) { + // we get here if we are trying to emit normal loop loop inside converted loop + // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; } + var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + return result; } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); + var functionName = ts.createUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + var initializer = node.initializer; + if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + loopInitializer = initializer; + } + break; } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); + // variables that will be passed to the loop as parameters + var loopParameters = []; + // variables declared in the loop initializer that will be changed inside the loop + var loopOutParameters = []; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); } } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); + var outerConvertedLoopState = convertedLoopState; + convertedLoopState = { loopOutParameters: loopOutParameters }; + if (outerConvertedLoopState) { + // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. + // if outer converted loop has already accumulated some state - pass it through + if (outerConvertedLoopState.argumentsName) { + // outer loop has already used 'arguments' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), - /*location*/ specifier.name))); + if (outerConvertedLoopState.thisName) { + // outer loop has already used 'this' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.thisName = outerConvertedLoopState.thisName; + } + if (outerConvertedLoopState.hoistedLocalVariables) { + // we've already collected some non-block scoped variable declarations in enclosing loop + // use the same storage in nested loop + convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; } } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512 /* Default */)) { - addExportDefault(statements, getDeclarationName(node), /*location*/ node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var currentState = convertedLoopState; + convertedLoopState = outerConvertedLoopState; + if (loopOutParameters.length) { + var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; + copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); + loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); } - } - function visitVariableStatement(node) { - // If the variable is for a generated declaration, - // we should maintain it and just strip off the 'export' modifier if necessary. - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 /* ModuleDeclaration */ || - originalKind === 224 /* EnumDeclaration */ || - originalKind === 221 /* ClassDeclaration */) { - if (!ts.hasModifier(node, 1 /* Export */)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, node.declarationList), node); + if (!ts.isBlock(loopBody)) { + loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } - var resultStatements = []; - // If we're exporting these variables, then these just become assignments to 'exports.blah'. - // We only want to emit assignments for variables with initializers. - if (ts.hasModifier(node, 1 /* Export */)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } + var isAsyncBlockContainingAwait = enclosingNonArrowFunction + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 + && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var loopBodyFlags = 0; + if (currentState.containsLexicalThis) { + loopBodyFlags |= 256 /* CapturesThis */; } - else { - resultStatements.push(node); + if (isAsyncBlockContainingAwait) { + loopBodyFlags |= 2097152 /* AsyncFunctionBody */; } - // While we might not have been exported here, each variable might have been exported - // later on in an export specifier (e.g. `export {foo as blah, bar}`). - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); + var convertedLoopVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(functionName, + /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, loopParameters, + /*type*/ undefined, loopBody), loopBodyFlags)) + ])); + var statements = [convertedLoopVariable]; + var extraVariableDeclarations; + // propagate state from the inner loop to the outer loop if necessary + if (currentState.argumentsName) { + // if alias for arguments is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.argumentsName = currentState.argumentsName; + } + else { + // this is top level converted loop and we need to create an alias for 'arguments' object + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, + /*type*/ undefined, ts.createIdentifier("arguments"))); + } } - return resultStatements; - } - /** - * Creates appropriate assignments for each binding identifier that is exported in an export specifier, - * and inserts it into 'resultStatements'. - */ - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } + if (currentState.thisName) { + // if alias for this is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.thisName = currentState.thisName; + } + else { + // this is top level converted loop so we need to create an alias for 'this' here + // NOTE: + // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. + // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, + /*type*/ undefined, ts.createIdentifier("this"))); } } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + if (currentState.hoistedLocalVariables) { + // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later + if (outerConvertedLoopState) { + // pass them to outer converted loop + outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; + } + else { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + // hoist collected variable declarations + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; + extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); } } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); + // add extra variables to hold out parameters if necessary + if (loopOutParameters.length) { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; + extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); + } } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); + // create variable statement to hold all introduced variable declarations + if (extraVariableDeclarations) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var loop; + if (convert) { + loop = convert(node, convertedLoopBodyStatements); } else { - statements.push(node); + loop = ts.getMutableClone(node); + // clean statement part + loop.statement = undefined; + // visit childnodes to transform initializer/condition/incrementor parts + loop = ts.visitEachChild(loop, visitor, context); + // set loop statement + loop.statement = ts.createBlock(convertedLoopBodyStatements, + /*location*/ undefined, + /*multiline*/ true); + // reset and re-aggregate the transform flags + loop.transformFlags = 0; + ts.aggregateTransformFlags(loop); } - if (node.name) { - addExportMemberAssignments(statements, node.name); + statements.push(currentParent.kind === 215 /* LabeledStatement */ + ? ts.createLabel(currentParent.label, loop) + : loop); + return statements; + } + function copyOutParameter(outParam, copyDirection) { + var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; + return ts.createBinary(target, 57 /* EqualsToken */, source); + } + function copyOutParameters(outParams, copyDirection, statements) { + for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { + var outParam = outParams_1[_i]; + statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); } - return ts.singleOrMany(statements); } - function visitClassDeclaration(node) { + function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { + var outerConvertedLoopState = convertedLoopState; var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); + // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop + // simple loops are emitted as just 'loop()'; + // NOTE: if loop uses only 'continue' it still will be emitted as simple loop + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + !state.labeledNonLocalBreaks && + !state.labeledNonLocalContinues; + var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38 /* AsteriskToken */), call) : call; + if (isSimpleLoop) { + statements.push(ts.createStatement(callResult)); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); } else { - statements.push(node); - } - // Decorators end up creating a series of assignment expressions which overwrite - // the local binding that we export, so we need to defer from exporting decorated classes - // until the decoration assignments take place. We do this when visiting expression-statements. - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 224 /* EnumDeclaration */ || origKind === 225 /* ModuleDeclaration */) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 221 /* ClassDeclaration */) { - // The decorated assignment for a class name may need to be transformed. - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; + var loopResultName = ts.createUniqueName("state"); + var stateVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); + statements.push(stateVariable); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Return */) { + var returnStatement = void 0; + if (outerConvertedLoopState) { + outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; + returnStatement = ts.createReturn(loopResultName); + } + else { + returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + } + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + } + if (state.nonLocalJumps & 2 /* Break */) { + statements.push(ts.createIf(ts.createBinary(loopResultName, 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + } + if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { + var caseClauses = []; + processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); + processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); + statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); } } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - // Preserve old behavior for enums in which a variable statement is emitted after the body itself. - if (ts.hasModifier(original, 1 /* Export */) && - original.kind === 224 /* EnumDeclaration */ && - ts.isFirstDeclarationOfKind(original, 224 /* EnumDeclaration */)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); return statements; } - /** - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], - /*location*/ node); - ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = ts.createMap(); + } + state.labeledNonLocalBreaks[labelText] = labelMarker; } else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = ts.createMap(); } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); + state.labeledNonLocalContinues[labelText] = labelMarker; } - return node; } - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 186 /* PostfixUnaryExpression */: - case 185 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); + function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { + if (!table) { + return; } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; + for (var labelText in table) { + var labelMarker = table[labelText]; + var statements = []; + // 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])) { + var label = ts.createIdentifier(labelText); + statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + statements.push(ts.createReturn(loopResultName)); } + caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); } - return node; } - function substituteUnaryExpression(node) { - // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are - // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var transformedUnaryExpression = void 0; - if (node.kind === 186 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node); - // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); + function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { + var name = decl.name; + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + processLoopVariableDeclaration(element, loopParameters, loopOutParameters); } - return nestedExportAssignment; } } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144 /* LocalName */) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); - if (container) { - if (container.kind === 256 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } + else { + loopParameters.push(ts.createParameter(name)); + if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { + var outParamName = ts.createUniqueName("out_" + name.text); + loopOutParameters.push({ originalName: name, outParamName: outParamName }); } } - return undefined; } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - if (languageVersion >= 1 /* ES5 */) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), - /*location*/ node); - } - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - if (name_35.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), - /*location*/ node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), - /*location*/ node); + /** + * Adds the members of an object literal to an array of expressions. + * + * @param expressions An array of expressions. + * @param node An ObjectLiteralExpression node. + * @param receiver The receiver for members of the ObjectLiteralExpression. + * @param numInitialNonComputedProperties The number of initial properties without + * computed property names. + */ + function addObjectLiteralMembers(expressions, node, receiver, start) { + var properties = node.properties; + var numProperties = properties.length; + for (var i = start; i < numProperties; i++) { + var property = properties[i]; + switch (property.kind) { + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property === accessors.firstAccessor) { + expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } - } + break; + case 253 /* PropertyAssignment */: + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 254 /* ShorthandPropertyAssignment */: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 148 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; } } - return undefined; } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, - /*location*/ name); + /** + * Transforms a PropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the PropertyAssignment. + * @param property The PropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); + /** + * Transforms a ShorthandPropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. + * @param property The ShorthandPropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + return expression; } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); + /** + * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. + * + * @param node The ObjectLiteralExpression that contains the MethodDeclaration. + * @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), + /*location*/ method); + if (startsOnNewLine) { + expression.startsOnNewLine = true; } - return statement; + return expression; } - function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion === 0 /* ES3 */ - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + /** + * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a + * PropertyAssignment. + * + * @param node A MethodDeclaration node. + */ + function visitMethodDeclaration(node) { + // We should only get here for methods on an object literal with regular identifier names. + // 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); + ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + return ts.createPropertyAssignment(node.name, functionExpression, + /*location*/ node); } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + /** + * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. + * + * @param node A ShorthandPropertyAssignment node. + */ + function visitShorthandPropertyAssignment(node) { + return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + /*location*/ node); } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; + /** + * Visits a YieldExpression node. + * + * @param node A YieldExpression node. + */ + function visitYieldExpression(node) { + // `yield` expressions are transformed using the generators transformer. + return ts.visitEachChild(node, visitor, context); } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - var entities = createEntitiesMap(); - function transformJsx(context) { - var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; - return transformSourceFile; /** - * Transform JSX-specific syntax in a SourceFile. + * Visits an ArrayLiteralExpression that contains a spread element. * - * @param node A SourceFile node. + * @param node An ArrayLiteralExpression node. */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - node = ts.visitEachChild(node, visitor, context); - currentSourceFile = undefined; - return node; + function visitArrayLiteralExpression(node) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); } - function visitor(node) { - if (node.transformFlags & 4 /* Jsx */) { - return visitorWorker(node); + /** + * Visits a CallExpression that contains either a spread element or `super`. + * + * @param node a CallExpression. + */ + function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { + // We are here either because SuperKeyword was used somewhere in the expression, or + // because we contain a SpreadElementExpression. + var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 96 /* SuperKeyword */) { + ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); } - else if (node.transformFlags & 8 /* ContainsJsx */) { - return ts.visitEachChild(node, visitor, context); + var resultingCall; + if (node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) { + // [source] + // f(...a, b) + // x.m(...a, b) + // super(...a, b) + // super.m(...a, b) // in static + // super.m(...a, b) // in instance + // + // [output] + // f.apply(void 0, a.concat([b])) + // (_a = x).m.apply(_a, a.concat([b])) + // _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)); } else { - return node; + // [source] + // super(a) + // super.m(a) // in static + // super.m(a) // in instance + // + // [output] + // _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), + /*location*/ node); } - } - function visitorWorker(node) { - switch (node.kind) { - case 241 /* JsxElement */: - return visitJsxElement(node, /*isChild*/ false); - case 242 /* JsxSelfClosingElement */: - return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 248 /* JsxExpression */: - return visitJsxExpression(node); - default: - ts.Debug.failBadSyntaxKind(node); - return undefined; + if (node.expression.kind === 96 /* SuperKeyword */) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; } + return resultingCall; } - function transformJsxChildToExpression(node) { - switch (node.kind) { - case 244 /* JsxText */: - return visitJsxText(node); - case 248 /* JsxExpression */: - return visitJsxExpression(node); - case 241 /* JsxElement */: - return visitJsxElement(node, /*isChild*/ true); - case 242 /* JsxSelfClosingElement */: - return visitJsxSelfClosingElement(node, /*isChild*/ true); - default: - ts.Debug.failBadSyntaxKind(node); - return undefined; + /** + * Visits a NewExpression that contains a spread element. + * + * @param node A NewExpression node. + */ + function visitNewExpression(node) { + // We are here because we contain a SpreadElementExpression. + ts.Debug.assert((node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) !== 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, []); + } + /** + * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * + * @param elements The array of Expression nodes. + * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. + * @param multiLine A value indicating whether the result should be emitted on multiple lines. + */ + function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { + // [source] + // [a, ...b, c] + // + // [output] + // [a].concat(b, [c]) + // Map spans of spread expressions into their expressions and spans of other + // expressions into an array literal. + var numElements = elements.length; + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); + })); + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 /* ArrayLiteralExpression */ + ? ts.createArraySlice(segments[0]) + : segments[0]; } + // Rewrite using the pattern .concat(, , ...) + return ts.createArrayConcat(segments.shift(), segments); } - function visitJsxElement(node, isChild) { - return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, /*location*/ node); + function partitionSpreadElement(node) { + return ts.isSpreadElementExpression(node) + ? visitSpanOfSpreadElements + : visitSpanOfNonSpreadElements; } - function visitJsxSelfClosingElement(node, isChild) { - return visitJsxOpeningLikeElement(node, /*children*/ undefined, isChild, /*location*/ node); + function visitSpanOfSpreadElements(chunk) { + return ts.map(chunk, visitExpressionOfSpreadElement); } - function visitJsxOpeningLikeElement(node, children, isChild, location) { - var tagName = getTagName(node); - var objectProperties; - var attrs = node.attributes; - if (attrs.length === 0) { - // When there are no attributes, React wants "null" - objectProperties = ts.createNull(); - } - else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument. - segments.unshift(ts.createObjectLiteral()); - } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments) - || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); - } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); - if (isChild) { - ts.startOnNewLine(element); - } - return element; + function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), + /*location*/ undefined, multiLine); } - function transformJsxSpreadAttributeToExpression(node) { + /** + * Transforms the expression of a SpreadElementExpression node. + * + * @param node A SpreadElementExpression node. + */ + function visitExpressionOfSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } - function transformJsxAttributeToObjectLiteralElement(node) { - var name = getAttributeName(node); - var expression = transformJsxAttributeInitializer(node.initializer); - return ts.createPropertyAssignment(name, expression); + /** + * Visits a template literal. + * + * @param node A template literal. + */ + function visitTemplateLiteral(node) { + return ts.createLiteral(node.text, /*location*/ node); } - function transformJsxAttributeInitializer(node) { - if (node === undefined) { - return ts.createLiteral(true); + /** + * Visits a TaggedTemplateExpression node. + * + * @param node A TaggedTemplateExpression node. + */ + function visitTaggedTemplateExpression(node) { + // Visit the tag expression + var tag = ts.visitNode(node.tag, visitor, ts.isExpression); + // Allocate storage for the template site object + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Build up the template arguments and the raw and cooked strings for the template. + var templateArguments = [temp]; + var cookedStrings = []; + var rawStrings = []; + var template = node.template; + if (ts.isNoSubstitutionTemplateLiteral(template)) { + cookedStrings.push(ts.createLiteral(template.text)); + rawStrings.push(getRawLiteral(template)); } - else if (node.kind === 9 /* StringLiteral */) { - var decoded = tryDecodeEntities(node.text); - return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; + else { + cookedStrings.push(ts.createLiteral(template.head.text)); + rawStrings.push(getRawLiteral(template.head)); + for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { + var templateSpan = _a[_i]; + cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); + rawStrings.push(getRawLiteral(templateSpan.literal)); + templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); + } } - else if (node.kind === 248 /* JsxExpression */) { - return visitJsxExpression(node); + // NOTE: The parentheses here is entirely optional as we are now able to auto- + // parenthesize when rebuilding the tree. This should be removed in a + // future version. It is here for now to match our existing emit. + return ts.createParen(ts.inlineExpressions([ + ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), + ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), + ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) + ])); + } + /** + * Creates an ES5 compatible literal from an ES6 template literal. + * + * @param node The ES6 template literal. + */ + function getRawLiteral(node) { + // Find original source text, since we need to emit the raw strings of the tagged template. + // The raw strings contain the (escaped) strings of what the user wrote. + // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 12 /* NoSubstitutionTemplateLiteral */ || node.kind === 15 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + // Newline normalization: + // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's + // and LineTerminatorSequences are normalized to for both TV and TRV. + text = text.replace(/\r\n?/g, "\n"); + return ts.createLiteral(text, /*location*/ node); + } + /** + * Visits a TemplateExpression node. + * + * @param node A TemplateExpression node. + */ + function visitTemplateExpression(node) { + var expressions = []; + addTemplateHead(expressions, node); + addTemplateSpans(expressions, node); + // createAdd will check if each expression binds less closely than binary '+'. + // If it does, it wraps the expression in parentheses. Otherwise, something like + // `abc${ 1 << 2 }` + // becomes + // "abc" + 1 << 2 + "" + // which is really + // ("abc" + 1) << (2 + "") + // rather than + // "abc" + (1 << 2) + "" + var expression = ts.reduceLeft(expressions, ts.createAdd); + if (ts.nodeIsSynthesized(expression)) { + ts.setTextRange(expression, node); } - else { - ts.Debug.failBadSyntaxKind(node); + return expression; + } + /** + * Gets a value indicating whether we need to include the head of a TemplateExpression. + * + * @param node A TemplateExpression node. + */ + function shouldAddTemplateHead(node) { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // There is always atleast one templateSpan in this code path, since + // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + /** + * Adds the head of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateHead(expressions, node) { + if (!shouldAddTemplateHead(node)) { + return; } + expressions.push(ts.createLiteral(node.head.text)); } - function visitJsxText(node) { - var text = ts.getTextOfNode(node, /*includeTrivia*/ true); - var parts; - var firstNonWhitespace = 0; - var 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 (var i = 0; i < text.length; i++) { - var c = text.charCodeAt(i); - if (ts.isLineBreak(c)) { - if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { - var 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(ts.createLiteral(decodeEntities(part))); - } - firstNonWhitespace = -1; - } - else if (!ts.isWhiteSpace(c)) { - lastNonWhitespace = i; - if (firstNonWhitespace === -1) { - firstNonWhitespace = i; - } + /** + * Visits and adds the template spans of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateSpans(expressions, node) { + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span_6 = _a[_i]; + expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); + // Only emit if the literal is non-empty. + // The binary '+' operator is left-associative, so the first string concatenation + // with the head will force the result up to this point to be a string. + // Emitting a '+ ""' has no semantic effect for middles and tails. + if (span_6.literal.text.length !== 0) { + expressions.push(ts.createLiteral(span_6.literal.text)); } } - if (firstNonWhitespace !== -1) { - var 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(ts.createLiteral(decodeEntities(part))); + } + /** + * Visits the `super` keyword + */ + function visitSuperKeyword() { + return enclosingNonAsyncFunctionBody + && ts.isClassElement(enclosingNonAsyncFunctionBody) + && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) + && currentParent.kind !== 175 /* CallExpression */ + ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") + : ts.createIdentifier("_super"); + } + function visitSourceFileNode(node) { + var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + var statements = []; + startLexicalEnvironment(); + ts.addRange(statements, prologue); + addCaptureThisForNodeIfNeeded(statements, node); + ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); + ts.addRange(statements, endLexicalEnvironment()); + var clone = ts.getMutableClone(node); + clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); + return clone; + } + /** + * 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; + } + previousOnEmitNode(emitContext, node, emitCallback); + enclosingFunction = savedEnclosingFunction; + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains block-scoped bindings (e.g. `let` or `const`). + */ + function enableSubstitutionsForBlockScopedBindings() { + if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* BlockScopedBindings */; + context.enableSubstitution(70 /* Identifier */); } - if (parts) { - return ts.reduceLeft(parts, aggregateJsxTextParts); + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains a captured `this`. + */ + function enableSubstitutionsForCapturedThis() { + if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* CapturedThis */; + context.enableSubstitution(98 /* ThisKeyword */); + context.enableEmitNotification(149 /* Constructor */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(181 /* ArrowFunction */); + context.enableEmitNotification(180 /* FunctionExpression */); + context.enableEmitNotification(221 /* FunctionDeclaration */); } - return undefined; } /** - * Aggregates two expressions by interpolating them with a whitespace literal. + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. */ - function aggregateJsxTextParts(left, right) { - return ts.createAdd(ts.createAdd(left, ts.createLiteral(" ")), right); + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + if (ts.isIdentifier(node)) { + return substituteIdentifier(node); + } + return node; } /** - * Replace entities like " ", "{", and "�" with the characters they encode. - * See https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references + * Hooks substitutions for non-expression identifiers. */ - function decodeEntities(text) { - return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) { - if (decimal) { - return String.fromCharCode(parseInt(decimal, 10)); - } - else if (hex) { - return String.fromCharCode(parseInt(hex, 16)); - } - else { - var ch = entities[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; + function substituteIdentifier(node) { + // Only substitute the identifier if we have enabled substitutions for block-scoped + // bindings. + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var original = ts.getParseTreeNode(node, ts.isIdentifier); + if (original && isNameOfDeclarationWithCollidingName(original)) { + return ts.getGeneratedNameForNode(original); } - }); + } + return node; } - /** Like `decodeEntities` but returns `undefined` if there were no entities to decode. */ - function tryDecodeEntities(text) { - var decoded = decodeEntities(text); - return decoded === text ? undefined : decoded; + /** + * Determines whether a name is the name of a declaration with a colliding name. + * NOTE: This function expects to be called with an original source tree node. + * + * @param node An original source tree node. + */ + function isNameOfDeclarationWithCollidingName(node) { + var parent = node.parent; + switch (parent.kind) { + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + return parent.name === node + && resolver.isDeclarationWithCollidingName(parent); + } + return false; } - function getTagName(node) { - if (node.kind === 241 /* JsxElement */) { - return getTagName(node.openingElement); + /** + * Substitutes an expression. + * + * @param node An Expression node. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 98 /* ThisKeyword */: + return substituteThisKeyword(node); } - else { - 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_36); + return node; + } + /** + * Substitutes an expression identifier. + * + * @param node An Identifier node. + */ + function substituteExpressionIdentifier(node) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); + if (declaration) { + return ts.getGeneratedNameForNode(declaration.name); } } + return node; } /** - * Emit an attribute name, which is quoted if it needs to be quoted. Because - * these emit into an object literal property name, we don't need to be worried - * about keywords, just non-identifier characters + * Substitutes `this` when contained within an arrow function. + * + * @param node The ThisKeyword node. */ - function getAttributeName(node) { - var name = node.name; - if (/^[A-Za-z_]\w*$/.test(name.text)) { - return name; - } - else { - return ts.createLiteral(name.text); + function substituteThisKeyword(node) { + if (enabledSubstitutions & 1 /* CapturedThis */ + && enclosingFunction + && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { + return ts.createIdentifier("_this", /*location*/ node); } + return node; } - function visitJsxExpression(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); + /** + * Gets the local name for a declaration for use in expressions. + * + * A local name will *never* be prefixed with an module or namespace export modifier like + * "exports.". + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node, allowComments, allowSourceMaps) { + return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); } - } - ts.transformJsx = transformJsx; - function createEntitiesMap() { - return ts.createMap({ - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }); - } -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; + /** + * Gets the name of a declaration, without source map or comments. + * + * @param node The declaration. + * @param allowComments Allow comments for the name. + */ + function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && !ts.isGeneratedIdentifier(node.name)) { + var name_33 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= 1536 /* NoSourceMap */; + } + if (!allowComments) { + emitFlags |= 49152 /* NoComments */; + } + if (emitFlags) { + ts.setEmitFlags(name_33, emitFlags); + } + return name_33; } - return ts.visitEachChild(node, visitor, context); + return ts.getGeneratedNameForNode(node); } - function visitor(node) { - if (node.transformFlags & 16 /* ES7 */) { - return visitorWorker(node); - } - else if (node.transformFlags & 32 /* ContainsES7 */) { - return ts.visitEachChild(node, visitor, context); + function getClassMemberPrefix(node, member) { + var expression = getLocalName(node); + return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + } + function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { + if (!constructor || !hasExtendsClause) { + return false; } - else { - return node; + var parameter = ts.singleOrUndefined(constructor.parameters); + if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + return false; } - } - function visitorWorker(node) { - switch (node.kind) { - case 187 /* BinaryExpression */: - return visitBinaryExpression(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + var statement = ts.firstOrUndefined(constructor.body.statements); + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203 /* ExpressionStatement */) { + return false; } - } - function visitBinaryExpression(node) { - // We are here because ES7 adds support for the exponentiation operator. - var left = ts.visitNode(node.left, visitor, ts.isExpression); - var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { - var target = void 0; - var value = void 0; - if (ts.isElementAccessExpression(left)) { - // Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)` - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression), - /*location*/ left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, - /*location*/ left); - } - else if (ts.isPropertyAccessExpression(left)) { - // Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)` - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, /*location*/ left.expression), left.name, - /*location*/ left); - value = ts.createPropertyAccess(expressionTemp, left.name, - /*location*/ left); - } - else { - // Transforms `a **= b` into `a = Math.pow(a, b)` - target = left; - value = left; - } - return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); + var statementExpression = statement.expression; + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + return false; } - else if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */) { - // Transforms `a ** b` into `Math.pow(a, b)` - return ts.createMathPow(left, right, /*location*/ node); + var callTarget = statementExpression.expression; + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96 /* SuperKeyword */) { + return false; } - else { - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + var callArgument = ts.singleOrUndefined(statementExpression.arguments); + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192 /* SpreadElementExpression */) { + return false; } + var expression = callArgument.expression; + return ts.isIdentifier(expression) && expression === parameter.name; } } - ts.transformES7 = transformES7; + ts.transformES2015 = transformES2015; })(ts || (ts = {})); /// /// @@ -48214,7 +49378,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024 /* ContainsGenerator */) { + if (node.transformFlags & 4096 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -48234,10 +49398,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512 /* Generator */) { + else if (transformFlags & 2048 /* Generator */) { return visitGenerator(node); } - else if (transformFlags & 1024 /* ContainsGenerator */) { + else if (transformFlags & 4096 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -48251,13 +49415,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitWhileStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -48270,30 +49434,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return visitAccessorDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitVariableStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitForInStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return visitBreakStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return visitContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 /* ContainsGenerator */ | 8388608 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (4096 /* ContainsGenerator */ | 33554432 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -48308,21 +49472,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitConditionalExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitYieldExpression(node); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return visitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48335,9 +49499,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -48396,6 +49560,7 @@ var ts; // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, node.parameters, /*type*/ undefined, transformGeneratorFunctionBody(node.body), @@ -48497,7 +49662,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -48536,23 +49701,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 /* FirstCompoundAssignment */ - && kind <= 68 /* LastCompoundAssignment */; + return kind >= 58 /* FirstCompoundAssignment */ + && kind <= 69 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57 /* PlusEqualsToken */: return 35 /* PlusToken */; - case 58 /* MinusEqualsToken */: return 36 /* MinusToken */; - case 59 /* AsteriskEqualsToken */: return 37 /* AsteriskToken */; - case 60 /* AsteriskAsteriskEqualsToken */: return 38 /* AsteriskAsteriskToken */; - case 61 /* SlashEqualsToken */: return 39 /* SlashToken */; - case 62 /* PercentEqualsToken */: return 40 /* PercentToken */; - case 63 /* LessThanLessThanEqualsToken */: return 43 /* LessThanLessThanToken */; - case 64 /* GreaterThanGreaterThanEqualsToken */: return 44 /* GreaterThanGreaterThanToken */; - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanGreaterThanToken */; - case 66 /* AmpersandEqualsToken */: return 46 /* AmpersandToken */; - case 67 /* BarEqualsToken */: return 47 /* BarToken */; - case 68 /* CaretEqualsToken */: return 48 /* CaretToken */; + case 58 /* PlusEqualsToken */: return 36 /* PlusToken */; + case 59 /* MinusEqualsToken */: return 37 /* MinusToken */; + case 60 /* AsteriskEqualsToken */: return 38 /* AsteriskToken */; + case 61 /* AsteriskAsteriskEqualsToken */: return 39 /* AsteriskAsteriskToken */; + case 62 /* SlashEqualsToken */: return 40 /* SlashToken */; + case 63 /* PercentEqualsToken */: return 41 /* PercentToken */; + case 64 /* LessThanLessThanEqualsToken */: return 44 /* LessThanLessThanToken */; + case 65 /* GreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanToken */; + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanGreaterThanToken */; + case 67 /* AmpersandEqualsToken */: return 47 /* AmpersandToken */; + case 68 /* BarEqualsToken */: return 48 /* BarToken */; + case 69 /* CaretEqualsToken */: return 49 /* CaretToken */; } } /** @@ -48565,7 +49730,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -48577,7 +49742,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -48596,7 +49761,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -48609,7 +49774,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24 /* CommaToken */) { + else if (node.operatorToken.kind === 25 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -48620,10 +49785,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - 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; + var clone_6 = ts.getMutableClone(node); + clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -48664,7 +49829,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -48695,7 +49860,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -48785,7 +49950,7 @@ var ts; * @param elements The elements to visit. * @param multiLine Whether array literals created should be emitted on multiple lines. */ - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { // [source] // ar = [1, yield, 2]; // @@ -48877,10 +50042,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - 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; + var clone_7 = ts.getMutableClone(node); + clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_7; } return ts.visitEachChild(node, visitor, context); } @@ -48897,7 +50062,7 @@ var ts; // .mark resumeLabel // _b.apply(_a, _c.concat([%sent%, 2])); var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, /*cacheIdentifiers*/ true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false), + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); @@ -48915,7 +50080,7 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false)), + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), /*typeArguments*/ undefined, [], /*location*/ node), node); } @@ -48946,35 +50111,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199 /* Block */: + case 200 /* Block */: return transformAndEmitBlock(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return transformAndEmitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return transformAndEmitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return transformAndEmitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return transformAndEmitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -49538,7 +50703,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304 /* ContainsYield */) !== 0; + return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -49568,12 +50733,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_7 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_7, node); - ts.setCommentRange(clone_7, node); - return clone_7; + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); + return clone_8; } } } @@ -49626,3222 +50791,2468 @@ var ts; blockActions = []; blockOffsets = []; blockStack = []; - } - var index = blockActions.length; - blockActions[index] = 0 /* Open */; - blockOffsets[index] = operations ? operations.length : 0; - blocks[index] = block; - blockStack.push(block); - return index; - } - /** - * Ends the current block operation. - */ - function endBlock() { - var block = peekBlock(); - ts.Debug.assert(block !== undefined, "beginBlock was never called."); - var index = blockActions.length; - blockActions[index] = 1 /* Close */; - blockOffsets[index] = operations ? operations.length : 0; - blocks[index] = block; - blockStack.pop(); - return block; - } - /** - * Gets the current open block. - */ - function peekBlock() { - return ts.lastOrUndefined(blockStack); - } - /** - * Gets the kind of the current open block. - */ - function peekBlockKind() { - var block = peekBlock(); - return block && block.kind; - } - /** - * Begins a code block for a generated `with` statement. - * - * @param expression An identifier representing expression for the `with` block. - */ - function beginWithBlock(expression) { - var startLabel = defineLabel(); - var endLabel = defineLabel(); - markLabel(startLabel); - beginBlock({ - kind: 1 /* With */, - expression: expression, - startLabel: startLabel, - endLabel: endLabel - }); - } - /** - * Ends a code block for a generated `with` statement. - */ - function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); - var block = endBlock(); - markLabel(block.endLabel); - } - function isWithBlock(block) { - return block.kind === 1 /* With */; - } - /** - * Begins a code block for a generated `try` statement. - */ - function beginExceptionBlock() { - var startLabel = defineLabel(); - var endLabel = defineLabel(); - markLabel(startLabel); - beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, - startLabel: startLabel, - endLabel: endLabel - }); - emitNop(); - return endLabel; - } - /** - * Enters the `catch` clause of a generated `try` statement. - * - * @param variable The catch variable. - */ - function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var text = variable.name.text; - var name = declareLocal(text); - if (!renamedCatchVariables) { - renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69 /* Identifier */); - } - renamedCatchVariables[text] = true; - renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; - var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); - var endLabel = exception.endLabel; - emitBreak(endLabel); - var catchLabel = defineLabel(); - markLabel(catchLabel); - exception.state = 1 /* Catch */; - exception.catchVariable = name; - exception.catchLabel = catchLabel; - emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [])); - emitNop(); - } - /** - * Enters the `finally` block of a generated `try` statement. - */ - function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); - var endLabel = exception.endLabel; - emitBreak(endLabel); - var finallyLabel = defineLabel(); - markLabel(finallyLabel); - exception.state = 2 /* Finally */; - exception.finallyLabel = finallyLabel; - } - /** - * Ends the code block for a generated `try` statement. - */ - function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var exception = endBlock(); - var state = exception.state; - if (state < 2 /* Finally */) { - emitBreak(exception.endLabel); - } - else { - emitEndfinally(); - } - markLabel(exception.endLabel); - emitNop(); - exception.state = 3 /* Done */; - } - function isExceptionBlock(block) { - return block.kind === 0 /* Exception */; - } - /** - * Begins a code block that supports `break` or `continue` statements that are defined in - * the source tree and not from generated code. - * - * @param labelText Names from containing labeled statements. - */ - function beginScriptLoopBlock() { - beginBlock({ - kind: 3 /* Loop */, - isScript: true, - breakLabel: -1, - continueLabel: -1 - }); - } - /** - * Begins a code block that supports `break` or `continue` statements that are defined in - * generated code. Returns a label used to mark the operation to which to jump when a - * `break` statement targets this block. - * - * @param continueLabel A Label used to mark the operation to which to jump when a - * `continue` statement targets this block. - */ - function beginLoopBlock(continueLabel) { - var breakLabel = defineLabel(); - beginBlock({ - kind: 3 /* Loop */, - isScript: false, - breakLabel: breakLabel, - continueLabel: continueLabel - }); - return breakLabel; - } - /** - * Ends a code block that supports `break` or `continue` statements that are defined in - * generated code or in the source tree. - */ - function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); - var block = endBlock(); - var breakLabel = block.breakLabel; - if (!block.isScript) { - markLabel(breakLabel); - } - } - /** - * Begins a code block that supports `break` statements that are defined in the source - * tree and not from generated code. - * - */ - function beginScriptSwitchBlock() { - beginBlock({ - kind: 2 /* Switch */, - isScript: true, - breakLabel: -1 - }); - } - /** - * Begins a code block that supports `break` statements that are defined in generated code. - * Returns a label used to mark the operation to which to jump when a `break` statement - * targets this block. - */ - function beginSwitchBlock() { - var breakLabel = defineLabel(); - beginBlock({ - kind: 2 /* Switch */, - isScript: false, - breakLabel: breakLabel - }); - return breakLabel; - } - /** - * Ends a code block that supports `break` statements that are defined in generated code. - */ - function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); - var block = endBlock(); - var breakLabel = block.breakLabel; - if (!block.isScript) { - markLabel(breakLabel); - } - } - function beginScriptLabeledBlock(labelText) { - beginBlock({ - kind: 4 /* Labeled */, - isScript: true, - labelText: labelText, - breakLabel: -1 - }); - } - function beginLabeledBlock(labelText) { - var breakLabel = defineLabel(); - beginBlock({ - kind: 4 /* Labeled */, - isScript: false, - labelText: labelText, - breakLabel: breakLabel - }); - } - function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); - var block = endBlock(); - if (!block.isScript) { - markLabel(block.breakLabel); - } - } - /** - * Indicates whether the provided block supports `break` statements. - * - * @param block A code block. - */ - function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; - } - /** - * Indicates whether the provided block supports `break` statements with labels. - * - * @param block A code block. - */ - function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; - } - /** - * Indicates whether the provided block supports `continue` statements. - * - * @param block A code block. - */ - function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; - } - function hasImmediateContainingLabeledBlock(labelText, start) { - for (var j = start; j >= 0; j--) { - var containingBlock = blockStack[j]; - if (supportsLabeledBreakOrContinue(containingBlock)) { - if (containingBlock.labelText === labelText) { - return true; - } - } - else { - break; - } - } - return false; - } - /** - * Finds the label that is the target for a `break` statement. - * - * @param labelText An optional name of a containing labeled statement. - */ - function findBreakTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { - return block.breakLabel; - } - else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.breakLabel; - } - } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledBreak(block)) { - return block.breakLabel; - } - } - } - return 0; - } - /** - * Finds the label that is the target for a `continue` statement. - * - * @param labelText An optional name of a containing labeled statement. - */ - function findContinueTarget(labelText) { - ts.Debug.assert(blocks !== undefined); - if (labelText) { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { - return block.continueLabel; - } - } - } - else { - for (var i = blockStack.length - 1; i >= 0; i--) { - var block = blockStack[i]; - if (supportsUnlabeledContinue(block)) { - return block.continueLabel; - } - } - } - return 0; - } - /** - * Creates an expression that can be used to indicate the value for a label. - * - * @param label A label. - */ - function createLabel(label) { - if (label > 0) { - if (labelExpressions === undefined) { - labelExpressions = []; - } - var expression = ts.createSynthesizedNode(8 /* NumericLiteral */); - if (labelExpressions[label] === undefined) { - labelExpressions[label] = [expression]; - } - else { - labelExpressions[label].push(expression); - } - return expression; - } - return ts.createNode(193 /* OmittedExpression */); - } - /** - * Creates a numeric literal for the provided instruction. - */ - function createInstruction(instruction) { - var literal = ts.createLiteral(instruction); - literal.trailingComment = instructionNames[instruction]; - return literal; - } - /** - * Creates a statement that can be used indicate a Break operation to the provided label. - * - * @param label A label. - * @param location An optional source map location for the statement. - */ - function createInlineBreak(label, location) { - ts.Debug.assert(label > 0, "Invalid label: " + label); - return ts.createReturn(ts.createArrayLiteral([ - createInstruction(3 /* Break */), - createLabel(label) - ]), location); - } - /** - * Creates a statement that can be used indicate a Return operation. - * - * @param expression The expression for the return statement. - * @param location An optional source map location for the statement. - */ - function createInlineReturn(expression, location) { - return ts.createReturn(ts.createArrayLiteral(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), location); - } - /** - * Creates an expression that can be used to resume from a Yield operation. - */ - function createGeneratorResume(location) { - return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); - } - /** - * Emits an empty instruction. - */ - function emitNop() { - emitWorker(0 /* Nop */); - } - /** - * Emits a Statement. - * - * @param node A statement. - */ - function emitStatement(node) { - if (node) { - emitWorker(1 /* Statement */, [node]); - } - else { - emitNop(); - } - } - /** - * Emits an Assignment operation. - * - * @param left The left-hand side of the assignment. - * @param right The right-hand side of the assignment. - * @param location An optional source map location for the assignment. - */ - function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); - } - /** - * Emits a Break operation to the specified label. - * - * @param label A label. - * @param location An optional source map location for the assignment. - */ - function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); - } - /** - * Emits a Break operation to the specified label when a condition evaluates to a truthy - * value at runtime. - * - * @param label A label. - * @param condition The condition. - * @param location An optional source map location for the assignment. - */ - function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + } + var index = blockActions.length; + blockActions[index] = 0 /* Open */; + blockOffsets[index] = operations ? operations.length : 0; + blocks[index] = block; + blockStack.push(block); + return index; } /** - * Emits a Break to the specified label when a condition evaluates to a falsey value at - * runtime. - * - * @param label A label. - * @param condition The condition. - * @param location An optional source map location for the assignment. + * Ends the current block operation. */ - function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + function endBlock() { + var block = peekBlock(); + ts.Debug.assert(block !== undefined, "beginBlock was never called."); + var index = blockActions.length; + blockActions[index] = 1 /* Close */; + blockOffsets[index] = operations ? operations.length : 0; + blocks[index] = block; + blockStack.pop(); + return block; } /** - * Emits a YieldStar operation for the provided expression. - * - * @param expression An optional value for the yield operation. - * @param location An optional source map location for the assignment. + * Gets the current open block. */ - function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + function peekBlock() { + return ts.lastOrUndefined(blockStack); } /** - * Emits a Yield operation for the provided expression. - * - * @param expression An optional value for the yield operation. - * @param location An optional source map location for the assignment. + * Gets the kind of the current open block. */ - function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + function peekBlockKind() { + var block = peekBlock(); + return block && block.kind; } /** - * Emits a Return operation for the provided expression. + * Begins a code block for a generated `with` statement. * - * @param expression An optional value for the operation. - * @param location An optional source map location for the assignment. + * @param expression An identifier representing expression for the `with` block. */ - function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + function beginWithBlock(expression) { + var startLabel = defineLabel(); + var endLabel = defineLabel(); + markLabel(startLabel); + beginBlock({ + kind: 1 /* With */, + expression: expression, + startLabel: startLabel, + endLabel: endLabel + }); } /** - * Emits a Throw operation for the provided expression. - * - * @param expression A value for the operation. - * @param location An optional source map location for the assignment. + * Ends a code block for a generated `with` statement. */ - function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + function endWithBlock() { + ts.Debug.assert(peekBlockKind() === 1 /* With */); + var block = endBlock(); + markLabel(block.endLabel); + } + function isWithBlock(block) { + return block.kind === 1 /* With */; } /** - * Emits an Endfinally operation. This is used to handle `finally` block semantics. + * Begins a code block for a generated `try` statement. */ - function emitEndfinally() { - emitWorker(10 /* Endfinally */); + function beginExceptionBlock() { + var startLabel = defineLabel(); + var endLabel = defineLabel(); + markLabel(startLabel); + beginBlock({ + kind: 0 /* Exception */, + state: 0 /* Try */, + startLabel: startLabel, + endLabel: endLabel + }); + emitNop(); + return endLabel; } /** - * Emits an operation. + * Enters the `catch` clause of a generated `try` statement. * - * @param code The OpCode for the operation. - * @param args The optional arguments for the operation. + * @param variable The catch variable. */ - function emitWorker(code, args, location) { - if (operations === undefined) { - operations = []; - operationArguments = []; - operationLocations = []; - } - if (labelOffsets === undefined) { - // mark entry point - markLabel(defineLabel()); + function beginCatchBlock(variable) { + ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + var text = variable.name.text; + var name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = ts.createMap(); + renamedCatchVariableDeclarations = ts.createMap(); + context.enableSubstitution(70 /* Identifier */); } - var operationIndex = operations.length; - operations[operationIndex] = code; - operationArguments[operationIndex] = args; - operationLocations[operationIndex] = location; + renamedCatchVariables[text] = true; + renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; + var exception = peekBlock(); + ts.Debug.assert(exception.state < 1 /* Catch */); + var endLabel = exception.endLabel; + emitBreak(endLabel); + var catchLabel = defineLabel(); + markLabel(catchLabel); + exception.state = 1 /* Catch */; + exception.catchVariable = name; + exception.catchLabel = catchLabel; + emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [])); + emitNop(); } /** - * Builds the generator function body. + * Enters the `finally` block of a generated `try` statement. */ - function build() { - blockIndex = 0; - labelNumber = 0; - labelNumbers = undefined; - lastOperationWasAbrupt = false; - lastOperationWasCompletion = false; - clauses = undefined; - statements = undefined; - exceptionBlockStack = undefined; - currentExceptionBlock = undefined; - withBlockStack = undefined; - var buildResult = buildStatements(); - return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), - /*typeArguments*/ undefined, [ - ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(state)], - /*type*/ undefined, ts.createBlock(buildResult, - /*location*/ undefined, - /*multiLine*/ buildResult.length > 0)), 4194304 /* ReuseTempVariableScope */) - ]); + function beginFinallyBlock() { + ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + var exception = peekBlock(); + ts.Debug.assert(exception.state < 2 /* Finally */); + var endLabel = exception.endLabel; + emitBreak(endLabel); + var finallyLabel = defineLabel(); + markLabel(finallyLabel); + exception.state = 2 /* Finally */; + exception.finallyLabel = finallyLabel; } /** - * Builds the statements for the generator function body. + * Ends the code block for a generated `try` statement. */ - function buildStatements() { - if (operations) { - for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) { - writeOperation(operationIndex); - } - flushFinalLabel(operations.length); + function endExceptionBlock() { + ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + var exception = endBlock(); + var state = exception.state; + if (state < 2 /* Finally */) { + emitBreak(exception.endLabel); } else { - flushFinalLabel(0); - } - if (clauses) { - var labelExpression = ts.createPropertyAccess(state, "label"); - var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses)); - switchStatement.startsOnNewLine = true; - return [switchStatement]; - } - if (statements) { - return statements; + emitEndfinally(); } - return []; + markLabel(exception.endLabel); + emitNop(); + exception.state = 3 /* Done */; + } + function isExceptionBlock(block) { + return block.kind === 0 /* Exception */; } /** - * Flush the current label and advance to a new label. + * Begins a code block that supports `break` or `continue` statements that are defined in + * the source tree and not from generated code. + * + * @param labelText Names from containing labeled statements. */ - function flushLabel() { - if (!statements) { - return; - } - appendLabel(/*markLabelEnd*/ !lastOperationWasAbrupt); - lastOperationWasAbrupt = false; - lastOperationWasCompletion = false; - labelNumber++; + function beginScriptLoopBlock() { + beginBlock({ + kind: 3 /* Loop */, + isScript: true, + breakLabel: -1, + continueLabel: -1 + }); } /** - * Flush the final label of the generator function body. + * Begins a code block that supports `break` or `continue` statements that are defined in + * generated code. Returns a label used to mark the operation to which to jump when a + * `break` statement targets this block. + * + * @param continueLabel A Label used to mark the operation to which to jump when a + * `continue` statement targets this block. */ - function flushFinalLabel(operationIndex) { - if (isFinalLabelReachable(operationIndex)) { - tryEnterLabel(operationIndex); - withBlockStack = undefined; - writeReturn(/*expression*/ undefined, /*operationLocation*/ undefined); - } - if (statements && clauses) { - appendLabel(/*markLabelEnd*/ false); - } - updateLabelExpressions(); + function beginLoopBlock(continueLabel) { + var breakLabel = defineLabel(); + beginBlock({ + kind: 3 /* Loop */, + isScript: false, + breakLabel: breakLabel, + continueLabel: continueLabel + }); + return breakLabel; } /** - * Tests whether the final label of the generator function body - * is reachable by user code. + * Ends a code block that supports `break` or `continue` statements that are defined in + * generated code or in the source tree. */ - function isFinalLabelReachable(operationIndex) { - // if the last operation was *not* a completion (return/throw) then - // the final label is reachable. - if (!lastOperationWasCompletion) { - return true; - } - // if there are no labels defined or referenced, then the final label is - // not reachable. - if (!labelOffsets || !labelExpressions) { - return false; - } - // if the label for this offset is referenced, then the final label - // is reachable. - for (var label = 0; label < labelOffsets.length; label++) { - if (labelOffsets[label] === operationIndex && labelExpressions[label]) { - return true; - } + function endLoopBlock() { + ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + var block = endBlock(); + var breakLabel = block.breakLabel; + if (!block.isScript) { + markLabel(breakLabel); } - return false; } /** - * Appends a case clause for the last label and sets the new label. + * Begins a code block that supports `break` statements that are defined in the source + * tree and not from generated code. * - * @param markLabelEnd Indicates that the transition between labels was a fall-through - * from a previous case clause and the change in labels should be - * reflected on the `state` object. */ - function appendLabel(markLabelEnd) { - if (!clauses) { - clauses = []; - } - if (statements) { - if (withBlockStack) { - // The previous label was nested inside one or more `with` blocks, so we - // surround the statements in generated `with` blocks to create the same environment. - for (var i = withBlockStack.length - 1; i >= 0; i--) { - var withBlock = withBlockStack[i]; - statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))]; - } - } - if (currentExceptionBlock) { - // The previous label was nested inside of an exception block, so we must - // indicate entry into a protected region by pushing the label numbers - // for each block in the protected region. - var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; - statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), - /*typeArguments*/ undefined, [ - ts.createArrayLiteral([ - createLabel(startLabel), - createLabel(catchLabel), - createLabel(finallyLabel), - createLabel(endLabel) - ]) - ]))); - currentExceptionBlock = undefined; - } - if (markLabelEnd) { - // The case clause for the last label falls through to this label, so we - // add an assignment statement to reflect the change in labels. - statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); - } - } - clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); - statements = undefined; + function beginScriptSwitchBlock() { + beginBlock({ + kind: 2 /* Switch */, + isScript: true, + breakLabel: -1 + }); } /** - * Tries to enter into a new label at the current operation index. + * Begins a code block that supports `break` statements that are defined in generated code. + * Returns a label used to mark the operation to which to jump when a `break` statement + * targets this block. */ - function tryEnterLabel(operationIndex) { - if (!labelOffsets) { - return; - } - for (var label = 0; label < labelOffsets.length; label++) { - if (labelOffsets[label] === operationIndex) { - flushLabel(); - if (labelNumbers === undefined) { - labelNumbers = []; - } - if (labelNumbers[labelNumber] === undefined) { - labelNumbers[labelNumber] = [label]; - } - else { - labelNumbers[labelNumber].push(label); - } - } - } + function beginSwitchBlock() { + var breakLabel = defineLabel(); + beginBlock({ + kind: 2 /* Switch */, + isScript: false, + breakLabel: breakLabel + }); + return breakLabel; } /** - * Updates literal expressions for labels with actual label numbers. + * Ends a code block that supports `break` statements that are defined in generated code. */ - function updateLabelExpressions() { - if (labelExpressions !== undefined && labelNumbers !== undefined) { - for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) { - var labels = labelNumbers[labelNumber_1]; - if (labels !== undefined) { - for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) { - var label = labels_1[_i]; - var expressions = labelExpressions[label]; - if (expressions !== undefined) { - for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) { - var expression = expressions_1[_a]; - expression.text = String(labelNumber_1); - } - } - } - } - } + function endSwitchBlock() { + ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + var block = endBlock(); + var breakLabel = block.breakLabel; + if (!block.isScript) { + markLabel(breakLabel); } } - /** - * Tries to enter or leave a code block. - */ - function tryEnterOrLeaveBlock(operationIndex) { - if (blocks) { - for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { - var block = blocks[blockIndex]; - var blockAction = blockActions[blockIndex]; - if (isExceptionBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!exceptionBlockStack) { - exceptionBlockStack = []; - } - if (!statements) { - statements = []; - } - exceptionBlockStack.push(currentExceptionBlock); - currentExceptionBlock = block; - } - else if (blockAction === 1 /* Close */) { - currentExceptionBlock = exceptionBlockStack.pop(); - } - } - else if (isWithBlock(block)) { - if (blockAction === 0 /* Open */) { - if (!withBlockStack) { - withBlockStack = []; - } - withBlockStack.push(block); - } - else if (blockAction === 1 /* Close */) { - withBlockStack.pop(); - } - } - } + function beginScriptLabeledBlock(labelText) { + beginBlock({ + kind: 4 /* Labeled */, + isScript: true, + labelText: labelText, + breakLabel: -1 + }); + } + function beginLabeledBlock(labelText) { + var breakLabel = defineLabel(); + beginBlock({ + kind: 4 /* Labeled */, + isScript: false, + labelText: labelText, + breakLabel: breakLabel + }); + } + function endLabeledBlock() { + ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + var block = endBlock(); + if (!block.isScript) { + markLabel(block.breakLabel); } } /** - * Writes an operation as a statement to the current label's statement list. + * Indicates whether the provided block supports `break` statements. * - * @param operation The OpCode of the operation + * @param block A code block. */ - function writeOperation(operationIndex) { - tryEnterLabel(operationIndex); - tryEnterOrLeaveBlock(operationIndex); - // early termination, nothing else to process in this label - if (lastOperationWasAbrupt) { - return; - } - lastOperationWasAbrupt = false; - lastOperationWasCompletion = false; - var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { - return; - } - else if (opcode === 10 /* Endfinally */) { - return writeEndfinally(); - } - var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { - return writeStatement(args[0]); - } - var location = operationLocations[operationIndex]; - switch (opcode) { - case 2 /* Assign */: - return writeAssign(args[0], args[1], location); - case 3 /* Break */: - return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: - return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: - return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: - return writeYield(args[0], location); - case 7 /* YieldStar */: - return writeYieldStar(args[0], location); - case 8 /* Return */: - return writeReturn(args[0], location); - case 9 /* Throw */: - return writeThrow(args[0], location); - } + function supportsUnlabeledBreak(block) { + return block.kind === 2 /* Switch */ + || block.kind === 3 /* Loop */; } /** - * Writes a statement to the current label's statement list. + * Indicates whether the provided block supports `break` statements with labels. * - * @param statement A statement to write. + * @param block A code block. */ - function writeStatement(statement) { - if (statement) { - if (!statements) { - statements = [statement]; - } - else { - statements.push(statement); - } - } + function supportsLabeledBreakOrContinue(block) { + return block.kind === 4 /* Labeled */; } /** - * Writes an Assign operation to the current label's statement list. + * Indicates whether the provided block supports `continue` statements. * - * @param left The left-hand side of the assignment. - * @param right The right-hand side of the assignment. - * @param operationLocation The source map location for the operation. + * @param block A code block. */ - function writeAssign(left, right, operationLocation) { - writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); + function supportsUnlabeledContinue(block) { + return block.kind === 3 /* Loop */; + } + function hasImmediateContainingLabeledBlock(labelText, start) { + for (var j = start; j >= 0; j--) { + var containingBlock = blockStack[j]; + if (supportsLabeledBreakOrContinue(containingBlock)) { + if (containingBlock.labelText === labelText) { + return true; + } + } + else { + break; + } + } + return false; } /** - * Writes a Throw operation to the current label's statement list. + * Finds the label that is the target for a `break` statement. * - * @param expression The value to throw. - * @param operationLocation The source map location for the operation. + * @param labelText An optional name of a containing labeled statement. */ - function writeThrow(expression, operationLocation) { - lastOperationWasAbrupt = true; - lastOperationWasCompletion = true; - writeStatement(ts.createThrow(expression, operationLocation)); + function findBreakTarget(labelText) { + ts.Debug.assert(blocks !== undefined); + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) { + return block.breakLabel; + } + else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.breakLabel; + } + } + } + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledBreak(block)) { + return block.breakLabel; + } + } + } + return 0; } /** - * Writes a Return operation to the current label's statement list. + * Finds the label that is the target for a `continue` statement. * - * @param expression The value to return. - * @param operationLocation The source map location for the operation. + * @param labelText An optional name of a containing labeled statement. */ - function writeReturn(expression, operationLocation) { - lastOperationWasAbrupt = true; - lastOperationWasCompletion = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)]), operationLocation)); + function findContinueTarget(labelText) { + ts.Debug.assert(blocks !== undefined); + if (labelText) { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) { + return block.continueLabel; + } + } + } + else { + for (var i = blockStack.length - 1; i >= 0; i--) { + var block = blockStack[i]; + if (supportsUnlabeledContinue(block)) { + return block.continueLabel; + } + } + } + return 0; } /** - * Writes a Break operation to the current label's statement list. + * Creates an expression that can be used to indicate the value for a label. * - * @param label The label for the Break. - * @param operationLocation The source map location for the operation. + * @param label A label. */ - function writeBreak(label, operationLocation) { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ - createInstruction(3 /* Break */), - createLabel(label) - ]), operationLocation)); + function createLabel(label) { + if (label > 0) { + if (labelExpressions === undefined) { + labelExpressions = []; + } + var expression = ts.createSynthesizedNode(8 /* NumericLiteral */); + if (labelExpressions[label] === undefined) { + labelExpressions[label] = [expression]; + } + else { + labelExpressions[label].push(expression); + } + return expression; + } + return ts.createNode(194 /* OmittedExpression */); } /** - * Writes a BreakWhenTrue operation to the current label's statement list. - * - * @param label The label for the Break. - * @param condition The condition for the Break. - * @param operationLocation The source map location for the operation. + * Creates a numeric literal for the provided instruction. */ - function writeBreakWhenTrue(label, condition, operationLocation) { - writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ - createInstruction(3 /* Break */), - createLabel(label) - ]), operationLocation))); + function createInstruction(instruction) { + var literal = ts.createLiteral(instruction); + literal.trailingComment = instructionNames[instruction]; + return literal; } /** - * Writes a BreakWhenFalse operation to the current label's statement list. + * Creates a statement that can be used indicate a Break operation to the provided label. * - * @param label The label for the Break. - * @param condition The condition for the Break. - * @param operationLocation The source map location for the operation. + * @param label A label. + * @param location An optional source map location for the statement. */ - function writeBreakWhenFalse(label, condition, operationLocation) { - writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + function createInlineBreak(label, location) { + ts.Debug.assert(label > 0, "Invalid label: " + label); + return ts.createReturn(ts.createArrayLiteral([ createInstruction(3 /* Break */), createLabel(label) - ]), operationLocation))); + ]), location); } /** - * Writes a Yield operation to the current label's statement list. + * Creates a statement that can be used indicate a Return operation. * - * @param expression The expression to yield. - * @param operationLocation The source map location for the operation. + * @param expression The expression for the return statement. + * @param location An optional source map location for the statement. */ - function writeYield(expression, operationLocation) { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)]), operationLocation)); + function createInlineReturn(expression, location) { + return ts.createReturn(ts.createArrayLiteral(expression + ? [createInstruction(2 /* Return */), expression] + : [createInstruction(2 /* Return */)]), location); } /** - * Writes a YieldStar instruction to the current label's statement list. - * - * @param expression The expression to yield. - * @param operationLocation The source map location for the operation. + * Creates an expression that can be used to resume from a Yield operation. */ - function writeYieldStar(expression, operationLocation) { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ - createInstruction(5 /* YieldStar */), - expression - ]), operationLocation)); + function createGeneratorResume(location) { + return ts.createCall(ts.createPropertyAccess(state, "sent"), /*typeArguments*/ undefined, [], location); } /** - * Writes an Endfinally instruction to the current label's statement list. + * Emits an empty instruction. */ - function writeEndfinally() { - lastOperationWasAbrupt = true; - writeStatement(ts.createReturn(ts.createArrayLiteral([ - createInstruction(7 /* Endfinally */) - ]))); + function emitNop() { + emitWorker(0 /* Nop */); } - } - ts.transformGenerators = transformGenerators; - var _a; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - var ES6SubstitutionFlags; - (function (ES6SubstitutionFlags) { - /** Enables substitutions for captured `this` */ - ES6SubstitutionFlags[ES6SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; - /** Enables substitutions for block-scoped bindings. */ - ES6SubstitutionFlags[ES6SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; - })(ES6SubstitutionFlags || (ES6SubstitutionFlags = {})); - var CopyDirection; - (function (CopyDirection) { - CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; - CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; - })(CopyDirection || (CopyDirection = {})); - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); - var SuperCaptureResult; - (function (SuperCaptureResult) { - /** - * A capture may have been added for calls to 'super', but - * the caller should emit subsequent statements normally. - */ - SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; - /** - * A call to 'super()' got replaced with a capturing statement like: - * - * var _this = _super.call(...) || this; - * - * Callers should skip the current statement. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; /** - * A call to 'super()' got replaced with a capturing statement like: - * - * return _super.call(...) || this; + * Emits a Statement. * - * Callers should skip the current statement and avoid any returns of '_this'. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; - })(SuperCaptureResult || (SuperCaptureResult = {})); - function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var resolver = context.getEmitResolver(); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; - context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; - var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - /** - * Used to track if we are emitting body of the converted loop - */ - var convertedLoopState; - /** - * Keeps track of whether substitutions have been enabled for specific cases. - * They are persisted between each SourceFile transformation and should not - * be reset. + * @param node A statement. */ - var enabledSubstitutions; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - currentText = node.text; - return ts.visitNode(node, visitor, ts.isSourceFile); - } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); - } - 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; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy - convertedLoopState = undefined; - } - onBeforeVisitNode(node); - var visited = f(node); - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES6 */) !== 0 || - node.kind === 214 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); - } - function visitorWorker(node) { - if (shouldCheckNode(node)) { - return visitJavaScript(node); - } - else if (node.transformFlags & 128 /* ContainsES6 */) { - return ts.visitEachChild(node, visitor, context); - } - else { - return node; - } - } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); + function emitStatement(node) { + if (node) { + emitWorker(1 /* Statement */, [node]); } else { - result = visitNodesInConvertedLoop(node); - } - return result; - } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 211 /* ReturnStatement */: - return visitReturnStatement(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 97 /* ThisKeyword */: - return visitThisKeyword(node); - case 69 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitJavaScript(node) { - switch (node.kind) { - case 82 /* ExportKeyword */: - return node; - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 192 /* ClassExpression */: - return visitClassExpression(node); - case 142 /* Parameter */: - return visitParameter(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 180 /* ArrowFunction */: - return visitArrowFunction(node); - case 179 /* FunctionExpression */: - return visitFunctionExpression(node); - case 218 /* VariableDeclaration */: - return visitVariableDeclaration(node); - case 69 /* Identifier */: - return visitIdentifier(node); - case 219 /* VariableDeclarationList */: - return visitVariableDeclarationList(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 206 /* ForStatement */: - return visitForStatement(node); - case 207 /* ForInStatement */: - return visitForInStatement(node); - case 208 /* ForOfStatement */: - return visitForOfStatement(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - case 171 /* ObjectLiteralExpression */: - return visitObjectLiteralExpression(node); - case 254 /* ShorthandPropertyAssignment */: - return visitShorthandPropertyAssignment(node); - case 170 /* ArrayLiteralExpression */: - return visitArrayLiteralExpression(node); - case 174 /* CallExpression */: - return visitCallExpression(node); - case 175 /* NewExpression */: - return visitNewExpression(node); - case 178 /* ParenthesizedExpression */: - return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 187 /* BinaryExpression */: - return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return visitTemplateLiteral(node); - case 176 /* TaggedTemplateExpression */: - return visitTaggedTemplateExpression(node); - case 189 /* TemplateExpression */: - return visitTemplateExpression(node); - case 190 /* YieldExpression */: - return visitYieldExpression(node); - case 95 /* SuperKeyword */: - return visitSuperKeyword(node); - case 190 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); - case 147 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 256 /* SourceFile */: - return visitSourceFileNode(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); - } - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 2097152 /* 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 200 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 219 /* VariableDeclarationList */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - 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; - } - 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()) - ])); - } - function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; - } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); - } - function visitIdentifier(node) { - if (!convertedLoopState) { - return node; - } - if (ts.isGeneratedIdentifier(node)) { - return node; - } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { - return node; + emitNop(); } - return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); } - function visitBreakOrContinueStatement(node) { - if (convertedLoopState) { - // check if we can emit break/continue as is - // 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 === 210 /* 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 === 210 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; - labelMarker = "break"; - } - else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; - // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. - labelMarker = "continue"; - } - } - else { - if (node.kind === 210 /* BreakStatement */) { - labelMarker = "break-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); - } - else { - labelMarker = "continue-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); - } - } - var returnExpression = ts.createLiteral(labelMarker); - if (convertedLoopState.loopOutParameters.length) { - var outParams = convertedLoopState.loopOutParameters; - var expr = void 0; - for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); - if (i === 0) { - expr = copyExpr; - } - else { - expr = ts.createBinary(expr, 24 /* CommaToken */, copyExpr); - } - } - returnExpression = ts.createBinary(expr, 24 /* CommaToken */, returnExpression); - } - return ts.createReturn(returnExpression); - } - } - return ts.visitEachChild(node, visitor, context); + /** + * Emits an Assignment operation. + * + * @param left The left-hand side of the assignment. + * @param right The right-hand side of the assignment. + * @param location An optional source map location for the assignment. + */ + function emitAssignment(left, right, location) { + emitWorker(2 /* Assign */, [left, right], location); } /** - * Visits a ClassDeclaration and transforms it into a variable statement. + * Emits a Break operation to the specified label. * - * @param node A ClassDeclaration node. + * @param label A label. + * @param location An optional source map location for the assignment. */ - function visitClassDeclaration(node) { - // [source] - // class C { } - // - // [output] - // var C = (function () { - // function C() { - // } - // return C; - // }()); - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1 /* Export */; - var isDefault = modifierFlags & 512 /* Default */; - // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), - /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) - ]), - /*location*/ node); - ts.setOriginalNode(statement, node); - ts.startOnNewLine(statement); - // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); - return statements; - } - return statement; + function emitBreak(label, location) { + emitWorker(3 /* Break */, [label], location); } - function isExportModifier(node) { - return node.kind === 82 /* ExportKeyword */; + /** + * Emits a Break operation to the specified label when a condition evaluates to a truthy + * value at runtime. + * + * @param label A label. + * @param condition The condition. + * @param location An optional source map location for the assignment. + */ + function emitBreakWhenTrue(label, condition, location) { + emitWorker(4 /* BreakWhenTrue */, [label, condition], location); } /** - * Visits a ClassExpression and transforms it into an expression. + * Emits a Break to the specified label when a condition evaluates to a falsey value at + * runtime. * - * @param node A ClassExpression node. + * @param label A label. + * @param condition The condition. + * @param location An optional source map location for the assignment. */ - function visitClassExpression(node) { - // [source] - // C = class { } - // - // [output] - // C = (function () { - // function class_1() { - // } - // return class_1; - // }()) - return transformClassLikeDeclarationToExpression(node); + function emitBreakWhenFalse(label, condition, location) { + emitWorker(5 /* BreakWhenFalse */, [label, condition], location); } /** - * Transforms a ClassExpression or ClassDeclaration into an expression. + * Emits a YieldStar operation for the provided expression. * - * @param node A ClassExpression or ClassDeclaration node. + * @param expression An optional value for the yield operation. + * @param location An optional source map location for the assignment. */ - function transformClassLikeDeclarationToExpression(node) { - // [source] - // class C extends D { - // constructor() {} - // method() {} - // get prop() {} - // set prop(v) {} - // } - // - // [output] - // (function (_super) { - // __extends(C, _super); - // function C() { - // } - // C.prototype.method = function () {} - // Object.defineProperty(C.prototype, "prop", { - // get: function() {}, - // set: function() {}, - // enumerable: true, - // configurable: true - // }); - // return C; - // }(D)) - if (node.name) { - enableSubstitutionsForBlockScopedBindings(); - } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], - /*type*/ undefined, transformClassBody(node, extendsClauseElement)); - // To preserve the behavior of the old emitter, we explicitly indent - // the body of the function here if it was requested in an earlier - // transformation. - if (ts.getEmitFlags(node) & 524288 /* Indented */) { - ts.setEmitFlags(classFunction, 524288 /* Indented */); - } - // "inner" and "outer" below are added purely to preserve source map locations from - // the old emitter - var inner = ts.createPartiallyEmittedExpression(classFunction); - inner.end = node.end; - ts.setEmitFlags(inner, 49152 /* NoComments */); - var outer = ts.createPartiallyEmittedExpression(inner); - outer.end = ts.skipTrivia(currentText, node.pos); - ts.setEmitFlags(outer, 49152 /* NoComments */); - return ts.createParen(ts.createCall(outer, - /*typeArguments*/ undefined, extendsClauseElement - ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] - : [])); + function emitYieldStar(expression, location) { + emitWorker(7 /* YieldStar */, [expression], location); } /** - * Transforms a ClassExpression or ClassDeclaration into a function body. + * Emits a Yield operation for the provided expression. * - * @param node A ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. + * @param expression An optional value for the yield operation. + * @param location An optional source map location for the assignment. */ - function transformClassBody(node, extendsClauseElement) { - var statements = []; - startLexicalEnvironment(); - addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); - addClassMembers(statements, node); - // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16 /* CloseBraceToken */); - var localName = getLocalName(node); - // The following partially-emitted expression exists purely to align our sourcemap - // emit with the original emitter. - var outer = ts.createPartiallyEmittedExpression(localName); - outer.end = closingBraceLocation.end; - ts.setEmitFlags(outer, 49152 /* NoComments */); - var statement = ts.createReturn(outer); - statement.pos = closingBraceLocation.pos; - ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); - statements.push(statement); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); - ts.setEmitFlags(block, 49152 /* NoComments */); - return block; + function emitYield(expression, location) { + emitWorker(6 /* Yield */, [expression], location); } /** - * Adds a call to the `__extends` helper if needed for a class. + * Emits a Return operation for the provided expression. * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. + * @param expression An optional value for the operation. + * @param location An optional source map location for the assignment. */ - function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { - if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), - /*location*/ extendsClauseElement)); - } + function emitReturn(expression, location) { + emitWorker(8 /* Return */, [expression], location); } /** - * Adds the constructor of the class to a class body function. + * Emits a Throw operation for the provided expression. * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. + * @param expression A value for the operation. + * @param location An optional source map location for the assignment. */ - function addConstructor(statements, node, extendsClauseElement) { - var constructor = ts.getFirstConstructorWithBody(node); - var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, getDeclarationName(node), - /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); - if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); - } - statements.push(constructorFunction); + function emitThrow(expression, location) { + emitWorker(9 /* Throw */, [expression], location); } /** - * Transforms the parameters of the constructor declaration of a class. + * Emits an Endfinally operation. This is used to handle `finally` block semantics. + */ + function emitEndfinally() { + emitWorker(10 /* Endfinally */); + } + /** + * Emits an operation. * - * @param constructor The constructor for the class. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. + * @param code The OpCode for the operation. + * @param args The optional arguments for the operation. */ - function transformConstructorParameters(constructor, hasSynthesizedSuper) { - // If the TypeScript transformer needed to synthesize a constructor for property - // initializers, it would have also added a synthetic `...args` parameter and - // `super` call. - // If this is the case, we do not include the synthetic `...args` parameter and - // will instead use the `arguments` object in ES5/3. - if (constructor && !hasSynthesizedSuper) { - return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); + function emitWorker(code, args, location) { + if (operations === undefined) { + operations = []; + operationArguments = []; + operationLocations = []; } - return []; + if (labelOffsets === undefined) { + // mark entry point + markLabel(defineLabel()); + } + var operationIndex = operations.length; + operations[operationIndex] = code; + operationArguments[operationIndex] = args; + operationLocations[operationIndex] = location; } /** - * Transforms the body of a constructor declaration of a class. - * - * @param constructor The constructor for the class. - * @param node The node which contains the constructor. - * @param extendsClauseElement The expression for the class `extends` clause. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. + * Builds the generator function body. */ - function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { - var statements = []; - startLexicalEnvironment(); - var statementOffset = -1; - if (hasSynthesizedSuper) { - // If a super call has already been synthesized, - // we're going to assume that we should just transform everything after that. - // The assumption is that no prior step in the pipeline has added any prologue directives. - statementOffset = 1; + function build() { + blockIndex = 0; + labelNumber = 0; + labelNumbers = undefined; + lastOperationWasAbrupt = false; + lastOperationWasCompletion = false; + clauses = undefined; + statements = undefined; + exceptionBlockStack = undefined; + currentExceptionBlock = undefined; + withBlockStack = undefined; + var buildResult = buildStatements(); + return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), + /*typeArguments*/ undefined, [ + ts.createThis(), + ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(state)], + /*type*/ undefined, ts.createBlock(buildResult, + /*location*/ undefined, + /*multiLine*/ buildResult.length > 0)), 4194304 /* ReuseTempVariableScope */) + ]); + } + /** + * Builds the statements for the generator function body. + */ + function buildStatements() { + if (operations) { + for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) { + writeOperation(operationIndex); + } + flushFinalLabel(operations.length); } - else if (constructor) { - // Otherwise, try to emit all potential prologue directives first. - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + else { + flushFinalLabel(0); } - if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); - ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + if (clauses) { + var labelExpression = ts.createPropertyAccess(state, "label"); + var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses)); + switchStatement.startsOnNewLine = true; + return [switchStatement]; } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); - // The last statement expression was replaced. Skip it. - if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { - statementOffset++; + if (statements) { + return statements; } - if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); - ts.addRange(statements, body); + return []; + } + /** + * Flush the current label and advance to a new label. + */ + function flushLabel() { + if (!statements) { + return; } - // 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 - && superCaptureStatus !== 2 /* ReplaceWithReturn */ - && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { - statements.push(ts.createReturn(ts.createIdentifier("_this"))); + appendLabel(/*markLabelEnd*/ !lastOperationWasAbrupt); + lastOperationWasAbrupt = false; + lastOperationWasCompletion = false; + labelNumber++; + } + /** + * Flush the final label of the generator function body. + */ + function flushFinalLabel(operationIndex) { + if (isFinalLabelReachable(operationIndex)) { + tryEnterLabel(operationIndex); + withBlockStack = undefined; + writeReturn(/*expression*/ undefined, /*operationLocation*/ undefined); } - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, - /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, - /*multiLine*/ true); - if (!constructor) { - ts.setEmitFlags(block, 49152 /* NoComments */); + if (statements && clauses) { + appendLabel(/*markLabelEnd*/ false); } - return block; + updateLabelExpressions(); } /** - * We want to try to avoid emitting a return statement in certain cases if a user already returned something. - * It would generate obviously dead code, so we'll try to make things a little bit prettier - * by doing a minimal check on whether some common patterns always explicitly return. + * Tests whether the final label of the generator function body + * is reachable by user code. */ - function isSufficientlyCoveredByReturnStatements(statement) { - // A return statement is considered covered. - if (statement.kind === 211 /* ReturnStatement */) { + function isFinalLabelReachable(operationIndex) { + // if the last operation was *not* a completion (return/throw) then + // the final label is reachable. + if (!lastOperationWasCompletion) { return true; } - else if (statement.kind === 203 /* IfStatement */) { - var ifStatement = statement; - if (ifStatement.elseStatement) { - return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && - isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); - } + // if there are no labels defined or referenced, then the final label is + // not reachable. + if (!labelOffsets || !labelExpressions) { + return false; } - else if (statement.kind === 199 /* Block */) { - var lastStatement = ts.lastOrUndefined(statement.statements); - if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + // if the label for this offset is referenced, then the final label + // is reachable. + for (var label = 0; label < labelOffsets.length; label++) { + if (labelOffsets[label] === operationIndex && labelExpressions[label]) { return true; } } return false; } /** - * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. + * Appends a case clause for the last label and sets the new label. * - * @returns The new statement offset into the `statements` array. + * @param markLabelEnd Indicates that the transition between labels was a fall-through + * from a previous case clause and the change in labels should be + * reflected on the `state` object. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { - if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + function appendLabel(markLabelEnd) { + if (!clauses) { + clauses = []; + } + if (statements) { + if (withBlockStack) { + // The previous label was nested inside one or more `with` blocks, so we + // surround the statements in generated `with` blocks to create the same environment. + for (var i = withBlockStack.length - 1; i >= 0; i--) { + var withBlock = withBlockStack[i]; + statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))]; + } + } + if (currentExceptionBlock) { + // The previous label was nested inside of an exception block, so we must + // indicate entry into a protected region by pushing the label numbers + // for each block in the protected region. + var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel; + statements.unshift(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), + /*typeArguments*/ undefined, [ + ts.createArrayLiteral([ + createLabel(startLabel), + createLabel(catchLabel), + createLabel(finallyLabel), + createLabel(endLabel) + ]) + ]))); + currentExceptionBlock = undefined; + } + if (markLabelEnd) { + // The case clause for the last label falls through to this label, so we + // add an assignment statement to reflect the change in labels. + statements.push(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1)))); } - return 0 /* NoReplacement */; } - // We must be here because the user didn't write a constructor - // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. - // If that's the case we can just immediately return the result of a 'super()' call. - if (!ctor) { - statements.push(ts.createReturn(createDefaultSuperCallOrThis())); - return 2 /* ReplaceWithReturn */; + clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || [])); + statements = undefined; + } + /** + * Tries to enter into a new label at the current operation index. + */ + function tryEnterLabel(operationIndex) { + if (!labelOffsets) { + return; } - // The constructor exists, but it and the 'super()' call it contains were generated - // for something like property initializers. - // Create a captured '_this' variable and assume it will subsequently be used. - if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); - enableSubstitutionsForCapturedThis(); - return 1 /* ReplaceSuperCapture */; + for (var label = 0; label < labelOffsets.length; label++) { + if (labelOffsets[label] === operationIndex) { + flushLabel(); + if (labelNumbers === undefined) { + labelNumbers = []; + } + if (labelNumbers[labelNumber] === undefined) { + labelNumbers[labelNumber] = [label]; + } + else { + labelNumbers[labelNumber].push(label); + } + } } - // Most of the time, a 'super' call will be the first real statement in a constructor body. - // In these cases, we'd like to transform these into a *single* statement instead of a declaration - // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, - // we'd get: - // - // var _this; - // _this = _super.call(...) || this; - // - // instead of - // - // var _this = _super.call(...) || this; - // - // Additionally, if the 'super()' call is the last statement, we should just avoid capturing - // entirely and immediately return the result like so: - // - // return _super.call(...) || this; - // - var firstStatement; - var superCallExpression; - var ctorStatements = ctor.body.statements; - if (statementOffset < ctorStatements.length) { - firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + /** + * Updates literal expressions for labels with actual label numbers. + */ + function updateLabelExpressions() { + if (labelExpressions !== undefined && labelNumbers !== undefined) { + for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) { + var labels = labelNumbers[labelNumber_1]; + if (labels !== undefined) { + for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) { + var label = labels_1[_i]; + var expressions = labelExpressions[label]; + if (expressions !== undefined) { + for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) { + var expression = expressions_1[_a]; + expression.text = String(labelNumber_1); + } + } + } + } } } - // Return the result if we have an immediate super() call on the last statement. - if (superCallExpression && statementOffset === ctorStatements.length - 1) { - statements.push(ts.createReturn(superCallExpression)); - return 2 /* ReplaceWithReturn */; + } + /** + * Tries to enter or leave a code block. + */ + function tryEnterOrLeaveBlock(operationIndex) { + if (blocks) { + for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) { + var block = blocks[blockIndex]; + var blockAction = blockActions[blockIndex]; + if (isExceptionBlock(block)) { + if (blockAction === 0 /* Open */) { + if (!exceptionBlockStack) { + exceptionBlockStack = []; + } + if (!statements) { + statements = []; + } + exceptionBlockStack.push(currentExceptionBlock); + currentExceptionBlock = block; + } + else if (blockAction === 1 /* Close */) { + currentExceptionBlock = exceptionBlockStack.pop(); + } + } + else if (isWithBlock(block)) { + if (blockAction === 0 /* Open */) { + if (!withBlockStack) { + withBlockStack = []; + } + withBlockStack.push(block); + } + else if (blockAction === 1 /* Close */) { + withBlockStack.pop(); + } + } + } + } + } + /** + * Writes an operation as a statement to the current label's statement list. + * + * @param operation The OpCode of the operation + */ + function writeOperation(operationIndex) { + tryEnterLabel(operationIndex); + tryEnterOrLeaveBlock(operationIndex); + // early termination, nothing else to process in this label + if (lastOperationWasAbrupt) { + return; + } + lastOperationWasAbrupt = false; + lastOperationWasCompletion = false; + var opcode = operations[operationIndex]; + if (opcode === 0 /* Nop */) { + return; + } + else if (opcode === 10 /* Endfinally */) { + return writeEndfinally(); + } + var args = operationArguments[operationIndex]; + if (opcode === 1 /* Statement */) { + return writeStatement(args[0]); } - // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); - // If we're actually replacing the original statement, we need to signal this to the caller. - if (superCallExpression) { - return 1 /* ReplaceSuperCapture */; + var location = operationLocations[operationIndex]; + switch (opcode) { + case 2 /* Assign */: + return writeAssign(args[0], args[1], location); + case 3 /* Break */: + return writeBreak(args[0], location); + case 4 /* BreakWhenTrue */: + return writeBreakWhenTrue(args[0], args[1], location); + case 5 /* BreakWhenFalse */: + return writeBreakWhenFalse(args[0], args[1], location); + case 6 /* Yield */: + return writeYield(args[0], location); + case 7 /* YieldStar */: + return writeYieldStar(args[0], location); + case 8 /* Return */: + return writeReturn(args[0], location); + case 9 /* Throw */: + return writeThrow(args[0], location); } - return 0 /* NoReplacement */; - } - function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); } /** - * Visits a parameter declaration. + * Writes a statement to the current label's statement list. * - * @param node A ParameterDeclaration node. + * @param statement A statement to write. */ - function visitParameter(node) { - if (node.dotDotDotToken) { - // rest parameters are elided - return undefined; - } - else if (ts.isBindingPattern(node.name)) { - // Binding patterns are converted into a generated name and are - // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else if (node.initializer) { - // Initializers are elided - return ts.setOriginalNode(ts.createParameter(node.name, - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else { - return node; + function writeStatement(statement) { + if (statement) { + if (!statements) { + statements = [statement]; + } + else { + statements.push(statement); + } } } /** - * Gets a value indicating whether we need to add default value assignments for a - * function-like node. + * Writes an Assign operation to the current label's statement list. * - * @param node A function-like node. + * @param left The left-hand side of the assignment. + * @param right The right-hand side of the assignment. + * @param operationLocation The source map location for the operation. */ - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536 /* ContainsDefaultValueAssignments */) !== 0; + function writeAssign(left, right, operationLocation) { + writeStatement(ts.createStatement(ts.createAssignment(left, right), operationLocation)); } /** - * Adds statements to the body of a function-like node if it contains parameters with - * binding patterns or initializers. + * Writes a Throw operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param node A function-like node. + * @param expression The value to throw. + * @param operationLocation The source map location for the operation. */ - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - 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; - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); - } - } + function writeThrow(expression, operationLocation) { + lastOperationWasAbrupt = true; + lastOperationWasCompletion = true; + writeStatement(ts.createThrow(expression, operationLocation)); } /** - * Adds statements to the body of a function-like node for parameters with binding patterns + * Writes a Return operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. + * @param expression The value to return. + * @param operationLocation The source map location for the operation. */ - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - // In cases where a binding pattern is simply '[]' or '{}', - // we usually don't want to emit a var declaration; however, in the presence - // of an initializer, we must emit that expression to preserve side effects. - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608 /* CustomPrologue */)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); - } + function writeReturn(expression, operationLocation) { + lastOperationWasAbrupt = true; + lastOperationWasCompletion = true; + writeStatement(ts.createReturn(ts.createArrayLiteral(expression + ? [createInstruction(2 /* Return */), expression] + : [createInstruction(2 /* Return */)]), operationLocation)); } /** - * Adds statements to the body of a function-like node for parameters with initializers. + * Writes a Break operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. + * @param label The label for the Break. + * @param operationLocation The source map location for the operation. */ - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); - statements.push(statement); + function writeBreak(label, operationLocation) { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral([ + createInstruction(3 /* Break */), + createLabel(label) + ]), operationLocation)); } /** - * Gets a value indicating whether we need to add statements to handle a rest parameter. + * Writes a BreakWhenTrue operation to the current label's statement list. * - * @param node A ParameterDeclaration node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` + * @param label The label for the Break. + * @param condition The condition for the Break. + * @param operationLocation The source map location for the operation. */ - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 /* Identifier */ && !inConstructorWithSynthesizedSuper; + function writeBreakWhenTrue(label, condition, operationLocation) { + writeStatement(ts.createIf(condition, ts.createReturn(ts.createArrayLiteral([ + createInstruction(3 /* Break */), + createLabel(label) + ]), operationLocation))); } /** - * Adds statements to the body of a function-like node if it contains a rest parameter. + * Writes a BreakWhenFalse operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param node A function-like node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` + * @param label The label for the Break. + * @param condition The condition for the Break. + * @param operationLocation The source map location for the operation. */ - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - // `declarationName` is the name of the local declaration for the parameter. - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); - // `expressionName` is the name of the parameter used in expressions. - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, - /*type*/ undefined, ts.createArrayLiteral([])) - ]), - /*location*/ parameter), 8388608 /* CustomPrologue */)); - // for (var _i = restIndex; _i < arguments.length; _i++) { - // param[_i - restIndex] = arguments[_i]; - // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), - /*location*/ parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); - ts.startOnNewLine(forStatement); - statements.push(forStatement); + function writeBreakWhenFalse(label, condition, operationLocation) { + writeStatement(ts.createIf(ts.createLogicalNot(condition), ts.createReturn(ts.createArrayLiteral([ + createInstruction(3 /* Break */), + createLabel(label) + ]), operationLocation))); } /** - * Adds a statement to capture the `this` of a function declaration if it is needed. + * Writes a Yield operation to the current label's statement list. * - * @param statements The statements for the new function body. - * @param node A node. + * @param expression The expression to yield. + * @param operationLocation The source map location for the operation. */ - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 180 /* ArrowFunction */) { - captureThisForNode(statements, node, ts.createThis()); - } + function writeYield(expression, operationLocation) { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral(expression + ? [createInstruction(4 /* Yield */), expression] + : [createInstruction(4 /* Yield */)]), operationLocation)); } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + /** + * Writes a YieldStar instruction to the current label's statement list. + * + * @param expression The expression to yield. + * @param operationLocation The source map location for the operation. + */ + function writeYieldStar(expression, operationLocation) { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral([ + createInstruction(5 /* YieldStar */), + expression + ]), operationLocation)); } /** - * Adds statements to the class body function for a class to define the members of the - * class. + * Writes an Endfinally instruction to the current label's statement list. + */ + function writeEndfinally() { + lastOperationWasAbrupt = true; + writeStatement(ts.createReturn(ts.createArrayLiteral([ + createInstruction(7 /* Endfinally */) + ]))); + } + } + ts.transformGenerators = transformGenerators; + var _a; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableSubstitution(254 /* ShorthandPropertyAssignment */); + context.enableEmitNotification(256 /* SourceFile */); + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var bindingNameExportSpecifiersMap; + // Subset of exportSpecifiers that is a binding-name. + // This is to reduce amount of memory we have to keep around even after we done with module-transformer + var bindingNameExportSpecifiersForFileMap = ts.createMap(); + var hasExportStarsToExportValues; + return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. * - * @param statements The statements for the class body function. - * @param node The ClassExpression or ClassDeclaration node. + * @param node The SourceFile node. */ - function addClassMembers(statements, node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - switch (member.kind) { - case 198 /* SemicolonClassElement */: - statements.push(transformSemicolonClassElementToStatement(member)); - break; - case 147 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); - break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); - } - break; - case 148 /* Constructor */: - // Constructors are handled in visitClassExpression/visitClassDeclaration - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + // Collect information about the external module. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Perform the transformation. + var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule_1(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + return updated; } + return node; + var _a; } /** - * Transforms a SemicolonClassElement into a statement for a class body function. + * Transforms a SourceFile into a CommonJS module. * - * @param member The SemicolonClassElement node. + * @param node The SourceFile node. */ - function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = updateSourceFile(node, statements); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); + } + return updated; } /** - * Transforms a MethodDeclaration into a statement for a class body function. + * Transforms a SourceFile into an AMD module. * - * @param receiver The receiver for the member. - * @param member The MethodDeclaration node. + * @param node The SourceFile node. */ - function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = ts.getCommentRange(member); - var sourceMapRange = ts.getSourceMapRange(member); - var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); - ts.setEmitFlags(func, 49152 /* NoComments */); - ts.setSourceMapRange(func, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), - /*location*/ member.name), func), - /*location*/ member); - ts.setOriginalNode(statement, member); - ts.setCommentRange(statement, commentRange); - // The location for the statement is used to emit comments only. - // No source map should be emitted for this statement to align with the - // old emitter. - ts.setEmitFlags(statement, 1536 /* NoSourceMap */); - return statement; + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); } /** - * Transforms a set of related of get/set accessors into a statement for a class body function. + * Transforms a SourceFile into a UMD module. * - * @param receiver The receiver for the member. - * @param accessors The set of related get/set accessors. + * @param node The SourceFile node. */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*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 - // old emitter. - ts.setEmitFlags(statement, 49152 /* NoComments */); - return statement; + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16 /* UMDDefine */); + return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); } /** - * Transforms a set of related get/set accessors into an expression for either a class - * body function or an ObjectLiteralExpression with computed properties. + * Transforms a SourceFile into an AMD or UMD module. * - * @param receiver The receiver for the member. + * @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 transformAccessorsToExpression(receiver, _a, startsOnNewLine) { - var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - // 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); - ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); - ts.setSourceMapRange(propertyName, firstAccessor.name); - var properties = []; - if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - var getter = ts.createPropertyAssignment("get", getterFunction); - ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); - properties.push(getter); - } - if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - var setter = ts.createPropertyAssignment("set", setterFunction); - ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); - properties.push(setter); - } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); - var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - target, - propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // 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; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter("require"), + ts.createParameter("exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) ]); - if (startsOnNewLine) { - call.startsOnNewLine = true; - } - return call; } /** - * Visits an ArrowFunction and transforms it into a FunctionExpression. + * Transforms a SourceFile into an AMD or UMD module body. * - * @param node An ArrowFunction node. + * @param node The SourceFile node. */ - function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */) { - enableSubstitutionsForCapturedThis(); + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + // Visit each statement of the module body. + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + if (hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.setEmitFlags(body, 2 /* EmitExportStar */); } - var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); - ts.setEmitFlags(func, 256 /* CapturesThis */); - return func; - } - /** - * Visits a FunctionExpression node. - * - * @param node a FunctionExpression node. - */ - function visitFunctionExpression(node) { - return transformFunctionLikeToExpression(node, /*location*/ node, node.name); + return body; } - /** - * Visits a FunctionDeclaration node. - * - * @param node a FunctionDeclaration node. - */ - function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, transformFunctionBody(node), - /*location*/ node), - /*original*/ node); + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(exportEquals.expression, + /*location*/ exportEquals); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), + /*location*/ exportEquals); + ts.setEmitFlags(statement, 49152 /* NoComments */); + statements.push(statement); + } + } } /** - * Transforms a function-like node into a FunctionExpression. + * Visits a node at the top level of the source file. * - * @param node The function-like node to transform. - * @param location The source-map location for the new FunctionExpression. - * @param name The name of the new FunctionExpression. + * @param node The node. */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = node; + function visitor(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), - /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; } /** - * Transforms the body of a function-like node. + * Visits an ImportDeclaration node. * - * @param node A function-like node. + * @param node The ImportDeclaration node. */ - function transformFunctionBody(node) { - var multiLine = false; // indicates whether the block *must* be emitted as multiple lines - var singleLine = false; // indicates whether the block *may* be emitted as a single line - var statementsLocation; - var closeBraceLocation; + function visitImportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + statements.push(ts.createStatement(createRequireCall(node), + /*location*/ node)); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createConstDeclarationList(variables), + /*location*/ node)); + } } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); - // If we added any generated statements, this must be a multi-line block. - if (!multiLine && statements.length > 0) { - multiLine = true; + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node), + /*location*/ node) + ]))); } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - // If the original body was a multi-line block, this must be a multi-line block. - if (!multiLine && body.multiLine) { - multiLine = true; + addExportImportAssignments(statements, node); + return ts.singleOrMany(statements); + } + function visitImportEqualsDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } + // Set emitFlags on the name of the importEqualsDeclaration + // This is so the printer will not substitute the identifier + ts.setEmitFlags(node.name, 128 /* NoSubstitution */); + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), + /*location*/ node)); + } + else { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*location*/ undefined, + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); } } else { - ts.Debug.assert(node.kind === 180 /* ArrowFunction */); - // To align with the old emitter, we use a synthetic end position on the location - // for the statement list we synthesize when we down-level an arrow function with - // an expression function body. This prevents both comments and source maps from - // being emitted for the end position only. - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, node.name), + /*location*/ node)); } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); - ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); - statements.push(returnStatement); - // To align with the source map emit for the old emitter, we set a custom - // source map location for the close brace. - closeBraceLocation = body; } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - // If we added any final generated statements, this must be a multi-line block - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; + addExportImportAssignments(statements, node); + return statements; + } + function visitExportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32 /* SingleLine */); + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ]), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), + /*location*/ specifier)); + } + return ts.singleOrMany(statements); } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); + else { + // export * from "mod"; + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), + /*location*/ node); } - ts.setOriginalNode(block, node.body); - return block; } - /** - * Visits an ExpressionStatement that contains a destructuring assignment. - * - * @param node An ExpressionStatement node. - */ - function visitExpressionStatement(node) { - // If we are here it is most likely because our expression is a destructuring assignment. - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 187 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide as `export=` is handled in addExportEqualsIfNeeded + return undefined; } - return ts.visitEachChild(node, visitor, context); + var statements = []; + addExportDefault(statements, node.expression, /*location*/ node); + return statements; } - /** - * Visits a ParenthesizedExpression that may contain a destructuring assignment. - * - * @param node A ParenthesizedExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitParenthesizedExpression(node, needsDestructuringValue) { - // If we are here it is most likely because our expression is a destructuring assignment. - if (needsDestructuringValue) { - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); - case 187 /* BinaryExpression */: - return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); + function addExportDefault(statements, expression, location) { + tryAddExportDefaultCompat(statements); + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + } + function tryAddExportDefaultCompat(statements) { + var original = ts.getOriginalNode(currentSourceFile); + ts.Debug.assert(original.kind === 256 /* SourceFile */); + if (!original.symbol.exports["___esModule"]) { + if (languageVersion === 0 /* ES3 */) { + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); } } - return ts.visitEachChild(node, visitor, context); } - /** - * Visits a BinaryExpression that contains a destructuring assignment. - * - * @param node A BinaryExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitBinaryExpression(node, needsDestructuringValue) { - // If we are here it is because this is a destructuring assignment. - ts.Debug.assert(ts.isDestructuringAssignment(node)); - return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + function addExportImportAssignments(statements, node) { + if (ts.isImportEqualsDeclaration(node)) { + addExportMemberAssignments(statements, node.name); + } + else { + var names = ts.reduceEachChild(node, collectExportMembers, []); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); + } + } } - function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 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++) { - var decl = _a[_i]; - hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); - if (decl.initializer) { - var assignment = void 0; - if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); - } - else { - assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); - } - (assignments || (assignments = [])).push(assignment); - } + function collectExportMembers(names, node) { + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); } - if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24 /* CommaToken */, acc); }), node); + } + return ts.reduceEachChild(node, collectExportMembers, names); + } + function addExportMemberAssignments(statements, name) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), + /*location*/ specifier.name))); } - else { - // none of declarations has initializer - the entire variable statement can be deleted - return undefined; + } + } + function addExportMemberAssignment(statements, node) { + if (ts.hasModifier(node, 512 /* Default */)) { + addExportDefault(statements, getDeclarationName(node), /*location*/ node); + } + else { + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + } + } + function visitVariableStatement(node) { + // If the variable is for a generated declaration, + // we should maintain it and just strip off the 'export' modifier if necessary. + var originalKind = ts.getOriginalNode(node).kind; + if (originalKind === 226 /* ModuleDeclaration */ || + originalKind === 225 /* EnumDeclaration */ || + originalKind === 222 /* ClassDeclaration */) { + if (!ts.hasModifier(node, 1 /* Export */)) { + return node; } + return ts.setOriginalNode(ts.createVariableStatement( + /*modifiers*/ undefined, node.declarationList), node); } - return ts.visitEachChild(node, visitor, context); + var resultStatements = []; + // If we're exporting these variables, then these just become assignments to 'exports.blah'. + // We only want to emit assignments for variables with initializers. + if (ts.hasModifier(node, 1 /* Export */)) { + var variables = ts.getInitializedVariables(node.declarationList); + if (variables.length > 0) { + var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + resultStatements.push(inlineAssignments); + } + } + else { + resultStatements.push(node); + } + // While we might not have been exported here, each variable might have been exported + // later on in an export specifier (e.g. `export {foo as blah, bar}`). + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + addExportMemberAssignmentsForBindingName(resultStatements, decl.name); + } + return resultStatements; } /** - * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). - * - * @param node A VariableDeclarationList node. + * Creates appropriate assignments for each binding identifier that is exported in an export specifier, + * and inserts it into 'resultStatements'. */ - function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); + function addExportMemberAssignmentsForBindingName(resultStatements, name) { + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + addExportMemberAssignmentsForBindingName(resultStatements, element.name); + } + } } - 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 & 2097152 /* 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)); + else { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + var sourceFileId = ts.getOriginalNodeId(currentSourceFile); + if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { + bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + } + bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; + addExportMemberAssignments(resultStatements, name); + } } - return declarationList; } - /** - * Gets a value indicating whether we should emit an explicit initializer for a variable - * declaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. - */ - function shouldEmitExplicitInitializerForLetDeclaration(node) { - // Nested let bindings might need to be initialized explicitly to preserve - // ES6 semantic: - // - // { let x = 1; } - // { let x; } // x here should be undefined. not 1 - // - // Top level bindings never collide with anything and thus don't require - // explicit initialization. As for nested let bindings there are two cases: - // - // - Nested let bindings that were not renamed definitely should be - // initialized explicitly: - // - // { let x = 1; } - // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } - // - // Without explicit initialization code in /*1*/ can be executed even if - // some-condition is evaluated to false. - // - // - Renaming introduces fresh name that should not collide with any - // existing names, however renamed bindings sometimes also should be - // explicitly initialized. One particular case: non-captured binding - // declared inside loop body (but not in loop initializer): - // - // let x; - // for (;;) { - // let x; - // } - // - // In downlevel codegen inner 'x' will be renamed so it won't collide - // with outer 'x' however it will should be reset on every iteration as - // if it was declared anew. - // - // * Why non-captured binding? - // - Because if loop contains block scoped binding captured in some - // function then loop body will be rewritten to have a fresh scope - // on every iteration so everything will just work. - // - // * Why loop initializer is excluded? - // - Since we've introduced a fresh name it already will be undefined. - var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) - || (isCapturedInFunction - && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); - var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 208 /* ForOfStatement */ - && (!resolver.isDeclarationWithCollidingName(node) - || (isDeclaredInLoop - && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); - return emitExplicitInitializer; + function transformInitializedVariable(node) { + var name = node.name; + if (ts.isBindingPattern(name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); + } + else { + return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); + } + } + function visitFunctionDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + if (node.name) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.setOriginalNode(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + // Decorators end up creating a series of assignment expressions which overwrite + // the local binding that we export, so we need to defer from exporting decorated classes + // until the decoration assignments take place. We do this when visiting expression-statements. + if (node.name && !(node.decorators && node.decorators.length)) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitExpressionStatement(node) { + var original = ts.getOriginalNode(node); + var origKind = original.kind; + if (origKind === 225 /* EnumDeclaration */ || origKind === 226 /* ModuleDeclaration */) { + return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); + } + else if (origKind === 222 /* ClassDeclaration */) { + // The decorated assignment for a class name may need to be transformed. + var classDecl = original; + if (classDecl.name) { + var statements = [node]; + addExportMemberAssignments(statements, classDecl.name); + return statements; + } + } + return node; + } + function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { + var statements = [node]; + // Preserve old behavior for enums in which a variable statement is emitted after the body itself. + if (ts.hasModifier(original, 1 /* Export */) && + original.kind === 225 /* EnumDeclaration */ && + ts.isFirstDeclarationOfKind(original, 225 /* EnumDeclaration */)) { + addVarForExportedEnumOrNamespaceDeclaration(statements, original); + } + addExportMemberAssignments(statements, original.name); + return statements; } /** - * Visits a VariableDeclaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. + * Adds a trailing VariableStatement for an enum or module declaration. */ - function visitVariableDeclarationInLetDeclarationList(node) { - // For binding pattern names that lack initializers there is no point to emit - // explicit initializer since downlevel codegen for destructuring will fail - // in the absence of initializer so all binding elements will say uninitialized - var name = node.name; - if (ts.isBindingPattern(name)) { - return visitVariableDeclaration(node); + function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { + var transformedStatement = ts.createVariableStatement( + /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), + /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], + /*location*/ node); + ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); + statements.push(transformedStatement); + } + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256 /* SourceFile */) { + bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + bindingNameExportSpecifiersMap = undefined; } - if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { - var clone_8 = ts.getMutableClone(node); - clone_8.initializer = ts.createVoidZero(); - return clone_8; + else { + previousOnEmitNode(emitContext, node, emitCallback); } - return ts.visitEachChild(node, visitor, context); } /** - * Visits a VariableDeclaration node with a binding pattern. + * Hooks node substitutions. * - * @param node A VariableDeclaration node. + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. */ - function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. - if (ts.isBindingPattern(node.name)) { - var recordTempVariablesInLine = !enclosingVariableStatement - || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenVariableDestructuring(context, node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); } - return ts.visitEachChild(node, visitor, context); + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); + } + return node; } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, /*location*/ node); } - convertedLoopState.labels[node.label.text] = node.label.text; + return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 187 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); } - else { - result = ts.visitEachChild(node, visitor, context); + return node; + } + function substituteExpressionIdentifier(node) { + return trySubstituteExportedName(node) + || trySubstituteImportedName(node) + || node; + } + function substituteBinaryExpression(node) { + var left = node.left; + // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier + if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, node); + } + return nestedExportAssignment; + } } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; + return node; + } + function substituteUnaryExpression(node) { + // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are + // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus + var operator = node.operator; + var operand = node.operand; + if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var transformedUnaryExpression = void 0; + if (node.kind === 187 /* PostfixUnaryExpression */) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), + /*location*/ node); + // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here + ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); + } + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, transformedUnaryExpression || node); + } + return nestedExportAssignment; + } } - return result; + return node; } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function trySubstituteExportedName(node) { + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 262144 /* LocalName */) === 0) { + var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); + if (container) { + if (container.kind === 256 /* SourceFile */) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), + /*location*/ node); + } + } + } + return undefined; } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function trySubstituteImportedName(node) { + if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (ts.isImportClause(declaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(declaration)) { + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), + /*location*/ node); + } + } + } + return undefined; } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function getModuleMemberName(name) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), name, + /*location*/ name); } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (ts.isDefined(moduleName)) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + function createExportStatement(name, value, location) { + var statement = ts.createStatement(createExportAssignment(name, value)); + statement.startsOnNewLine = true; + if (location) { + ts.setSourceMapRange(statement, location); + } + return statement; } - function convertForOfToFor(node, convertedLoopBodyStatements) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (var _i = 0, _a = expr; _i < _a.length; _i++) { - // var v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - // In the case where the user wrote an identifier as the RHS, like this: - // - // for (let v of arr) { } - // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 /* Identifier */ - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); - ts.setOriginalNode(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); + function createExportAssignment(name, value) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(amdDependency.name)); } else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), - /*location*/ ts.moveRangeEnd(initializer, -1))); + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); } } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, - /*needsValue*/ false, hoistVariableDeclaration, visitor))); + for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { + var importNode = externalImports_1[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(importAliasName)); } else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + unaliasedModuleNames.push(externalModuleName); } } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function updateSourceFile(node, statements) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + return updated; + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableEmitNotification(256 /* SourceFile */); + var exportFunctionForFileMap = []; + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStarsToExportValues; + var exportFunctionForFile; + var contextObjectForFile; + var exportedLocalNames; + var exportedFunctionDeclarations; + var enclosingBlockScopedContainer; + var currentParent; + var currentNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + currentNode = node; + // Perform the transformation. + var updated = transformSystemModuleWorker(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + exportFunctionForFile = undefined; + contextObjectForFile = undefined; + exportedLocalNames = undefined; + exportedFunctionDeclarations = undefined; + return updated; } - // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); - ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); - // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); - return forStatement; + return node; + } + function transformSystemModuleWorker(node) { + // System modules have the following shape: + // + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // + // The parameter 'exports' here is a callback '(name: string, value: T) => T' that + // is used to publish exported values. 'exports' returns its 'value' argument so in + // most cases expressions that mutate exported values can be rewritten as: + // + // expr -> exports('name', expr) + // + // The only exception in this rule is postfix unary operators, + // see comment to 'substitutePostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // Collect information about the external module and dependency groups. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Make sure that the name of the 'exports' function does not conflict with + // existing identifiers. + exportFunctionForFile = ts.createUniqueName("exports"); + contextObjectForFile = ts.createUniqueName("context"); + exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; + var dependencyGroups = collectDependencyGroups(externalImports); + var statements = []; + // Add the body of the module. + addSystemModuleBody(statements, node, dependencyGroups); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); + var body = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(exportFunctionForFile), + ts.createParameter(contextObjectForFile) + ], + /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); + // Write the call to `System.register` + // Clear the emit-helpers flag for later passes since we'll have already used it in the module body + // So the helper will be emit at the correct position instead of at the top of the source-file + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + /*typeArguments*/ undefined, moduleName + ? [moduleName, dependencies, body] + : [dependencies, body])) + ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); + var _a; } /** - * Visits an ObjectLiteralExpression with computed propety names. + * Adds the statements for the module body function for the source file. * - * @param node An ObjectLiteralExpression node. + * @param statements The output statements for the module body. + * @param node The source file for the module. + * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. */ - function visitObjectLiteralExpression(node) { - // We are here because a ComputedPropertyName was used somewhere in the expression. - var properties = node.properties; - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialProperties = numProperties; - for (var i = 0; i < numProperties; i++) { - var property = properties[i]; - if (property.transformFlags & 4194304 /* ContainsYield */ - || property.name.kind === 140 /* 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), 524288 /* 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); - } - function shouldConvertIterationStatementBody(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + function addSystemModuleBody(statements, node, dependencyGroups) { + // Shape of the body in system modules: + // + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // + // i.e: + // + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // + // Will be transformed to: + // + // function(exports) { + // var file_1; // local alias + // var y; + // function foo() { return y + file_1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file_1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + // We start a new lexical environment in this function body, but *not* in the + // body of the execute function. This allows us to emit temporary declarations + // only in the outer module body and not in the inner one. + startLexicalEnvironment(); + // Add any prologue directives. + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); + // var __moduleName = context_1 && context_1.id; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", + /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) + ]))); + // Visit the statements of the source file, emitting any transformations into + // the `executeStatements` array. We do this *before* we fill the `setters` array + // as we both emit transformations as well as aggregate some data used when creating + // setters. This allows us to reduce the number of times we need to loop through the + // statements of the source file. + var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); + // We emit the lexical environment (hoisted variables and function declarations) + // early to align roughly with our previous emit output. + // Two key differences in this approach are: + // - Temporary variables will appear at the top rather than at the bottom of the file + // - Calls to the exporter for exported function declarations are grouped after + // the declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Emit early exports for function declarations. + ts.addRange(statements, exportedFunctionDeclarations); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.createBlock(executeStatements, + /*location*/ undefined, + /*multiLine*/ true))) + ]), + /*multiLine*/ true))); } - /** - * Records constituents of name for the given variable to be hoisted in the outer scope. - */ - function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { - if (!state.hoistedLocalVariables) { - state.hoistedLocalVariables = []; + function addExportStarIfNeeded(statements) { + if (!hasExportStarsToExportValues) { + return; } - visit(node.name); - function visit(node) { - if (node.kind === 69 /* Identifier */) { - state.hoistedLocalVariables.push(node); - } - else { - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - visit(element.name); - } + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + // local names set should only be added if we have anything exported + if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { + var externalImport = externalImports_2[_i]; + if (externalImport.kind === 237 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; } } - } - } - function convertIterationStatementBodyIfNecessary(node, convert) { - if (!shouldConvertIterationStatementBody(node)) { - var saveAllowedNonLabeledJumps = void 0; - if (convertedLoopState) { - // we get here if we are trying to emit normal loop loop inside converted loop - // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is - saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; - } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); - if (convertedLoopState) { - convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return addExportStarFunction(statements, /*localNames*/ undefined); } - return result; - } - var functionName = ts.createUniqueName("_loop"); - var loopInitializer; - switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - var initializer = node.initializer; - if (initializer && initializer.kind === 219 /* VariableDeclarationList */) { - loopInitializer = initializer; - } - break; } - // variables that will be passed to the loop as parameters - var loopParameters = []; - // variables declared in the loop initializer that will be changed inside the loop - var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { - for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); + var exportedNames = []; + if (exportedLocalNames) { + for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { + var exportedLocalName = exportedLocalNames_1[_a]; + // write name of exported declaration, i.e 'export var x...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); } } - var outerConvertedLoopState = convertedLoopState; - convertedLoopState = { loopOutParameters: loopOutParameters }; - if (outerConvertedLoopState) { - // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. - // if outer converted loop has already accumulated some state - pass it through - if (outerConvertedLoopState.argumentsName) { - // outer loop has already used 'arguments' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; + for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { + var externalImport = externalImports_3[_b]; + if (externalImport.kind !== 237 /* ExportDeclaration */) { + continue; } - if (outerConvertedLoopState.thisName) { - // outer loop has already used 'this' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.thisName = outerConvertedLoopState.thisName; + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; } - if (outerConvertedLoopState.hoistedLocalVariables) { - // we've already collected some non-block scoped variable declarations in enclosing loop - // use the same storage in nested loop - convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; + for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { + var element = _d[_c]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); } } - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); - var currentState = convertedLoopState; - convertedLoopState = outerConvertedLoopState; - if (loopOutParameters.length) { - var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; - copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); - loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); - } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); - } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 - && (node.statement.transformFlags & 4194304 /* ContainsYield */) !== 0; - var loopBodyFlags = 0; - if (currentState.containsLexicalThis) { - loopBodyFlags |= 256 /* CapturesThis */; - } - if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 2097152 /* AsyncFunctionBody */; - } - var convertedLoopVariable = ts.createVariableStatement( + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, - /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, loopParameters, - /*type*/ undefined, loopBody), loopBodyFlags)) - ])); - var statements = [convertedLoopVariable]; - var extraVariableDeclarations; - // propagate state from the inner loop to the outer loop if necessary - if (currentState.argumentsName) { - // if alias for arguments is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.argumentsName = currentState.argumentsName; - } - else { - // this is top level converted loop and we need to create an alias for 'arguments' object - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, - /*type*/ undefined, ts.createIdentifier("arguments"))); - } - } - if (currentState.thisName) { - // if alias for this is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.thisName = currentState.thisName; - } - else { - // this is top level converted loop so we need to create an alias for 'this' here - // NOTE: - // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. - // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, - /*type*/ undefined, ts.createIdentifier("this"))); - } - } - if (currentState.hoistedLocalVariables) { - // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later - if (outerConvertedLoopState) { - // pass them to outer converted loop - outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; - } - else { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - // hoist collected variable declarations - for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { - var identifier = _c[_b]; - extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); + ts.createVariableDeclaration(exportedNamesStorageRef, + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + ]))); + return addExportStarFunction(statements, exportedNamesStorageRef); + } + /** + * Emits a setter callback for each dependency group. + * @param write The callback used to write each callback. + */ + function generateSetters(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + // derive a unique name for parameter from the first named entry in the group + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 231 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 230 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 237 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // + // emit as: + // + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + } + else { + // export * from 'foo' + // + // emit as: + // + // exportStar(foo_1_1); + statements.push(ts.createStatement(ts.createCall(exportStarFunction, + /*typeArguments*/ undefined, [parameterName]))); + } + break; } } + setters.push(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); } - // add extra variables to hold out parameters if necessary - if (loopOutParameters.length) { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { - var outParam = loopOutParameters_1[_d]; - extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); - } - } - // create variable statement to hold all introduced variable declarations - if (extraVariableDeclarations) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); - } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); - var loop; - if (convert) { - loop = convert(node, convertedLoopBodyStatements); - } - else { - loop = ts.getMutableClone(node); - // clean statement part - loop.statement = undefined; - // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); - // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); - // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); - } - statements.push(currentParent.kind === 214 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); - return statements; - } - function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56 /* EqualsToken */, source); + return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); } - function copyOutParameters(outParams, copyDirection, statements) { - for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { - var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + function visitSourceElement(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + default: + return visitNestedNode(node); } } - function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { - var outerConvertedLoopState = convertedLoopState; - var statements = []; - // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop - // simple loops are emitted as just 'loop()'; - // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && - !state.labeledNonLocalBreaks && - !state.labeledNonLocalContinues; - var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37 /* AsteriskToken */), call) : call; - if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - } - else { - var loopResultName = ts.createUniqueName("state"); - var stateVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); - statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { - var returnStatement = void 0; - if (outerConvertedLoopState) { - outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; - returnStatement = ts.createReturn(loopResultName); - } - else { - returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); - } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); - } - if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); - } - if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { - var caseClauses = []; - processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); - processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); - statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); - } + function visitNestedNode(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var currentGrandparent = currentParent; + currentParent = currentNode; + currentNode = node; + if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { + enclosingBlockScopedContainer = currentParent; } - return statements; + var result = visitNestedNodeWorker(node); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return result; } - function setLabeledJump(state, isBreak, labelText, labelMarker) { - if (isBreak) { - if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = ts.createMap(); - } - state.labeledNonLocalBreaks[labelText] = labelMarker; - } - else { - if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = ts.createMap(); - } - state.labeledNonLocalContinues[labelText] = labelMarker; + function visitNestedNodeWorker(node) { + switch (node.kind) { + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 207 /* ForStatement */: + return visitForStatement(node); + case 208 /* ForInStatement */: + return visitForInStatement(node); + case 209 /* ForOfStatement */: + return visitForOfStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 213 /* WithStatement */: + return visitWithStatement(node); + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 228 /* CaseBlock */: + return visitCaseBlock(node); + case 249 /* CaseClause */: + return visitCaseClause(node); + case 250 /* DefaultClause */: + return visitDefaultClause(node); + case 217 /* TryStatement */: + return visitTryStatement(node); + case 252 /* CatchClause */: + return visitCatchClause(node); + case 200 /* Block */: + return visitBlock(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + return node; } } - function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { - if (!table) { - return; - } - for (var labelText in table) { - var labelMarker = table[labelText]; - var statements = []; - // 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])) { - var label = ts.createIdentifier(labelText); - statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); - } - else { - setLabeledJump(outerLoop, isBreak, labelText, labelMarker); - statements.push(ts.createReturn(loopResultName)); - } - caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + function visitImportDeclaration(node) { + if (node.importClause && ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); } + return undefined; } - function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { - var name = decl.name; - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - processLoopVariableDeclaration(element, loopParameters, loopOutParameters); - } - } - } - else { - loopParameters.push(ts.createParameter(name)); - if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); - loopOutParameters.push({ originalName: name, outParamName: outParamName }); - } + function visitImportEqualsDeclaration(node) { + if (ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); } + // NOTE(rbuckton): Do we support export import = require('') in System? + return undefined; } - /** - * Adds the members of an object literal to an array of expressions. - * - * @param expressions An array of expressions. - * @param node An ObjectLiteralExpression node. - * @param receiver The receiver for members of the ObjectLiteralExpression. - * @param numInitialNonComputedProperties The number of initial properties without - * computed property names. - */ - function addObjectLiteralMembers(expressions, node, receiver, start) { - var properties = node.properties; - var numProperties = properties.length; - for (var i = start; i < numProperties; i++) { - var property = properties[i]; - switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); - } - break; - case 253 /* PropertyAssignment */: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 254 /* ShorthandPropertyAssignment */: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 147 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + var statements = []; + ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); + return statements; } + return undefined; } - /** - * Transforms a PropertyAssignment node into an expression. - * - * @param node The ObjectLiteralExpression that contains the PropertyAssignment. - * @param property The PropertyAssignment node. - * @param receiver The receiver for the assignment. - */ - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function visitExportSpecifier(specifier) { + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + } + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; } - return expression; + return createExportStatement(ts.createLiteral("default"), node.expression); } /** - * Transforms a ShorthandPropertyAssignment node into an expression. + * Visits a variable statement, hoisting declared names to the top-level module body. + * Each declaration is rewritten into an assignment expression. * - * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. - * @param property The ShorthandPropertyAssignment node. - * @param receiver The receiver for the assignment. + * @param node The variable statement to visit. */ - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function visitVariableStatement(node) { + // hoist only non-block scoped declarations or block scoped declarations parented by source file + var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || + enclosingBlockScopedContainer.kind === 256 /* SourceFile */; + if (!shouldHoist) { + return node; } - return expression; + var isExported = ts.hasModifier(node, 1 /* Export */); + var expressions = []; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, isExported); + if (visited) { + expressions.push(visited); + } + } + if (expressions.length) { + return ts.createStatement(ts.inlineExpressions(expressions), node); + } + return undefined; } /** - * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. + * Transforms a VariableDeclaration into one or more assignment expressions. * - * @param node The ObjectLiteralExpression that contains the MethodDeclaration. - * @param method The MethodDeclaration node. - * @param receiver The receiver for the assignment. + * @param node The VariableDeclaration to transform. + * @param isExported A value used to indicate whether the containing statement was exported. */ - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), - /*location*/ method); - if (startsOnNewLine) { - expression.startsOnNewLine = true; + function transformVariable(node, isExported) { + // Hoist any bound names within the declaration. + hoistBindingElement(node, isExported); + if (!node.initializer) { + // If the variable has no initializer, ignore it. + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + // If the variable has an IdentifierName, write out an assignment expression in its place. + return ts.createAssignment(name, node.initializer); + } + else { + // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } - return expression; } /** - * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a - * PropertyAssignment. + * Visits a FunctionDeclaration, hoisting it to the outer module body function. * - * @param node A MethodDeclaration node. + * @param node The function declaration to visit. */ - function visitMethodDeclaration(node) { - // We should only get here for methods on an object literal with regular identifier names. - // 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); - ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, - /*location*/ node); + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + // If the function is exported, ensure it has a name and rewrite the function without any export flags. + var name_38 = node.name || ts.getGeneratedNameForNode(node); + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + var newNode = ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name_38, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node); + // Record a declaration export in the outer module body function. + recordExportedFunctionDeclaration(node); + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name_38); + } + ts.setOriginalNode(newNode, node); + node = newNode; + } + // Hoist the function declaration to the outer module body function. + hoistFunctionDeclaration(node); + return undefined; } - /** - * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. - * - * @param node A ShorthandPropertyAssignment node. - */ - function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), - /*location*/ node); + function visitExpressionStatement(node) { + var originalNode = ts.getOriginalNode(node); + if ((originalNode.kind === 226 /* ModuleDeclaration */ || originalNode.kind === 225 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { + var name_39 = getDeclarationName(originalNode); + // We only need to hoistVariableDeclaration for EnumDeclaration + // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement + // which then call transformsVariable for each declaration in declarationList + if (originalNode.kind === 225 /* EnumDeclaration */) { + hoistVariableDeclaration(name_39); + } + return [ + node, + createExportStatement(name_39, name_39) + ]; + } + return node; } /** - * Visits a YieldExpression node. + * Visits a ClassDeclaration, hoisting its name to the outer module body function. * - * @param node A YieldExpression node. + * @param node The class declaration to visit. */ - function visitYieldExpression(node) { - // `yield` expressions are transformed using the generators transformer. - return ts.visitEachChild(node, visitor, context); + function visitClassDeclaration(node) { + // Hoist the name of the class declaration to the outer module body function. + var name = getDeclarationName(node); + hoistVariableDeclaration(name); + var statements = []; + // Rewrite the class declaration into an assignment of a class expression. + statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node)), + /*location*/ node)); + // If the class was exported, write a declaration export to the inner module body function. + if (ts.hasModifier(node, 1 /* Export */)) { + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name); + } + statements.push(createDeclarationExport(node)); + } + return statements; } - /** - * Visits an ArrayLiteralExpression that contains a spread element. - * - * @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); + function shouldHoistLoopInitializer(node) { + return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; } /** - * Visits a CallExpression that contains either a spread element or `super`. + * Visits the body of a ForStatement to hoist declarations. * - * @param node a CallExpression. + * @param node The statement to visit. */ - function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); - } - function visitImmediateSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); - } - function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - // We are here either because SuperKeyword was used somewhere in the expression, or - // because we contain a SpreadElementExpression. - var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); - } - var resultingCall; - if (node.transformFlags & 262144 /* ContainsSpreadElementExpression */) { - // [source] - // f(...a, b) - // x.m(...a, b) - // super(...a, b) - // super.m(...a, b) // in static - // super.m(...a, b) // in instance - // - // [output] - // f.apply(void 0, a.concat([b])) - // (_a = x).m.apply(_a, a.concat([b])) - // _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)); - } - else { - // [source] - // super(a) - // super.m(a) // in static - // super.m(a) // in instance - // - // [output] - // _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), + function visitForStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var expressions = []; + for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, /*isExported*/ false); + if (visited) { + expressions.push(visited); + } + } + ; + return ts.createFor(expressions.length + ? ts.inlineExpressions(expressions) + : ts.createSynthesizedNode(194 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), /*location*/ node); } - if (node.expression.kind === 95 /* SuperKeyword */) { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis - ? ts.createAssignment(ts.createIdentifier("_this"), initializer) - : initializer; + else { + return ts.visitEachChild(node, visitNestedNode, context); } - return resultingCall; } /** - * Visits a NewExpression that contains a spread element. + * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. * - * @param node A NewExpression node. + * @param node The decalaration list to transform. */ - function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 262144 /* ContainsSpreadElementExpression */) !== 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, []); + function transformForBinding(node) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + hoistBindingElement(firstDeclaration, /*isExported*/ false); + var name = firstDeclaration.name; + return ts.isIdentifier(name) + ? name + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } /** - * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * Visits the body of a ForInStatement to hoist declarations. * - * @param elements The array of Expression nodes. - * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. - * @param multiLine A value indicating whether the result should be emitted on multiple lines. + * @param node The statement to visit. */ - function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { - // [source] - // [a, ...b, c] - // - // [output] - // [a].concat(b, [c]) - // Map spans of spread expressions into their expressions and spans of other - // expressions into an array literal. - var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { - return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); - })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 /* ArrayLiteralExpression */ - ? ts.createArraySlice(segments[0]) - : segments[0]; + function visitForInStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); } - // Rewrite using the pattern .concat(, , ...) - return ts.createArrayConcat(segments.shift(), segments); - } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; - } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.map(chunk, visitExpressionOfSpreadElement); - } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); } /** - * Transforms the expression of a SpreadElementExpression node. + * Visits the body of a ForOfStatement to hoist declarations. * - * @param node A SpreadElementExpression node. + * @param node The statement to visit. */ - function visitExpressionOfSpreadElement(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); + function visitForOfStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } } /** - * Visits a template literal. + * Visits the body of a DoStatement to hoist declarations. * - * @param node A template literal. + * @param node The statement to visit. */ - function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); + function visitDoStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; } /** - * Visits a TaggedTemplateExpression node. + * Visits the body of a WhileStatement to hoist declarations. * - * @param node A TaggedTemplateExpression node. + * @param node The statement to visit. */ - function visitTaggedTemplateExpression(node) { - // Visit the tag expression - var tag = ts.visitNode(node.tag, visitor, ts.isExpression); - // Allocate storage for the template site object - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Build up the template arguments and the raw and cooked strings for the template. - var templateArguments = [temp]; - var cookedStrings = []; - var rawStrings = []; - var template = node.template; - if (ts.isNoSubstitutionTemplateLiteral(template)) { - cookedStrings.push(ts.createLiteral(template.text)); - rawStrings.push(getRawLiteral(template)); - } - else { - cookedStrings.push(ts.createLiteral(template.head.text)); - rawStrings.push(getRawLiteral(template.head)); - for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { - var templateSpan = _a[_i]; - cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); - rawStrings.push(getRawLiteral(templateSpan.literal)); - templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); - } + function visitWhileStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; } - // NOTE: The parentheses here is entirely optional as we are now able to auto- - // parenthesize when rebuilding the tree. This should be removed in a - // future version. It is here for now to match our existing emit. - return ts.createParen(ts.inlineExpressions([ - ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), - ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), - ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) - ])); + return node; } /** - * Creates an ES5 compatible literal from an ES6 template literal. + * Visits the body of a LabeledStatement to hoist declarations. * - * @param node The ES6 template literal. + * @param node The statement to visit. */ - function getRawLiteral(node) { - // Find original source text, since we need to emit the raw strings of the tagged template. - // The raw strings contain the (escaped) strings of what the user wrote. - // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - // Newline normalization: - // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's - // and LineTerminatorSequences are normalized to for both TV and TRV. - text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); + function visitLabeledStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; } /** - * Visits a TemplateExpression node. + * Visits the body of a WithStatement to hoist declarations. * - * @param node A TemplateExpression node. + * @param node The statement to visit. */ - function visitTemplateExpression(node) { - var expressions = []; - addTemplateHead(expressions, node); - addTemplateSpans(expressions, node); - // createAdd will check if each expression binds less closely than binary '+'. - // If it does, it wraps the expression in parentheses. Otherwise, something like - // `abc${ 1 << 2 }` - // becomes - // "abc" + 1 << 2 + "" - // which is really - // ("abc" + 1) << (2 + "") - // rather than - // "abc" + (1 << 2) + "" - var expression = ts.reduceLeft(expressions, ts.createAdd); - if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); + function visitWithStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; } - return expression; + return node; } /** - * Gets a value indicating whether we need to include the head of a TemplateExpression. + * Visits the body of a SwitchStatement to hoist declarations. * - * @param node A TemplateExpression node. + * @param node The statement to visit. */ - function shouldAddTemplateHead(node) { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // There is always atleast one templateSpan in this code path, since - // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + function visitSwitchStatement(node) { + var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); + if (caseBlock !== node.caseBlock) { + var updated = ts.getMutableClone(node); + updated.caseBlock = caseBlock; + return updated; + } + return node; } /** - * Adds the head of a TemplateExpression to an array of expressions. + * Visits the body of a CaseBlock to hoist declarations. * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. + * @param node The node to visit. */ - function addTemplateHead(expressions, node) { - if (!shouldAddTemplateHead(node)) { - return; + function visitCaseBlock(node) { + var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); + if (clauses !== node.clauses) { + var updated = ts.getMutableClone(node); + updated.clauses = clauses; + return updated; } - expressions.push(ts.createLiteral(node.head.text)); + return node; } /** - * Visits and adds the template spans of a TemplateExpression to an array of expressions. + * Visits the body of a CaseClause to hoist declarations. * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. + * @param node The clause to visit. */ - function addTemplateSpans(expressions, node) { - for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { - var span_6 = _a[_i]; - expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); - // Only emit if the literal is non-empty. - // The binary '+' operator is left-associative, so the first string concatenation - // with the head will force the result up to this point to be a string. - // Emitting a '+ ""' has no semantic effect for middles and tails. - if (span_6.literal.text.length !== 0) { - expressions.push(ts.createLiteral(span_6.literal.text)); - } + function visitCaseClause(node) { + var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); + if (statements !== node.statements) { + var updated = ts.getMutableClone(node); + updated.statements = statements; + return updated; } + return node; } /** - * Visits the `super` keyword - */ - function visitSuperKeyword(node) { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 174 /* CallExpression */ - ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") - : ts.createIdentifier("_super"); - } - function visitSourceFileNode(node) { - var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; - var statements = []; - startLexicalEnvironment(); - ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); - ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); - ts.addRange(statements, endLexicalEnvironment()); - var clone = ts.getMutableClone(node); - clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); - return clone; - } - /** - * Called by the printer just before a node is printed. + * Visits the body of a DefaultClause to hoist declarations. * - * @param node The node to be printed. + * @param node The clause to visit. */ - 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; - } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; + function visitDefaultClause(node) { + return ts.visitEachChild(node, visitNestedNode, context); } /** - * Enables a more costly code path for substitutions when we determine a source file - * contains block-scoped bindings (e.g. `let` or `const`). + * Visits the body of a TryStatement to hoist declarations. + * + * @param node The statement to visit. */ - function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(69 /* Identifier */); + function visitTryStatement(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + /** + * Visits the body of a CatchClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitCatchClause(node) { + var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); + if (block !== node.block) { + var updated = ts.getMutableClone(node); + updated.block = block; + return updated; } + return node; } /** - * Enables a more costly code path for substitutions when we determine a source file - * contains a captured `this`. + * Visits the body of a Block to hoist declarations. + * + * @param node The block to visit. */ - function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(97 /* ThisKeyword */); - context.enableEmitNotification(148 /* Constructor */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(180 /* ArrowFunction */); - context.enableEmitNotification(179 /* FunctionExpression */); - context.enableEmitNotification(220 /* FunctionDeclaration */); + function visitBlock(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + // + // Substitutions + // + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256 /* SourceFile */) { + exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + exportFunctionForFile = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -52856,168 +53267,445 @@ var ts; if (emitContext === 1 /* Expression */) { return substituteExpression(node); } - if (ts.isIdentifier(node)) { - return substituteIdentifier(node); + return node; + } + /** + * Substitute the expression, if necessary. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + return substituteUnaryExpression(node); } return node; } /** - * Hooks substitutions for non-expression identifiers. + * Substitution for identifiers exported at the top level of a module. */ - function substituteIdentifier(node) { - // Only substitute the identifier if we have enabled substitutions for block-scoped - // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var original = ts.getParseTreeNode(node, ts.isIdentifier); - if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + function substituteExpressionIdentifier(node) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + var importBinding = createImportBinding(importDeclaration); + if (importBinding) { + return importBinding; + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind)) { + return substituteAssignmentExpression(node); + } + return node; + } + function substituteAssignmentExpression(node) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var left = node.left; + switch (left.kind) { + case 70 /* Identifier */: + var exportDeclaration = resolver.getReferencedExportContainer(left); + if (exportDeclaration) { + return createExportExpression(left, node); + } + break; + case 172 /* ObjectLiteralExpression */: + case 171 /* ArrayLiteralExpression */: + if (hasExportedReferenceInDestructuringPattern(left)) { + return substituteDestructuring(node); + } + break; + } + return node; + } + function isExportedBinding(name) { + var container = resolver.getReferencedExportContainer(name); + return container && container.kind === 256 /* SourceFile */; + } + function hasExportedReferenceInDestructuringPattern(node) { + switch (node.kind) { + case 70 /* Identifier */: + return isExportedBinding(node); + case 172 /* ObjectLiteralExpression */: + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (hasExportedReferenceInObjectDestructuringElement(property)) { + return true; + } + } + break; + case 171 /* ArrayLiteralExpression */: + for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { + var element = _c[_b]; + if (hasExportedReferenceInArrayDestructuringElement(element)) { + return true; + } + } + break; + } + return false; + } + function hasExportedReferenceInObjectDestructuringElement(node) { + if (ts.isShorthandPropertyAssignment(node)) { + return isExportedBinding(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringElement(node.initializer); + } + else { + return false; + } + } + function hasExportedReferenceInArrayDestructuringElement(node) { + if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else { + return hasExportedReferenceInDestructuringElement(node); + } + } + function hasExportedReferenceInDestructuringElement(node) { + if (ts.isBinaryExpression(node)) { + var left = node.left; + return node.operatorToken.kind === 57 /* EqualsToken */ + && isDestructuringPattern(left) + && hasExportedReferenceInDestructuringPattern(left); + } + else if (ts.isIdentifier(node)) { + return isExportedBinding(node); + } + else if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else if (isDestructuringPattern(node)) { + return hasExportedReferenceInDestructuringPattern(node); + } + else { + return false; + } + } + function isDestructuringPattern(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; + } + function substituteDestructuring(node) { + return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); + } + function substituteUnaryExpression(node) { + var operand = node.operand; + var operator = node.operator; + var substitute = ts.isIdentifier(operand) && + (node.kind === 187 /* PostfixUnaryExpression */ || + (node.kind === 186 /* PrefixUnaryExpression */ && (operator === 42 /* PlusPlusToken */ || operator === 43 /* MinusMinusToken */))); + if (substitute) { + var exportDeclaration = resolver.getReferencedExportContainer(operand); + if (exportDeclaration) { + var expr = ts.createPrefix(node.operator, operand, node); + ts.setEmitFlags(expr, 128 /* NoSubstitution */); + var call = createExportExpression(operand, expr); + if (node.kind === 186 /* PrefixUnaryExpression */) { + return call; + } + else { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + return operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(call, ts.createLiteral(1)) + : ts.createAdd(call, ts.createLiteral(1)); + } } } return node; } /** - * Determines whether a name is the name of a declaration with a colliding name. - * NOTE: This function expects to be called with an original source tree node. - * - * @param node An original source tree node. + * Gets a name to use for a DeclarationStatement. + * @param node The declaration statement. */ - function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 218 /* VariableDeclaration */: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function addExportStarFunction(statements, localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); } - return false; + statements.push(ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, exportStarFunction, + /*typeParameters*/ undefined, [ts.createParameter(m)], + /*type*/ undefined, ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, + /*type*/ undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, /*type*/ undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ])), + ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [exports])) + ], + /*location*/ undefined, + /*multiline*/ true))); + return exportStarFunction; } /** - * Substitutes an expression. - * - * @param node An Expression node. + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. */ - function substituteExpression(node) { + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; + return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); + } + /** + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. + */ + function createExportStatement(name, value) { + return ts.createStatement(createExportExpression(name, value)); + } + /** + * Creates a call to the current file's export function to export a declaration. + * @param node The declaration to export. + */ + function createDeclarationExport(node) { + var declarationName = getDeclarationName(node); + var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; + return createExportStatement(exportName, declarationName); + } + function createImportBinding(importDeclaration) { + var importAlias; + var name; + if (ts.isImportClause(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); + name = ts.createIdentifier("default"); + } + else if (ts.isImportSpecifier(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); + name = importDeclaration.propertyName || importDeclaration.name; + } + else { + return undefined; + } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + } + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } + } + return dependencyGroups; + } + function getNameOfDependencyGroup(dependencyGroup) { + return dependencyGroup.name; + } + function recordExportName(name) { + if (!exportedLocalNames) { + exportedLocalNames = []; + } + exportedLocalNames.push(name); + } + function recordExportedFunctionDeclaration(node) { + if (!exportedFunctionDeclarations) { + exportedFunctionDeclarations = []; + } + exportedFunctionDeclarations.push(createDeclarationExport(node)); + } + function hoistBindingElement(node, isExported) { + if (ts.isOmittedExpression(node)) { + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + if (isExported) { + recordExportName(name); + } + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + } + } + function hoistExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ true); + } + function hoistNonExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ false); + } + function updateSourceFile(node, statements, nodeEmitFlags) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + ts.setEmitFlags(updated, nodeEmitFlags); + return updated; + } + } + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 97 /* ThisKeyword */: - return substituteThisKeyword(node); + case 230 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 236 /* ExportAssignment */: + return visitExportAssignment(node); } return node; } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(253 /* PropertyAssignment */); + return transformSourceFile; /** - * Substitutes an expression identifier. + * Transforms an ES5 source file to ES3. * - * @param node An Identifier node. + * @param node A SourceFile */ - function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); - } - } + function transformSourceFile(node) { return node; } /** - * Substitutes `this` when contained within an arrow function. + * Hooks node substitutions. * - * @param node The ThisKeyword node. + * @param emitContext The context for the emitter. + * @param node The node to substitute. */ - function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); } return node; } /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". + * Substitutes a PropertyAccessExpression whose name is a reserved word. * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + * @param node A PropertyAccessExpression */ - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, /*location*/ node); + } + return node; } /** - * Gets the name of a declaration, without source map or comments. + * Substitutes a PropertyAssignment whose name is a reserved word. * - * @param node The declaration. - * @param allowComments Allow comments for the name. + * @param node A PropertyAssignment */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_39 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_39, emitFlags); - } - return name_39; + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); } - return ts.getGeneratedNameForNode(node); - } - function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); - return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + return node; } - function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { - if (!constructor || !hasExtendsClause) { - return false; - } - var parameter = ts.singleOrUndefined(constructor.parameters); - if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { - return false; - } - var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202 /* ExpressionStatement */) { - return false; - } - var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174 /* CallExpression */) { - return false; - } - var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95 /* SuperKeyword */) { - return false; - } - var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191 /* SpreadElementExpression */) { - return false; + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.createLiteral(name, /*location*/ name); } - var expression = callArgument.expression; - return ts.isIdentifier(expression) && expression === parameter.name; + return undefined; } } - ts.transformES6 = transformES6; + ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /// -/// -/// +/// +/// +/// /// +/// /// /// -/// +/// /* @internal */ var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, @@ -53039,11 +53727,19 @@ var ts; if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); - if (languageVersion < 2 /* ES6 */) { - transformers.push(ts.transformES6); + if (languageVersion < 4 /* ES2017 */) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3 /* ES2016 */) { + transformers.push(ts.transformES2016); + } + if (languageVersion < 2 /* ES2015 */) { + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1 /* ES5 */) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -53073,7 +53769,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -53274,7 +53970,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; /** * Initialize the SourceMapWriter for a new output file. @@ -53548,7 +54244,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } /** @@ -53625,7 +54321,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -53669,7 +54365,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 === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -53756,7 +54452,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -53775,7 +54471,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { writer.write(" "); @@ -53799,7 +54495,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); @@ -53923,7 +54619,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -53979,7 +54675,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 231 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -54013,7 +54709,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -54053,10 +54749,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218 /* VariableDeclaration */) { + if (declaration.kind === 219 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 /* NamedImports */ || declaration.kind === 234 /* ImportSpecifier */ || declaration.kind === 231 /* ImportClause */) { + else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -54074,7 +54770,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 === 230 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 231 /* 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; @@ -54084,12 +54780,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -54206,53 +54902,53 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 166 /* ThisType */: + case 167 /* LiteralType */: return writeTextOfNode(currentText, type); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(type); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(type); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(type); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(type); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(type); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenType(type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(type); - case 69 /* Identifier */: + case 70 /* Identifier */: return emitEntityName(type); - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitEntityName(type); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 139 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 140 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 140 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -54261,14 +54957,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 229 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 230 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 172 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 173 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -54354,7 +55050,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -54377,12 +55073,12 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -54396,7 +55092,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 /* ImportEqualsDeclaration */ || + else if (node.kind === 230 /* ImportEqualsDeclaration */ || (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { @@ -54409,7 +55105,7 @@ var ts; }); } else { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -54427,23 +55123,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return writeVariableStatement(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return writeClassDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -54460,7 +55156,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 222 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -54502,7 +55198,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -54512,7 +55208,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -54536,7 +55232,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 233 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -54557,13 +55253,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 !== 225 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 229 /* ImportEqualsDeclaration */) { + if (parent.kind === 230 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225 /* ModuleDeclaration */) { + else if (parent.kind === 226 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -54633,7 +55329,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226 /* ModuleBlock */) { + while (node.body && node.body.kind !== 227 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -54667,7 +55363,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -54703,7 +55399,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 148 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -54714,50 +55410,50 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 159 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 147 /* MethodDeclaration */ || - node.parent.kind === 146 /* MethodSignature */ || - node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.kind === 151 /* CallSignature */ || - node.parent.kind === 152 /* ConstructSignature */); + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 160 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 148 /* MethodDeclaration */ || + node.parent.kind === 147 /* MethodSignature */ || + node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.kind === 152 /* CallSignature */ || + node.parent.kind === 153 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: 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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* 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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -54785,17 +55481,17 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 94 /* NullKeyword */) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 221 /* ClassDeclaration */) { + if (node.parent.parent.kind === 222 /* 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 : @@ -54879,7 +55575,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 !== 218 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -54890,11 +55586,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */ || - (node.kind === 142 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */ || + (node.kind === 143 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) && node.parent.kind === 159 /* TypeLiteral */) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) && node.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -54907,14 +55603,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* 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 : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) { + else if (node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -54923,7 +55619,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* 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 : @@ -54955,7 +55651,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193 /* OmittedExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { elements.push(element); } } @@ -55025,7 +55721,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 149 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -55038,7 +55734,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 /* GetAccessor */ + return accessor.kind === 150 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -55047,7 +55743,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 151 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -55097,17 +55793,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 /* MethodDeclaration */ || node.kind === 148 /* Constructor */) { + else if (node.kind === 148 /* MethodDeclaration */ || node.kind === 149 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148 /* Constructor */) { + else if (node.kind === 149 /* Constructor */) { write("constructor"); } else { @@ -55127,17 +55823,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 152 /* ConstructSignature */ || node.kind === 157 /* ConstructorType */) { + if (node.kind === 153 /* ConstructSignature */ || node.kind === 158 /* ConstructorType */) { write("new "); } - else if (node.kind === 156 /* FunctionType */) { + else if (node.kind === 157 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -55152,22 +55848,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 156 /* FunctionType */ || node.kind === 157 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 157 /* FunctionType */ || node.kind === 158 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 149 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -55181,26 +55877,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55208,7 +55904,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* 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 : @@ -55222,7 +55918,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220 /* FunctionDeclaration */: + case 221 /* 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 : @@ -55257,9 +55953,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.parent.kind === 159 /* TypeLiteral */) { + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -55275,24 +55971,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55300,7 +55996,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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* 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 : @@ -55313,7 +56009,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 220 /* FunctionDeclaration */: + case 221 /* 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 : @@ -55325,12 +56021,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 167 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -55341,7 +56037,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193 /* OmittedExpression */) { + if (bindingElement.kind === 194 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -55350,7 +56046,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 169 /* BindingElement */) { + else if (bindingElement.kind === 170 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -55373,7 +56069,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 70 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -55389,38 +56085,38 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 222 /* InterfaceDeclaration */: - case 221 /* ClassDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 223 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return writeFunctionDeclaration(node); - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return emitPropertyDeclaration(node); case 255 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); case 256 /* SourceFile */: return emitSourceFile(node); @@ -55448,7 +56144,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path if (isBundledEmit && !addBundledFileReference) { return; @@ -55502,7 +56198,7 @@ var ts; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); @@ -55817,7 +56513,7 @@ var ts; var kind = node.kind; switch (kind) { // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); } } @@ -55831,199 +56527,213 @@ var ts; var kind = node.kind; switch (kind) { // Pseudo-literals - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 82 /* ExportKeyword */: - case 103 /* VoidKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 104 /* VoidKeyword */: // Strict mode reserved words - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 113 /* StaticKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 114 /* StaticKeyword */: // Contextual keywords - case 115 /* AbstractKeyword */: - case 117 /* AnyKeyword */: - case 118 /* AsyncKeyword */: - case 120 /* BooleanKeyword */: - case 122 /* DeclareKeyword */: - case 130 /* NumberKeyword */: - case 128 /* ReadonlyKeyword */: - case 132 /* StringKeyword */: - case 133 /* SymbolKeyword */: - case 137 /* GlobalKeyword */: + case 116 /* AbstractKeyword */: + case 117 /* AsKeyword */: + case 118 /* AnyKeyword */: + case 119 /* AsyncKeyword */: + case 120 /* AwaitKeyword */: + case 121 /* BooleanKeyword */: + case 122 /* ConstructorKeyword */: + case 123 /* DeclareKeyword */: + case 124 /* GetKeyword */: + case 125 /* IsKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 128 /* NeverKeyword */: + case 129 /* ReadonlyKeyword */: + case 130 /* RequireKeyword */: + case 131 /* NumberKeyword */: + case 132 /* SetKeyword */: + case 133 /* StringKeyword */: + case 134 /* SymbolKeyword */: + case 135 /* TypeKeyword */: + case 136 /* UndefinedKeyword */: + case 137 /* FromKeyword */: + case 138 /* GlobalKeyword */: + case 139 /* OfKeyword */: writeTokenText(kind); return; // Parse tree nodes // Names - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitQualifiedName(node); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return emitTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return emitParameter(node); - case 143 /* Decorator */: + case 144 /* Decorator */: return emitDecorator(node); // Type members - case 144 /* PropertySignature */: + case 145 /* PropertySignature */: return emitPropertySignature(node); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 146 /* MethodSignature */: + case 147 /* MethodSignature */: return emitMethodSignature(node); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return emitConstructor(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 151 /* CallSignature */: + case 152 /* CallSignature */: return emitCallSignature(node); - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return emitConstructSignature(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return emitIndexSignature(node); // Types - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(node); - case 156 /* FunctionType */: + case 157 /* FunctionType */: return emitFunctionType(node); - case 157 /* ConstructorType */: + case 158 /* ConstructorType */: return emitConstructorType(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(node); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(node); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenthesizedType(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 165 /* ThisType */: - return emitThisType(node); - case 166 /* LiteralType */: + case 166 /* ThisType */: + return emitThisType(); + case 167 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return emitBindingElement(node); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return emitTemplateSpan(node); - case 198 /* SemicolonClassElement */: - return emitSemicolonClassElement(node); + case 199 /* SemicolonClassElement */: + return emitSemicolonClassElement(); // Statements - case 199 /* Block */: + case 200 /* Block */: return emitBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitVariableStatement(node); - case 201 /* EmptyStatement */: - return emitEmptyStatement(node); - case 202 /* ExpressionStatement */: + case 202 /* EmptyStatement */: + return emitEmptyStatement(); + case 203 /* ExpressionStatement */: return emitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return emitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return emitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return emitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return emitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return emitForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return emitForOfStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return emitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return emitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return emitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return emitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return emitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return emitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return emitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return emitTryStatement(node); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return emitClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return emitModuleBlock(node); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return emitCaseBlock(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return emitImportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return emitImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return emitNamespaceImport(node); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return emitNamedImports(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return emitImportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 237 /* NamedExports */: + case 238 /* NamedExports */: return emitNamedExports(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return emitExportSpecifier(node); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return; // Module references - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 244 /* JsxText */: + case 10 /* JsxText */: return emitJsxText(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return emitJsxOpeningElement(node); case 245 /* JsxClosingElement */: return emitJsxClosingElement(node); @@ -56070,77 +56780,77 @@ var ts; case 8 /* NumericLiteral */: return emitNumericLiteral(node); case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 99 /* TrueKeyword */: - case 97 /* ThisKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 100 /* TrueKeyword */: + case 98 /* ThisKeyword */: writeTokenText(kind); return; // Expressions - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return emitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emitNewExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return emitFunctionExpression(node); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return emitArrowFunction(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return emitDeleteExpression(node); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return emitVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return emitAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return emitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return emitConditionalExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return emitTemplateExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return emitYieldExpression(node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return emitClassExpression(node); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return; - case 195 /* AsExpression */: + case 196 /* AsExpression */: return emitAsExpression(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return emitJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes case 288 /* PartiallyEmittedExpression */: @@ -56193,7 +56903,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -56269,7 +56979,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 150 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -56297,7 +57007,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } // @@ -56354,7 +57064,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -56428,7 +57138,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -56446,7 +57156,7 @@ var ts; if (expression.kind === 8 /* NumericLiteral */) { // check if numeric literal was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -56465,11 +57175,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { @@ -56541,16 +57253,16 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 185 /* PrefixUnaryExpression */ - && ((node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) - || (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */))); + return operand.kind === 186 /* PrefixUnaryExpression */ + && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) + || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 25 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -56617,16 +57329,16 @@ var ts; // // Statements // - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); write(" "); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } else { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } function emitBlockStatements(node) { @@ -56642,7 +57354,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -56650,16 +57362,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88 /* IfKeyword */, node.pos, node); + var openParenPos = writeToken(89 /* IfKeyword */, node.pos, node); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, node); + writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end, node); + writeToken(19 /* CloseParenToken */, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 203 /* IfStatement */) { + writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); + if (node.elseStatement.kind === 204 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -56688,9 +57400,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, /*contextNode*/ node); + writeToken(18 /* OpenParenToken */, openParenPos, /*contextNode*/ node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -56700,28 +57412,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { emit(node); } else { @@ -56730,17 +57442,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75 /* ContinueKeyword */, node.pos); + writeToken(76 /* ContinueKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70 /* BreakKeyword */, node.pos); + writeToken(71 /* BreakKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + writeToken(95 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -56751,11 +57463,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96 /* SwitchKeyword */, node.pos); + var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); write(" "); emit(node.caseBlock); } @@ -56780,7 +57492,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76 /* DebuggerKeyword */, node.pos); + writeToken(77 /* DebuggerKeyword */, node.pos); write(";"); } // @@ -56788,6 +57500,7 @@ var ts; // function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -56814,13 +57527,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304 /* ReuseTempVariableScope */) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -56843,7 +57556,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { // We must emit a function body as a single-line body in the following case: // * The body has NodeEmitFlags.SingleLine specified. // We must emit a function body as a multi-line body in the following cases: @@ -56873,14 +57586,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16 /* CloseBraceToken */, body.statements.end, body); + writeToken(17 /* CloseBraceToken */, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -56959,7 +57672,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225 /* ModuleDeclaration */) { + while (body.kind === 226 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -56982,9 +57695,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15 /* OpenBraceToken */, node.pos); + writeToken(16 /* OpenBraceToken */, node.pos); emitList(node, node.clauses, 65 /* CaseBlockClauses */); - writeToken(16 /* CloseBraceToken */, node.clauses.end); + writeToken(17 /* CloseBraceToken */, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -56995,7 +57708,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57121,7 +57834,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57164,11 +57877,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72 /* CatchKeyword */, node.pos); + var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emit(node.variableDeclaration); - writeToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -57279,7 +57992,7 @@ var ts; var helpersEmitted = false; // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { + if ((languageVersion < 2 /* ES2015 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; helpersEmitted = true; @@ -57301,9 +58014,12 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */) { + // Only emit __awaiter function when target ES5/ES6. + // Only emit __generator function when target ES5. + // For target ES2017 and above, we can emit async/await as is. + if ((languageVersion < 4 /* ES2017 */) && (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */)) { writeLines(awaiterHelper); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { writeLines(generatorHelper); } awaiterEmitted = true; @@ -57630,7 +58346,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -57755,19 +58471,19 @@ var ts; */ function generateNameForNode(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 230 /* ImportDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: - case 235 /* ExportAssignment */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 236 /* ExportAssignment */: return generateNameForExportDefault(); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58440,7 +59156,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -58530,7 +59246,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -58563,14 +59279,14 @@ var ts; // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -58580,16 +59296,16 @@ var ts; return false; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -58598,29 +59314,29 @@ var ts; break; case 251 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 106 /* ImplementsKeyword */) { + if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -58628,20 +59344,20 @@ var ts; return true; } break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -58649,7 +59365,7 @@ var ts; return true; } break; - case 142 /* Parameter */: + case 143 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -58665,12 +59381,12 @@ var ts; return true; } break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113 /* StaticKeyword */) { + if (modifier.kind !== 114 /* StaticKeyword */) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -58680,14 +59396,14 @@ var ts; return true; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 143 /* Decorator */: + case 144 /* Decorator */: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, 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)); } @@ -58715,19 +59431,19 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 128 /* ReadonlyKeyword */: - case 122 /* DeclareKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 123 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 113 /* StaticKeyword */: - case 82 /* ExportKeyword */: - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 115 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 83 /* ExportKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 116 /* AbstractKeyword */: } } } @@ -58761,7 +59477,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, /*isReference*/ true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -58802,9 +59518,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -58819,7 +59535,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225 /* ModuleDeclaration */: + case 226 /* 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. @@ -58859,7 +59575,7 @@ var ts; /** * 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration) */ - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -58867,7 +59583,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -58877,13 +59593,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -58908,7 +59624,7 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -58921,16 +59637,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -58959,13 +59675,12 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } // always process imported modules to record module name resolutions - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -58975,10 +59690,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, /*isReference*/ true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -59004,7 +59719,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -59019,7 +59734,7 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } } } @@ -59045,7 +59760,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -59071,7 +59786,7 @@ var ts; } else if (shouldAddFile) { findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), - /*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -59200,7 +59915,7 @@ var ts; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES6 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -59209,7 +59924,7 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span_7.start, span_7.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span_8 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_8.start, span_8.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -59250,7 +59965,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -59261,12 +59976,12 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } // Report error if multiple files write into same file if (emitFilesSeen.contains(emitFilePath)) { // Already seen the same emit file - report error - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -59274,7 +59989,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -59294,24 +60009,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -59326,7 +60041,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -59336,15 +60051,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -59353,7 +60068,7 @@ var ts; "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -59362,18 +60077,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -59384,11 +60099,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -59397,12 +60112,12 @@ var ts; "lf": 1 /* LineFeed */ }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -59411,7 +60126,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -59420,60 +60135,60 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, // for correct behaviour, please use outFile - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -59496,30 +60211,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -59530,7 +60245,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -59544,23 +60259,25 @@ var ts; type: ts.createMap({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, - "es6": 2 /* ES6 */, - "es2015": 2 /* ES2015 */ + "es6": 2 /* ES2015 */, + "es2015": 2 /* ES2015 */, + "es2016": 3 /* ES2016 */, + "es2017": 4 /* ES2017 */, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -59577,10 +60294,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -59710,7 +60427,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -59738,7 +60455,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -59762,7 +60479,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; /* @internal */ @@ -59784,10 +60501,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -60592,7 +61306,7 @@ var ts; StringScriptSnapshot.prototype.getLength = function () { return this.text.length; }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + StringScriptSnapshot.prototype.getChangeRange = function () { // Text-based snapshots do not support incremental parsing. Return undefined // to signal that to the caller. return undefined; @@ -60814,7 +61528,7 @@ var ts; /* @internal */ var ts; (function (ts) { - ts.scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); ts.emptyArray = []; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -60826,33 +61540,33 @@ var ts; var SemanticMeaning = ts.SemanticMeaning; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 252 /* CatchClause */: return 1 /* Value */; - case 141 /* TypeParameter */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 159 /* TypeLiteral */: + case 142 /* TypeParameter */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 160 /* TypeLiteral */: return 2 /* Type */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -60862,12 +61576,12 @@ var ts; else { return 4 /* Namespace */; } - case 233 /* NamedImports */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: - case 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 234 /* NamedImports */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value case 256 /* SourceFile */: @@ -60877,7 +61591,7 @@ var ts; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent.kind === 236 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -60898,19 +61612,19 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69 /* Identifier */); + ts.Debug.assert(node.kind === 70 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 139 /* QualifiedName */ && + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 229 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 230 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 139 /* QualifiedName */) { + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -60921,27 +61635,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 139 /* QualifiedName */) { - while (root.parent && root.parent.kind === 139 /* QualifiedName */) { + if (root.parent.kind === 140 /* QualifiedName */) { + while (root.parent && root.parent.kind === 140 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 155 /* TypeReference */ && !isLastClause; + return root.parent.kind === 156 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 172 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 172 /* PropertyAccessExpression */) { + if (root.parent.kind === 173 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 173 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 195 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 221 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 222 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 222 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 223 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -60949,17 +61663,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 155 /* TypeReference */ || - (node.parent.kind === 194 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 165 /* ThisType */; + return node.parent.kind === 156 /* TypeReference */ || + (node.parent.kind === 195 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || + node.kind === 166 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 175 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -60972,7 +61686,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 214 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -60981,14 +61695,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 69 /* Identifier */ && - (node.parent.kind === 210 /* BreakStatement */ || node.parent.kind === 209 /* ContinueStatement */) && + return node.kind === 70 /* Identifier */ && + (node.parent.kind === 211 /* BreakStatement */ || node.parent.kind === 210 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 69 /* Identifier */ && - node.parent.kind === 214 /* LabeledStatement */ && + return node.kind === 70 /* Identifier */ && + node.parent.kind === 215 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -60996,38 +61710,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 226 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 226 /* ModuleDeclaration */: return node.parent.name === node; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return true; } } @@ -61077,16 +61791,16 @@ var ts; } switch (node.kind) { case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return node; } } @@ -61096,42 +61810,42 @@ var ts; switch (node.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 222 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 223 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 224 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 218 /* VariableDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 224 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 225 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 219 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 149 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 150 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 150 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 151 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 153 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 152 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 151 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 148 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 141 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 154 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 153 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 152 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 149 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 142 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 142 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229 /* ImportEqualsDeclaration */: - case 234 /* ImportSpecifier */: - case 231 /* ImportClause */: - case 238 /* ExportSpecifier */: - case 232 /* NamespaceImport */: + case 143 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230 /* ImportEqualsDeclaration */: + case 235 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 239 /* ExportSpecifier */: + case 233 /* NamespaceImport */: return ts.ScriptElementKind.alias; case 279 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; @@ -61148,7 +61862,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 167 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -61158,12 +61872,12 @@ var ts; ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 69 /* Identifier */: + case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143 /* Parameter */; default: return false; } @@ -61208,42 +61922,42 @@ var ts; return false; } switch (n.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 167 /* ObjectBindingPattern */: - case 159 /* TypeLiteral */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 227 /* CaseBlock */: - case 233 /* NamedImports */: - case 237 /* NamedExports */: - return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 168 /* ObjectBindingPattern */: + case 160 /* TypeLiteral */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 228 /* CaseBlock */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: + return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); case 252 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 175 /* NewExpression */: + case 176 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 174 /* CallExpression */: - case 178 /* ParenthesizedExpression */: - case 164 /* ParenthesizedType */: - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 175 /* CallExpression */: + case 179 /* ParenthesizedExpression */: + case 165 /* ParenthesizedType */: + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 181 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -61252,68 +61966,68 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 18 /* CloseParenToken */, sourceFile); - case 225 /* ModuleDeclaration */: + return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); + case 226 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 203 /* IfStatement */: + case 204 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23 /* SemicolonToken */); - case 170 /* ArrayLiteralExpression */: - case 168 /* ArrayBindingPattern */: - case 173 /* ElementAccessExpression */: - case 140 /* ComputedPropertyName */: - case 161 /* TupleType */: - return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 153 /* IndexSignature */: + hasChildOfKind(n, 24 /* SemicolonToken */); + case 171 /* ArrayLiteralExpression */: + case 169 /* ArrayBindingPattern */: + case 174 /* ElementAccessExpression */: + case 141 /* ComputedPropertyName */: + case 162 /* TupleType */: + return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); + case 154 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); case 249 /* CaseClause */: case 250 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 182 /* TypeOfExpression */: - case 181 /* DeleteExpression */: - case 183 /* VoidExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: + case 183 /* TypeOfExpression */: + case 182 /* DeleteExpression */: + case 184 /* VoidExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 236 /* ExportDeclaration */: - case 230 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -61331,7 +62045,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 24 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -61504,7 +62218,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61512,7 +62226,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61526,10 +62240,10 @@ var ts; // if no - position is in the node itself so we should recurse in it. // NOTE: JsxText is a weird kind of node that can contain only whitespaces (since they are not counted as trivia). // if this is the case - then we should assume that token in question is located in previous child. - if (position < child.end && (nodeHasTokens(child) || child.kind === 244 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 10 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 244 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 10 /* JsxText */ && start === child.end); // whitespace only JsxText if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); @@ -61592,25 +62306,25 @@ var ts; if (!token) { return false; } - if (token.kind === 244 /* JsxText */) { + if (token.kind === 10 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 244 /* JsxText */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 16 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
|
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { return true; } return false; @@ -61667,9 +62381,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -61722,21 +62436,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 /* TypeReference */ || node.kind === 174 /* CallExpression */) { + if (node.kind === 156 /* TypeReference */ || node.kind === 175 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 221 /* ClassDeclaration */ || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 138 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 139 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 69 /* Identifier */ || ts.isKeyword(kind); + return kind === 70 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -61748,7 +62462,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 10 /* RegularExpressionLiteral */ + || kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -61756,7 +62470,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; + return 16 /* FirstPunctuation */ <= kind && kind <= 69 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -61766,9 +62480,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: return true; } return false; @@ -61791,18 +62505,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 /* ArrayLiteralExpression */ || - node.kind === 171 /* ObjectLiteralExpression */) { + if (node.kind === 171 /* ArrayLiteralExpression */ || + node.kind === 172 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 187 /* BinaryExpression */ && + if (node.parent.kind === 188 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 208 /* ForOfStatement */ && + if (node.parent.kind === 209 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -61843,7 +62557,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -61896,7 +62610,7 @@ var ts; } } function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3 /* Variable */) { @@ -61945,7 +62659,7 @@ var ts; } } ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { + function displayPart(text, kind) { return { text: text, kind: ts.SymbolDisplayPartKind[kind] @@ -62023,7 +62737,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140 /* ComputedPropertyName */) { + location.parent.kind === 141 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -62035,7 +62749,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 234 /* ImportSpecifier */ || location.parent.kind === 238 /* ExportSpecifier */) && + (location.parent.kind === 235 /* ImportSpecifier */ || location.parent.kind === 239 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -62081,7 +62795,7 @@ var ts; var options = { fileName: "config.js", compilerOptions: { - target: 2 /* ES6 */, + target: 2 /* ES2015 */, removeComments: true }, reportDiagnostics: true @@ -62107,24 +62821,24 @@ var ts; (function (ts) { /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[69 /* Identifier */] = true; + noRegexTable[70 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; - noRegexTable[10 /* RegularExpressionLiteral */] = true; - noRegexTable[97 /* ThisKeyword */] = true; - noRegexTable[41 /* PlusPlusToken */] = true; - noRegexTable[42 /* MinusMinusToken */] = true; - noRegexTable[18 /* CloseParenToken */] = true; - noRegexTable[20 /* CloseBracketToken */] = true; - noRegexTable[16 /* CloseBraceToken */] = true; - noRegexTable[99 /* TrueKeyword */] = true; - noRegexTable[84 /* FalseKeyword */] = true; + noRegexTable[11 /* RegularExpressionLiteral */] = true; + noRegexTable[98 /* ThisKeyword */] = true; + noRegexTable[42 /* PlusPlusToken */] = true; + noRegexTable[43 /* MinusMinusToken */] = true; + noRegexTable[19 /* CloseParenToken */] = true; + noRegexTable[21 /* CloseBracketToken */] = true; + noRegexTable[17 /* CloseBraceToken */] = true; + noRegexTable[100 /* TrueKeyword */] = true; + noRegexTable[85 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -62149,10 +62863,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 123 /* GetKeyword */ || - keyword2 === 131 /* SetKeyword */ || - keyword2 === 121 /* ConstructorKeyword */ || - keyword2 === 113 /* StaticKeyword */) { + if (keyword2 === 124 /* GetKeyword */ || + keyword2 === 132 /* SetKeyword */ || + keyword2 === 122 /* ConstructorKeyword */ || + keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -62251,7 +62965,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(12 /* TemplateHead */); + templateStack.push(13 /* TemplateHead */); break; } scanner.setText(text); @@ -62282,71 +62996,71 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { - token = 10 /* RegularExpressionLiteral */; + if ((token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11 /* RegularExpressionLiteral */) { + token = 11 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 69 /* Identifier */; + else if (lastNonTriviaToken === 22 /* DotToken */ && isKeyword(token)) { + token = 70 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 69 /* Identifier */; + token = 70 /* Identifier */; } - else if (lastNonTriviaToken === 69 /* Identifier */ && - token === 25 /* LessThanToken */) { + else if (lastNonTriviaToken === 70 /* Identifier */ && + token === 26 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 28 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 117 /* AnyKeyword */ || - token === 132 /* StringKeyword */ || - token === 130 /* NumberKeyword */ || - token === 120 /* BooleanKeyword */ || - token === 133 /* SymbolKeyword */) { + else if (token === 118 /* AnyKeyword */ || + token === 133 /* StringKeyword */ || + token === 131 /* NumberKeyword */ || + token === 121 /* BooleanKeyword */ || + token === 134 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 69 /* Identifier */; + token = 70 /* Identifier */; } } - else if (token === 12 /* TemplateHead */) { + else if (token === 13 /* TemplateHead */) { templateStack.push(token); } - else if (token === 15 /* OpenBraceToken */) { + else if (token === 16 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12 /* TemplateHead */) { + if (lastTemplateStackToken === 13 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 14 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 16 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -62387,10 +63101,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 11 /* NoSubstitutionTemplateLiteral */) { + else if (token === 12 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -62398,7 +63112,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -62428,43 +63142,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - case 46 /* AmpersandToken */: - case 48 /* CaretToken */: - case 47 /* BarToken */: - case 51 /* AmpersandAmpersandToken */: - case 52 /* BarBarToken */: - case 67 /* BarEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 56 /* EqualsToken */: - case 24 /* CommaToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: + case 47 /* AmpersandToken */: + case 49 /* CaretToken */: + case 48 /* BarToken */: + case 52 /* AmpersandAmpersandToken */: + case 53 /* BarBarToken */: + case 68 /* BarEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 57 /* EqualsToken */: + case 25 /* CommaToken */: return true; default: return false; @@ -62472,19 +63186,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 138 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 139 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -62493,7 +63207,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { + else if (token >= 16 /* FirstPunctuation */ && token <= 69 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -62501,7 +63215,7 @@ var ts; return 4 /* numericLiteral */; case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -62510,7 +63224,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 69 /* Identifier */: + case 70 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -62541,10 +63255,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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -62595,7 +63309,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 /* ModuleDeclaration */ && + return declaration.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -62605,7 +63319,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 70 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -62674,8 +63388,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -62839,10 +63553,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 244 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -62855,7 +63569,7 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } @@ -62865,7 +63579,7 @@ var ts; return 20 /* jsxCloseTagName */; } break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } @@ -62887,7 +63601,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { + if (tokenKind === 26 /* LessThanToken */ || tokenKind === 28 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -62896,19 +63610,19 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 56 /* EqualsToken */) { + if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 218 /* VariableDeclaration */ || - token.parent.kind === 145 /* PropertyDeclaration */ || - token.parent.kind === 142 /* Parameter */ || + if (token.parent.kind === 219 /* VariableDeclaration */ || + token.parent.kind === 146 /* PropertyDeclaration */ || + token.parent.kind === 143 /* Parameter */ || token.parent.kind === 246 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 187 /* BinaryExpression */ || - token.parent.kind === 185 /* PrefixUnaryExpression */ || - token.parent.kind === 186 /* PostfixUnaryExpression */ || - token.parent.kind === 188 /* ConditionalExpression */) { + if (token.parent.kind === 188 /* BinaryExpression */ || + token.parent.kind === 186 /* PrefixUnaryExpression */ || + token.parent.kind === 187 /* PostfixUnaryExpression */ || + token.parent.kind === 189 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -62920,7 +63634,7 @@ var ts; else if (tokenKind === 9 /* StringLiteral */) { return token.parent.kind === 246 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } - else if (tokenKind === 10 /* RegularExpressionLiteral */) { + else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -62928,38 +63642,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 244 /* JsxText */) { + else if (tokenKind === 10 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 69 /* Identifier */) { + else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 142 /* Parameter */: + case 143 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -62989,6 +63703,7 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); +/// /* @internal */ var ts; (function (ts) { @@ -63028,7 +63743,7 @@ var ts; name: tagName.text, kind: undefined, kindModifiers: undefined, - sortText: "0" + sortText: "0", }); } else { @@ -63085,7 +63800,7 @@ var ts; name: displayName, kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" + sortText: "0", }; } function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { @@ -63113,7 +63828,7 @@ var ts; return undefined; } if (node.parent.kind === 253 /* PropertyAssignment */ && - node.parent.parent.kind === 171 /* ObjectLiteralExpression */ && + node.parent.parent.kind === 172 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -63138,7 +63853,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 230 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 231 /* 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*/"); @@ -63151,7 +63866,7 @@ var ts; // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" @@ -63168,7 +63883,7 @@ var ts; } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { var candidates = []; var entries = []; typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); @@ -63531,7 +64246,7 @@ var ts; if (typeRoots) { for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -63540,12 +64255,12 @@ var ts; for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { var packageJson = _d[_c]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { + function getCompletionEntriesFromDirectories(host, directory, span, result) { if (host.getDirectories && tryDirectoryExists(host, directory)) { var directories = tryGetDirectories(host, directory); if (directories) { @@ -63769,12 +64484,12 @@ var ts; return undefined; } var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21 /* DotToken */) { - if (parent_17.kind === 172 /* PropertyAccessExpression */) { + if (kind === 22 /* DotToken */) { + if (parent_17.kind === 173 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139 /* QualifiedName */) { + else if (parent_17.kind === 140 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -63785,11 +64500,11 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 25 /* LessThanToken */) { + if (kind === 26 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -63830,7 +64545,6 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; @@ -63839,7 +64553,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -63895,10 +64609,9 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 242 /* JsxSelfClosingElement */) || (jsxContainer.kind === 243 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -63942,6 +64655,13 @@ var ts; previousToken.getStart() : position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 /* SourceFile */ || + scopeNode.kind === 190 /* TemplateExpression */ || + scopeNode.kind === 248 /* JsxExpression */ || + ts.isStatement(scopeNode); + } /// TODO filter meaning based on the current context var symbolMeanings = 793064 /* Type */ | 107455 /* Value */ | 1920 /* Namespace */ | 8388608 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); @@ -63968,15 +64688,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 244 /* JsxText */) { + if (contextToken.kind === 10 /* JsxText */) { return true; } - if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 243 /* JsxOpeningElement */) { + if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 242 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241 /* JsxElement */; + if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 243 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242 /* JsxElement */; } } return false; @@ -63985,41 +64705,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 174 /* CallExpression */ // func( a, | - || containingNodeKind === 148 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 175 /* NewExpression */ // new C(a, | - || containingNodeKind === 170 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 187 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 156 /* FunctionType */; // var x: (s: string, list| - case 17 /* OpenParenToken */: - return containingNodeKind === 174 /* CallExpression */ // func( | - || containingNodeKind === 148 /* Constructor */ // constructor( | - || containingNodeKind === 175 /* NewExpression */ // new C(a| - || containingNodeKind === 178 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 164 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 19 /* OpenBracketToken */: - return containingNodeKind === 170 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 153 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 140 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 125 /* ModuleKeyword */: // module | - case 126 /* NamespaceKeyword */: + case 25 /* CommaToken */: + return containingNodeKind === 175 /* CallExpression */ // func( a, | + || containingNodeKind === 149 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 176 /* NewExpression */ // new C(a, | + || containingNodeKind === 171 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 188 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 157 /* FunctionType */; // var x: (s: string, list| + case 18 /* OpenParenToken */: + return containingNodeKind === 175 /* CallExpression */ // func( | + || containingNodeKind === 149 /* Constructor */ // constructor( | + || containingNodeKind === 176 /* NewExpression */ // new C(a| + || containingNodeKind === 179 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 165 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 20 /* OpenBracketToken */: + return containingNodeKind === 171 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 154 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 141 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 126 /* ModuleKeyword */: // module | + case 127 /* NamespaceKeyword */: return true; - case 21 /* DotToken */: - return containingNodeKind === 225 /* ModuleDeclaration */; // module A.| - case 15 /* OpenBraceToken */: - return containingNodeKind === 221 /* ClassDeclaration */; // class A{ | - case 56 /* EqualsToken */: - return containingNodeKind === 218 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 187 /* BinaryExpression */; // x = a| - case 12 /* TemplateHead */: - return containingNodeKind === 189 /* TemplateExpression */; // `aa ${| - case 13 /* TemplateMiddle */: - return containingNodeKind === 197 /* TemplateSpan */; // `aa ${10} dd ${| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; // class A{ public | + case 22 /* DotToken */: + return containingNodeKind === 226 /* ModuleDeclaration */; // module A.| + case 16 /* OpenBraceToken */: + return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + case 57 /* EqualsToken */: + return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 188 /* BinaryExpression */; // x = a| + case 13 /* TemplateHead */: + return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + case 14 /* TemplateMiddle */: + return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -64033,7 +64753,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 10 /* RegularExpressionLiteral */ + || contextToken.kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -64046,7 +64766,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 10 /* RegularExpressionLiteral */; + || contextToken.kind === 11 /* RegularExpressionLiteral */; } } return false; @@ -64062,7 +64782,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 171 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -64072,7 +64792,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 167 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -64083,11 +64803,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 143 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 147 /* MethodDeclaration */ || rootDeclaration.parent.kind === 150 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 148 /* MethodDeclaration */ || rootDeclaration.parent.kind === 151 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -64129,9 +64849,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 /* NamedImports */ ? - 230 /* ImportDeclaration */ : - 236 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 234 /* NamedImports */ ? + 231 /* ImportDeclaration */ : + 237 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -64154,10 +64874,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // const x = { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // const x = { | + case 25 /* CommaToken */: var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { + if (parent_18 && (parent_18.kind === 172 /* ObjectLiteralExpression */ || parent_18.kind === 168 /* ObjectBindingPattern */)) { return parent_18; } break; @@ -64172,11 +64892,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // import { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // import { | + case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return contextToken.parent; } } @@ -64187,12 +64907,12 @@ var ts; if (contextToken) { var parent_19 = contextToken.parent; switch (contextToken.kind) { - case 26 /* LessThanSlashToken */: - case 39 /* SlashToken */: - case 69 /* Identifier */: + case 27 /* LessThanSlashToken */: + case 40 /* SlashToken */: + case 70 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { + if (parent_19 && (parent_19.kind === 243 /* JsxSelfClosingElement */ || parent_19.kind === 244 /* JsxOpeningElement */)) { return parent_19; } else if (parent_19.kind === 246 /* JsxAttribute */) { @@ -64207,7 +64927,7 @@ var ts; return parent_19.parent; } break; - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: if (parent_19 && parent_19.kind === 248 /* JsxExpression */ && parent_19.parent && @@ -64224,16 +64944,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return true; } return false; @@ -64244,67 +64964,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 218 /* VariableDeclaration */ || - containingNodeKind === 219 /* VariableDeclarationList */ || - containingNodeKind === 200 /* VariableStatement */ || - containingNodeKind === 224 /* EnumDeclaration */ || + case 25 /* CommaToken */: + return containingNodeKind === 219 /* VariableDeclaration */ || + containingNodeKind === 220 /* VariableDeclarationList */ || + containingNodeKind === 201 /* VariableStatement */ || + containingNodeKind === 225 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 168 /* ArrayBindingPattern */ || - containingNodeKind === 223 /* TypeAliasDeclaration */; // type Map, K, | - case 21 /* DotToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [.| - case 54 /* ColonToken */: - return containingNodeKind === 169 /* BindingElement */; // var {x :html| - case 19 /* OpenBracketToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [x| - case 17 /* OpenParenToken */: + containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 169 /* ArrayBindingPattern */ || + containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + case 22 /* DotToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + case 55 /* ColonToken */: + return containingNodeKind === 170 /* BindingElement */; // var {x :html| + case 20 /* OpenBracketToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + case 18 /* OpenParenToken */: return containingNodeKind === 252 /* CatchClause */ || isFunction(containingNodeKind); - case 15 /* OpenBraceToken */: - return containingNodeKind === 224 /* EnumDeclaration */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* TypeLiteral */; // const x : { | - case 23 /* SemicolonToken */: - return containingNodeKind === 144 /* PropertySignature */ && + case 16 /* OpenBraceToken */: + return containingNodeKind === 225 /* EnumDeclaration */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* TypeLiteral */; // const x : { | + case 24 /* SemicolonToken */: + return containingNodeKind === 145 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 159 /* TypeLiteral */); // const x : { a; | - case 25 /* LessThanToken */: - return containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 223 /* TypeAliasDeclaration */ || + (contextToken.parent.parent.kind === 223 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 160 /* TypeLiteral */); // const x : { a; | + case 26 /* LessThanToken */: + return containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 224 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 113 /* StaticKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; - case 22 /* DotDotDotToken */: - return containingNodeKind === 142 /* Parameter */ || + case 114 /* StaticKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; + case 23 /* DotDotDotToken */: + return containingNodeKind === 143 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168 /* ArrayBindingPattern */); // var [...z| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 142 /* Parameter */; - case 116 /* AsKeyword */: - return containingNodeKind === 234 /* ImportSpecifier */ || - containingNodeKind === 238 /* ExportSpecifier */ || - containingNodeKind === 232 /* NamespaceImport */; - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 107 /* InterfaceKeyword */: - case 87 /* FunctionKeyword */: - case 102 /* VarKeyword */: - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - case 89 /* ImportKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 114 /* YieldKeyword */: - case 134 /* TypeKeyword */: + contextToken.parent.parent.kind === 169 /* ArrayBindingPattern */); // var [...z| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 143 /* Parameter */; + case 117 /* AsKeyword */: + return containingNodeKind === 235 /* ImportSpecifier */ || + containingNodeKind === 239 /* ExportSpecifier */ || + containingNodeKind === 233 /* NamespaceImport */; + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 108 /* InterfaceKeyword */: + case 88 /* FunctionKeyword */: + case 103 /* VarKeyword */: + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + case 90 /* ImportKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 115 /* YieldKeyword */: + case 135 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -64376,8 +65096,8 @@ var ts; // Ignore omitted expressions for missing members if (m.kind !== 253 /* PropertyAssignment */ && m.kind !== 254 /* ShorthandPropertyAssignment */ && - m.kind !== 169 /* BindingElement */ && - m.kind !== 147 /* MethodDeclaration */) { + m.kind !== 170 /* BindingElement */ && + m.kind !== 148 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -64385,9 +65105,9 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 169 /* BindingElement */ && m.propertyName) { + if (m.kind === 170 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 69 /* Identifier */) { + if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; } } @@ -64465,7 +65185,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 138 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 139 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -64540,10 +65260,10 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 97 /* ThisKeyword */ || - node.kind === 165 /* ThisType */ || - node.kind === 95 /* SuperKeyword */ || + if (node.kind === 70 /* Identifier */ || + node.kind === 98 /* ThisKeyword */ || + node.kind === 166 /* ThisType */ || + node.kind === 96 /* SuperKeyword */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); @@ -64594,77 +65314,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 88 /* IfKeyword */: - case 80 /* ElseKeyword */: - if (hasKind(node.parent, 203 /* IfStatement */)) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 204 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 211 /* ReturnStatement */)) { + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 212 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 215 /* ThrowStatement */)) { + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 216 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 216 /* TryStatement */)) { + case 73 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 100 /* TryKeyword */: - case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 216 /* TryStatement */)) { + case 101 /* TryKeyword */: + case 86 /* FinallyKeyword */: + if (hasKind(parent(node), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 213 /* SwitchStatement */)) { + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 71 /* CaseKeyword */: - case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 213 /* SwitchStatement */)) { + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 70 /* BreakKeyword */: - case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 210 /* BreakStatement */) || hasKind(node.parent, 209 /* ContinueStatement */)) { + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 211 /* BreakStatement */) || hasKind(node.parent, 210 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 86 /* ForKeyword */: - if (hasKind(node.parent, 206 /* ForStatement */) || - hasKind(node.parent, 207 /* ForInStatement */) || - hasKind(node.parent, 208 /* ForOfStatement */)) { + case 87 /* ForKeyword */: + if (hasKind(node.parent, 207 /* ForStatement */) || + hasKind(node.parent, 208 /* ForInStatement */) || + hasKind(node.parent, 209 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 104 /* WhileKeyword */: - case 79 /* DoKeyword */: - if (hasKind(node.parent, 205 /* WhileStatement */) || hasKind(node.parent, 204 /* DoStatement */)) { + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 206 /* WhileStatement */) || hasKind(node.parent, 205 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 148 /* Constructor */)) { + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 149 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - if (hasKind(node.parent, 149 /* GetAccessor */) || hasKind(node.parent, 150 /* SetAccessor */)) { + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + if (hasKind(node.parent, 150 /* GetAccessor */) || hasKind(node.parent, 151 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 201 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -64680,10 +65400,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* ThrowStatement */) { + if (node.kind === 216 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 216 /* TryStatement */) { + else if (node.kind === 217 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -64716,7 +65436,7 @@ var ts; } // 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_20.kind === 216 /* TryStatement */) { + if (parent_20.kind === 217 /* TryStatement */) { var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -64731,7 +65451,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 /* BreakStatement */ || node.kind === 209 /* ContinueStatement */) { + if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -64746,16 +65466,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 213 /* SwitchStatement */: - if (statement.kind === 209 /* ContinueStatement */) { + case 214 /* SwitchStatement */: + if (statement.kind === 210 /* ContinueStatement */) { continue; } // Fall through. - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -64774,24 +65494,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 === 221 /* ClassDeclaration */ || - container.kind === 192 /* ClassExpression */ || - (declaration.kind === 142 /* Parameter */ && hasKind(container, 148 /* Constructor */)))) { + if (!(container.kind === 222 /* ClassDeclaration */ || + container.kind === 193 /* ClassExpression */ || + (declaration.kind === 143 /* Parameter */ && hasKind(container, 149 /* Constructor */)))) { return undefined; } } - else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || container.kind === 192 /* ClassExpression */)) { + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || container.kind === 193 /* ClassExpression */)) { return undefined; } } - else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 226 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { return undefined; } } - else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || declaration.kind === 221 /* ClassDeclaration */)) { + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { return undefined; } } @@ -64803,7 +65523,7 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { @@ -64813,17 +65533,17 @@ var ts; nodes = container.statements; } break; - case 148 /* Constructor */: + case 149 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* 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 & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 /* Constructor */ && member; + return member.kind === 149 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -64844,19 +65564,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 112 /* PublicKeyword */: + case 113 /* PublicKeyword */: return 4 /* Public */; - case 110 /* PrivateKeyword */: + case 111 /* PrivateKeyword */: return 8 /* Private */; - case 111 /* ProtectedKeyword */: + case 112 /* ProtectedKeyword */: return 16 /* Protected */; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: return 32 /* Static */; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: return 2 /* Ambient */; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: return 128 /* Abstract */; default: ts.Debug.fail(); @@ -64876,13 +65596,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 123 /* GetKeyword */, 131 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 132 /* SetKeyword */); }); } } } @@ -64891,19 +65611,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { + 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 === 204 /* DoStatement */) { + if (loopNode.kind === 205 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { break; } } @@ -64912,7 +65632,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -64921,13 +65641,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -64935,14 +65655,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); } }); }); @@ -64950,13 +65670,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -64967,13 +65687,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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 (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -64981,36 +65701,36 @@ 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, 199 /* Block */))) { + if (!(func && hasKind(func.body, 200 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 203 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 204 /* 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) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 89 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 203 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -65019,7 +65739,7 @@ var ts; // 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 (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 80 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 81 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -65053,7 +65773,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 215 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -65191,10 +65911,10 @@ var ts; break; } // Fallthrough - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: case 9 /* StringLiteral */: return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); } @@ -65219,7 +65939,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 95 /* SuperKeyword */) { + if (node.kind === 96 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } } @@ -65255,7 +65975,7 @@ var ts; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - var internedName = getInternedName(symbol, node, declarations); + var internedName = getInternedName(symbol, node); for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; cancellationToken.throwIfCancellationRequested(); @@ -65287,12 +66007,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 231 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 232 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 /* ImportSpecifier */ || - declaration.kind === 238 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 /* ImportSpecifier */ || + declaration.kind === 239 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -65300,7 +66020,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 234 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 235 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -65315,20 +66035,20 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 167 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } return undefined; } - function getInternedName(symbol, location, declarations) { + function getInternedName(symbol, location) { // 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 (ts.isImportOrExportSpecifierName(location)) { @@ -65352,14 +66072,14 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 179 /* FunctionExpression */ || valueDeclaration.kind === 192 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 180 /* FunctionExpression */ || valueDeclaration.kind === 193 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class 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, 221 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 222 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -65421,8 +66141,8 @@ var ts; // 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). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4 /* Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -65462,7 +66182,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -65526,14 +66246,14 @@ var ts; var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 121 /* ConstructorKeyword */, parents, inheritsFromCache); + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); if (relatedSymbol) { addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - else if (searchLocation.kind === 121 /* ConstructorKeyword */) { + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); } } @@ -65594,17 +66314,17 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121 /* ConstructorKeyword */); + ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 147 /* MethodDeclaration */) { + if (decl && decl.kind === 148 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -65624,10 +66344,10 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 95 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { result.push(node); } @@ -65665,7 +66385,7 @@ var ts; if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { result.push(getReferenceEntryFromNode(refNode.parent)); } - else if (refNode.kind === 69 /* Identifier */) { + else if (refNode.kind === 70 /* Identifier */) { if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); @@ -65684,7 +66404,7 @@ var ts; maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); } else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199 /* Block */) { + if (parent_21.body.kind === 200 /* Block */) { ts.forEachReturnStatement(parent_21.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); @@ -65736,12 +66456,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ + if (node.kind === 195 /* ExpressionWithTypeArguments */ && node.parent.kind === 251 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 69 /* Identifier */ || node.kind === 172 /* PropertyAccessExpression */) { + else if (node.kind === 70 /* Identifier */ || node.kind === 173 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -65752,14 +66472,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { return isImplementationExpression(node.expression); } - return node.kind === 180 /* ArrowFunction */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 171 /* ObjectLiteralExpression */ || - node.kind === 192 /* ClassExpression */ || - node.kind === 170 /* ArrayLiteralExpression */; + return node.kind === 181 /* ArrowFunction */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 172 /* ObjectLiteralExpression */ || + node.kind === 193 /* ClassExpression */ || + node.kind === 171 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -65808,7 +66528,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -65836,13 +66556,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65855,7 +66575,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* SuperKeyword */) { + if (!node || node.kind !== 96 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -65874,17 +66594,17 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65893,8 +66613,8 @@ var ts; return undefined; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 180 /* 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. @@ -65937,20 +66657,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* 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) { @@ -66060,7 +66780,7 @@ var ts; // 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 === 142 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -66115,7 +66835,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -66199,7 +66919,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -66281,7 +67001,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 218 /* VariableDeclaration */) { + else if (node.kind === 219 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -66291,18 +67011,18 @@ var ts; } else { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 219 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 201 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 220 /* VariableDeclarationList */); return node.parent.parent; } } @@ -66336,17 +67056,17 @@ var ts; FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 69 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 70 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 186 /* PostfixUnaryExpression */ || parent.kind === 185 /* PrefixUnaryExpression */) { + if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 187 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; + return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } } return false; @@ -66366,11 +67086,11 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 140 /* ComputedPropertyName */) { + if (node.parent.kind === 141 /* ComputedPropertyName */) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } // intential fall through - case 69 /* Identifier */: + case 70 /* Identifier */: return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -66379,9 +67099,9 @@ var ts; switch (node.kind) { case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return true; } return false; @@ -66454,9 +67174,9 @@ var ts; // (1) when the aliased symbol was declared in the location(parent). // (2) when the aliased symbol is originating from a named import. // - if (node.kind === 69 /* Identifier */ && + if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 234 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 233 /* NamedImports */))) { + (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -66523,7 +67243,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (ts.isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { + if (ts.isNewExpressionTarget(location) || location.kind === 122 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -66548,8 +67268,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 148 /* Constructor */) || - (!selectConstructors && (d.kind === 220 /* FunctionDeclaration */ || d.kind === 147 /* MethodDeclaration */ || d.kind === 146 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 149 /* Constructor */) || + (!selectConstructors && (d.kind === 221 /* FunctionDeclaration */ || d.kind === 148 /* MethodDeclaration */ || d.kind === 147 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -66634,7 +67354,7 @@ var ts; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; } - else if (node.kind === 95 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 96 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = typeChecker.getSymbolAtLocation(node); @@ -66702,7 +67422,7 @@ var ts; "version" ]; var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + function getJsDocCommentsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter @@ -66752,7 +67472,7 @@ var ts; name: tagName, kind: ts.ScriptElementKind.keyword, kindModifiers: "", - sortText: "0" + sortText: "0", }; })); } @@ -66795,19 +67515,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: - case 221 /* ClassDeclaration */: - case 200 /* VariableStatement */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: + case 222 /* ClassDeclaration */: + case 201 /* VariableStatement */: break findOwner; case 256 /* SourceFile */: return undefined; - case 225 /* ModuleDeclaration */: + case 226 /* 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 === 225 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 226 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -66823,7 +67543,7 @@ var ts; var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 69 /* Identifier */ ? + var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : "param" + i; docParams += indentationStr + " * @param " + paramName + newLine; @@ -66848,7 +67568,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 200 /* VariableStatement */) { + if (commentOwner.kind === 201 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -66866,17 +67586,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 179 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return rightHandSide.parameters; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { return member.parameters; } } @@ -66911,7 +67631,7 @@ var ts; * @param typingOptions are used to customize the typing inference process * @param compilerOptions are used as a source for typing inference */ - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { // A typing name to typing file path mapping var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { @@ -67079,8 +67799,6 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -67121,7 +67839,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 === 231 /* ImportClause */ || decl.kind === 234 /* ImportSpecifier */ || decl.kind === 229 /* ImportEqualsDeclaration */) { + if (decl.kind === 232 /* ImportClause */ || decl.kind === 235 /* ImportSpecifier */ || decl.kind === 230 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -67149,7 +67867,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -67163,7 +67881,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 140 /* ComputedPropertyName */) { + else if (declaration.name.kind === 141 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -67184,7 +67902,7 @@ var ts; } return true; } - if (expression.kind === 172 /* PropertyAccessExpression */) { + if (expression.kind === 173 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -67197,7 +67915,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -67230,8 +67948,8 @@ var ts; // We first sort case insensitively. So "Aaa" will come before "bar". // Then we sort case sensitively, so "aaa" will come before "Aaa". return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem) { var declaration = rawItem.declaration; @@ -67350,7 +68068,7 @@ var ts; return; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -67362,21 +68080,21 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 147 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -67388,7 +68106,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -67399,8 +68117,8 @@ var ts; } } break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var decl = node; var name_50 = decl.name; if (ts.isBindingPattern(name_50)) { @@ -67414,12 +68132,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -67429,9 +68147,9 @@ var ts; } endNode(); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -67439,15 +68157,15 @@ var ts; } endNode(); break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 238 /* ExportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 153 /* IndexSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 223 /* TypeAliasDeclaration */: + case 239 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 154 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 224 /* TypeAliasDeclaration */: addLeafNode(node); break; default: @@ -67504,14 +68222,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 !== 225 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 226 /* 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 !== 225 /* ModuleDeclaration */) { + if (a.body.kind !== 226 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -67546,11 +68264,9 @@ var ts; return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { // This isn't perfect, but it passes all of our tests. for (var i = 0; i < Math.min(a.length, b.length); i++) { var chA = a.charAt(i), chB = b.charAt(i); @@ -67560,7 +68276,7 @@ var ts; if (chA === "'" && chB === "\"") { return -1; } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } @@ -67573,7 +68289,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -67581,9 +68297,9 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: return getFunctionOrClassName(node); case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67592,7 +68308,7 @@ var ts; } } function getItemName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -67608,22 +68324,22 @@ var ts; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } return getFunctionOrClassName(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return "constructor"; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return "new()"; - case 151 /* CallSignature */: + case 152 /* CallSignature */: return "()"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "[]"; case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67637,10 +68353,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { return nameIdentifier.text; } } @@ -67666,24 +68382,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: case 279 /* JSDocTypedefTag */: return true; - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 218 /* VariableDeclaration */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 219 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -67693,10 +68409,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -67705,7 +68421,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 218 /* VariableDeclaration */ && childKind !== 169 /* BindingElement */; + return childKind !== 219 /* VariableDeclaration */ && childKind !== 170 /* BindingElement */; }); } } @@ -67763,7 +68479,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 === 225 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -67774,10 +68490,10 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 225 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 226 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 140 /* ComputedPropertyName */; + return !member.name || member.name.kind === 141 /* ComputedPropertyName */; } function getNodeSpan(node) { return node.kind === 256 /* SourceFile */ @@ -67788,11 +68504,11 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 218 /* VariableDeclaration */) { + else if (node.parent.kind === 219 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 187 /* BinaryExpression */ && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + else if (node.parent.kind === 188 /* BinaryExpression */ && + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left); } else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { @@ -67806,7 +68522,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */ || node.kind === 192 /* ClassExpression */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -67882,7 +68598,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -67894,26 +68610,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + 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_22.kind === 204 /* DoStatement */ || - parent_22.kind === 207 /* ForInStatement */ || - parent_22.kind === 208 /* ForOfStatement */ || - parent_22.kind === 206 /* ForStatement */ || - parent_22.kind === 203 /* IfStatement */ || - parent_22.kind === 205 /* WhileStatement */ || - parent_22.kind === 212 /* WithStatement */ || + if (parent_22.kind === 205 /* DoStatement */ || + parent_22.kind === 208 /* ForInStatement */ || + parent_22.kind === 209 /* ForOfStatement */ || + parent_22.kind === 207 /* ForStatement */ || + parent_22.kind === 204 /* IfStatement */ || + parent_22.kind === 206 /* WhileStatement */ || + parent_22.kind === 213 /* WithStatement */ || parent_22.kind === 252 /* CatchClause */) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 216 /* TryStatement */) { + if (parent_22.kind === 217 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_22; if (tryStatement.tryBlock === n) { @@ -67921,7 +68637,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -67940,25 +68656,25 @@ var ts; break; } // Fallthrough. - case 226 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 227 /* 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 227 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 228 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 170 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 171 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -68313,7 +69029,7 @@ var ts; if (ch >= 65 /* A */ && ch <= 90 /* Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68326,7 +69042,7 @@ var ts; if (ch >= 97 /* a */ && ch <= 122 /* z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68547,10 +69263,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { braceNesting++; } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { braceNesting--; } return token; @@ -68601,10 +69317,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 122 /* DeclareKeyword */) { + if (token === 123 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 125 /* ModuleKeyword */) { + if (token === 126 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -68619,7 +69335,7 @@ var ts; */ function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 89 /* ImportKeyword */) { + if (token === 90 /* ImportKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import "mod"; @@ -68627,9 +69343,9 @@ var ts; return true; } else { - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -68637,12 +69353,12 @@ var ts; return true; } } - else if (token === 56 /* EqualsToken */) { + else if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 24 /* CommaToken */) { + else if (token === 25 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -68651,16 +69367,16 @@ var ts; return true; } } - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -68670,13 +69386,13 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 116 /* AsKeyword */) { + if (token === 117 /* AsKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -68694,19 +69410,19 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 82 /* ExportKeyword */) { + if (token === 83 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -68716,9 +69432,9 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -68726,11 +69442,11 @@ var ts; } } } - else if (token === 89 /* ImportKeyword */) { + else if (token === 90 /* ImportKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 56 /* EqualsToken */) { + if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -68743,9 +69459,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129 /* RequireKeyword */) { + if (token === 130 /* RequireKeyword */) { token = nextToken(); - if (token === 17 /* OpenParenToken */) { + if (token === 18 /* OpenParenToken */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // require("mod"); @@ -68758,16 +69474,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 69 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 70 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 17 /* OpenParenToken */) { + if (token !== 18 /* OpenParenToken */) { return true; } token = nextToken(); if (token === 9 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 24 /* CommaToken */) { + if (token === 25 /* CommaToken */) { token = nextToken(); } else { @@ -68776,14 +69492,14 @@ var ts; } } // should be start of dependency list - if (token !== 19 /* OpenBracketToken */) { + if (token !== 20 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); var i = 0; // scan until ']' or EOF - while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 21 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); @@ -68873,7 +69589,7 @@ var ts; var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node)) { @@ -69134,15 +69850,15 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 175 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 69 /* Identifier */ + var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 172 /* PropertyAccessExpression */ + : expression.kind === 173 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -69175,7 +69891,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 /* CallExpression */ || node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 175 /* CallExpression */ || node.parent.kind === 176 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -69191,8 +69907,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 25 /* LessThanToken */ || - node.kind === 17 /* OpenParenToken */) { + if (node.kind === 26 /* LessThanToken */ || + node.kind === 18 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -69229,27 +69945,27 @@ var ts; } return undefined; } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 177 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 197 /* TemplateSpan */ && node.parent.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 198 /* TemplateSpan */ && node.parent.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -69277,7 +69993,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 24 /* CommaToken */) { + if (child.kind !== 25 /* CommaToken */) { argumentIndex++; } } @@ -69296,8 +70012,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -69327,7 +70043,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 12 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -69365,7 +70081,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -69435,10 +70151,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(28 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -69449,10 +70165,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -69462,7 +70178,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -69516,7 +70232,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -69547,7 +70263,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 97 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 98 /* ThisKeyword */ && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } if (flags & 3 /* Variable */) { @@ -69611,7 +70327,7 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 /* ThisKeyword */ && ts.isExpression(location); + var isThisExpression = location.kind === 98 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { @@ -69622,7 +70338,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 172 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 173 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -69631,7 +70347,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression = void 0; - if (location.kind === 174 /* CallExpression */ || location.kind === 175 /* NewExpression */) { + if (location.kind === 175 /* CallExpression */ || location.kind === 176 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -69644,7 +70360,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 175 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 176 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -69662,7 +70378,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -69678,10 +70394,10 @@ var ts; case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 2097152 /* Anonymous */) && type.symbol) { @@ -69697,24 +70413,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 148 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 149 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 149 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 148 /* Constructor */) { + if (functionDeclaration.kind === 149 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -69723,7 +70439,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -69731,7 +70447,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(74 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -69739,49 +70455,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(108 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(75 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(82 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 127 /* NamespaceKeyword */ : 126 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90 /* InKeyword */)); + displayParts.push(ts.keywordPart(91 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -69790,17 +70506,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + if (declaration.kind === 153 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 151 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 152 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -69809,7 +70525,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -69824,7 +70540,7 @@ var ts; var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -69832,33 +70548,33 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228 /* NamespaceExportDeclaration */) { - displayParts.push(ts.keywordPart(82 /* ExportKeyword */)); + if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(127 /* NamespaceKeyword */)); } else { - displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229 /* ImportEqualsDeclaration */) { + if (declaration.kind === 230 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(130 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -69872,7 +70588,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(98 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -69882,7 +70598,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -69919,7 +70635,7 @@ var ts; if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 188 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -69962,9 +70678,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); return; } } @@ -69972,12 +70688,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(35 /* PlusToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(36 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -69995,16 +70711,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 179 /* FunctionExpression */) { + if (declaration.kind === 180 /* FunctionExpression */) { return true; } - if (declaration.kind !== 218 /* VariableDeclaration */ && declaration.kind !== 220 /* FunctionDeclaration */) { + if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 226 /* ModuleBlock */) { + if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { return false; } } @@ -70065,8 +70781,8 @@ var ts; var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); sourceMapText = text; @@ -70082,9 +70798,9 @@ var ts; getCurrentDirectory: function () { return ""; }, getNewLine: function () { return newLine; }, fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } }; var program = ts.createProgram([inputFileName], options, compilerHost); if (transpileOptions.reportDiagnostics) { @@ -70146,8 +70862,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); /** * Scanner that is currently used for formatting */ @@ -70162,7 +70878,7 @@ var ts; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -70187,7 +70903,7 @@ var ts; } }; function advance() { - ts.Debug.assert(scanner !== undefined); + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -70229,11 +70945,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 29 /* GreaterThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanToken */: return true; } } @@ -70243,26 +70959,26 @@ var ts; if (node.parent) { switch (node.parent.kind) { case 246 /* JsxAttribute */: - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: case 245 /* JsxClosingElement */: - case 242 /* JsxSelfClosingElement */: - return node.kind === 69 /* Identifier */; + case 243 /* JsxSelfClosingElement */: + return node.kind === 70 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 244 /* JsxText */; + return node && node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 10 /* RegularExpressionLiteral */; + return container.kind === 11 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 13 /* TemplateMiddle */ || - container.kind === 14 /* TemplateTail */; + return container.kind === 14 /* TemplateMiddle */ || + container.kind === 15 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; + return t === 40 /* SlashToken */ || t === 62 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -70303,7 +71019,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 28 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -70313,11 +71029,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 17 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 70 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -70460,8 +71176,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 16 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -70649,125 +71365,125 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + 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(16 /* 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.Any), 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(16 /* CloseBraceToken */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 20 /* CloseBracketToken */, 24 /* CommaToken */, 23 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + 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 */)); // No space for dot - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + 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 */)); // No space before and after indexer - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */, 82 /* ExportKeyword */, 89 /* ImportKeyword */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 3 /* MultiLineCommentTrivia */, 74 /* ClassKeyword */, 83 /* ExportKeyword */, 90 /* ImportKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 79 /* DoKeyword */, 100 /* TryKeyword */, 85 /* FinallyKeyword */, 80 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + 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(15 /* 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, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* 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, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + 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.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(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([102 /* VarKeyword */, 98 /* ThrowKeyword */, 92 /* NewKeyword */, 78 /* DeleteKeyword */, 94 /* ReturnKeyword */, 101 /* TypeOfKeyword */, 119 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([108 /* LetKeyword */, 74 /* 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, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(87 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* 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(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* PlusPlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* MinusMinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103 /* VarKeyword */, 99 /* ThrowKeyword */, 93 /* NewKeyword */, 79 /* DeleteKeyword */, 95 /* ReturnKeyword */, 102 /* TypeOfKeyword */, 120 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + 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.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 */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 80 /* DoKeyword */, 81 /* ElseKeyword */, 72 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 131 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 132 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. 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 /* Space */)); 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.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + 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([125 /* ModuleKeyword */, 129 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126 /* ModuleKeyword */, 130 /* 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([115 /* AbstractKeyword */, 73 /* ClassKeyword */, 122 /* DeclareKeyword */, 77 /* DefaultKeyword */, 81 /* EnumKeyword */, 82 /* ExportKeyword */, 83 /* ExtendsKeyword */, 123 /* GetKeyword */, 106 /* ImplementsKeyword */, 89 /* ImportKeyword */, 107 /* InterfaceKeyword */, 125 /* ModuleKeyword */, 126 /* NamespaceKeyword */, 110 /* PrivateKeyword */, 112 /* PublicKeyword */, 111 /* ProtectedKeyword */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */, 136 /* FromKeyword */]), 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([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */, 136 /* FromKeyword */])), 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 */, 126 /* ModuleKeyword */, 127 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 132 /* SetKeyword */, 114 /* StaticKeyword */, 135 /* TypeKeyword */, 137 /* FromKeyword */]), 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 */, 137 /* 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 */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([18 /* CloseParenToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23 /* DotDotDotToken */, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics and type assertions - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* CloseParenToken */, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([18 /* OpenParenToken */, 20 /* OpenBracketToken */, 28 /* GreaterThanToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([115 /* AbstractKeyword */, 69 /* Identifier */, 82 /* ExportKeyword */, 77 /* DefaultKeyword */, 73 /* ClassKeyword */, 113 /* StaticKeyword */, 112 /* PublicKeyword */, 110 /* PrivateKeyword */, 111 /* ProtectedKeyword */, 123 /* GetKeyword */, 131 /* SetKeyword */, 19 /* OpenBracketToken */, 37 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(37 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* YieldKeyword */, 37 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([114 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 132 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* YieldKeyword */, 38 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 88 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70 /* Identifier */, formatting.Shared.TokenRange.FromTokens([12 /* NoSubstitutionTemplateLiteral */, 13 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // jsx opening element - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* SlashToken */, 27 /* 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, 56 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + 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 */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -70829,54 +71545,54 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* OpenParenToken */, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty brackets - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* OpenBracketToken */, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing template string braces - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12 /* TemplateHead */, 13 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13 /* TemplateMiddle */, 14 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(87 /* FunctionKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); // No space after type assertion - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -70891,42 +71607,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 206 /* ForStatement */; + return context.contextNode.kind === 207 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 195 /* AsExpression */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 154 /* TypePredicate */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 196 /* AsExpression */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 155 /* TypePredicate */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 169 /* BindingElement */: + case 170 /* BindingElement */: // equals in type X = ... - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: // equal in p = 0; - case 142 /* Parameter */: + case 143 /* Parameter */: case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 207 /* ForInStatement */: - return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; + case 208 /* ForInStatement */: + 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 208 /* ForOfStatement */: - return context.currentTokenSpan.kind === 138 /* OfKeyword */ || context.nextTokenSpan.kind === 138 /* OfKeyword */; + case 209 /* ForOfStatement */: + return context.currentTokenSpan.kind === 139 /* OfKeyword */ || context.nextTokenSpan.kind === 139 /* OfKeyword */; } return false; }; @@ -70934,7 +71650,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188 /* ConditionalExpression */; + return context.contextNode.kind === 189 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -70978,81 +71694,81 @@ var ts; return true; } switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 171 /* ObjectLiteralExpression */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 172 /* ObjectLiteralExpression */: + case 227 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 151 /* CallSignature */: - case 179 /* FunctionExpression */: - case 148 /* Constructor */: - case 180 /* ArrowFunction */: + case 152 /* CallSignature */: + case 180 /* FunctionExpression */: + case 149 /* Constructor */: + case 181 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 /* FunctionDeclaration */ || context.contextNode.kind === 179 /* FunctionExpression */; + return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 159 /* TypeLiteral */: - case 225 /* ModuleDeclaration */: - case 236 /* ExportDeclaration */: - case 237 /* NamedExports */: - case 230 /* ImportDeclaration */: - case 233 /* NamedImports */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 160 /* TypeLiteral */: + case 226 /* ModuleDeclaration */: + case 237 /* ExportDeclaration */: + case 238 /* NamedExports */: + case 231 /* ImportDeclaration */: + case 234 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 221 /* ClassDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: - case 199 /* Block */: + case 222 /* ClassDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: + case 200 /* Block */: case 252 /* CatchClause */: - case 226 /* ModuleBlock */: - case 213 /* SwitchStatement */: + case 227 /* ModuleBlock */: + case 214 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 203 /* IfStatement */: - case 213 /* SwitchStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 216 /* TryStatement */: - case 204 /* DoStatement */: - case 212 /* WithStatement */: + case 204 /* IfStatement */: + case 214 /* SwitchStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 217 /* TryStatement */: + case 205 /* DoStatement */: + case 213 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: case 252 /* CatchClause */: @@ -71062,31 +71778,31 @@ var ts; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171 /* ObjectLiteralExpression */; + return context.contextNode.kind === 172 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174 /* CallExpression */; + return context.contextNode.kind === 175 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175 /* NewExpression */; + return context.contextNode.kind === 176 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24 /* CommaToken */; + return context.currentTokenSpan.kind !== 25 /* CommaToken */; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180 /* ArrowFunction */; + return context.contextNode.kind === 181 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241 /* JsxElement */; + return context.contextNode.kind !== 242 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { return context.contextNode.kind === 248 /* JsxExpression */; @@ -71098,7 +71814,7 @@ var ts; return context.contextNode.kind === 246 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242 /* JsxSelfClosingElement */; + return context.contextNode.kind === 243 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -71113,41 +71829,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 220 /* 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 === 225 /* ModuleDeclaration */; + return context.contextNode.kind === 226 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 160 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { + if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 155 /* TypeReference */: - case 177 /* TypeAssertionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 194 /* ExpressionWithTypeArguments */: + case 156 /* TypeReference */: + case 178 /* TypeAssertionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 195 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -71158,13 +71874,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177 /* TypeAssertionExpression */; + return context.contextNode.kind === 178 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 183 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 184 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -71188,7 +71904,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 /* LastToken */ + 1; + this.mapRowLength = 139 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); // new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); // new Array(this.map.length); @@ -71202,8 +71918,8 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 /* LastKeyword */ && column <= 139 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; - // Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array."); return rulesBucketIndex; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { @@ -71383,12 +72099,12 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 138 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 139 /* LastToken */; token++) { result.push(token); } return result; }; - TokenAllAccess.prototype.Contains = function (tokenValue) { + TokenAllAccess.prototype.Contains = function () { return true; }; TokenAllAccess.prototype.toString = function () { @@ -71427,17 +72143,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 138 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 138 /* OfKeyword */, 116 /* AsKeyword */, 124 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([41 /* PlusPlusToken */, 42 /* MinusMinusToken */, 50 /* TildeToken */, 49 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 69 /* Identifier */, 17 /* OpenParenToken */, 19 /* OpenBracketToken */, 15 /* OpenBraceToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 17 /* OpenParenToken */, 97 /* ThisKeyword */, 92 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([69 /* Identifier */, 18 /* CloseParenToken */, 20 /* CloseBracketToken */, 92 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 139 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 139 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 130 /* NumberKeyword */, 132 /* StringKeyword */, 120 /* BooleanKeyword */, 133 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 131 /* NumberKeyword */, 133 /* StringKeyword */, 121 /* BooleanKeyword */, 134 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -71628,11 +72344,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 24 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 17 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -71696,15 +72412,15 @@ 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 226 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + return body && body.kind === 227 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); case 256 /* SourceFile */: - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); case 252 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); @@ -71761,7 +72477,7 @@ var ts; index++; } }; - function rangeHasNoErrors(r) { + function rangeHasNoErrors() { return false; } } @@ -71911,20 +72627,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 221 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 222 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 220 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 224 /* EnumDeclaration */: return 224 /* EnumDeclaration */; - case 149 /* GetAccessor */: return 123 /* GetKeyword */; - case 150 /* SetAccessor */: return 131 /* SetKeyword */; - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 223 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 221 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 225 /* EnumDeclaration */: return 225 /* EnumDeclaration */; + case 150 /* GetAccessor */: return 124 /* GetKeyword */; + case 151 /* SetAccessor */: return 132 /* SetKeyword */; + case 148 /* MethodDeclaration */: if (node.asteriskToken) { - return 37 /* AsteriskToken */; + return 38 /* AsteriskToken */; } /* fall-through */ - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: return node.name.kind; } } @@ -71936,9 +72652,9 @@ var ts; // .. { // // comment // } - case 16 /* CloseBraceToken */: - case 20 /* CloseBracketToken */: - case 18 /* CloseParenToken */: + case 17 /* CloseBraceToken */: + case 21 /* CloseBracketToken */: + case 19 /* CloseParenToken */: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; @@ -71952,15 +72668,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 15 /* OpenBraceToken */: - case 16 /* CloseBraceToken */: - case 19 /* OpenBracketToken */: - case 20 /* CloseBracketToken */: - case 17 /* OpenParenToken */: - case 18 /* CloseParenToken */: - case 80 /* ElseKeyword */: - case 104 /* WhileKeyword */: - case 55 /* AtToken */: + 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 @@ -72060,18 +72776,19 @@ var ts; if (!formattingScanner.isOnToken()) { return inheritedIndentation; } - if (ts.isToken(child)) { + // JSX text shouldn't affect indenting + if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 143 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 144 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 170 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 171 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -72416,41 +73133,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 181 /* ArrowFunction */: if (node.typeParameters === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.parameters === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.arguments === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 17 /* OpenParenToken */: - return 18 /* CloseParenToken */; - case 25 /* LessThanToken */: - return 27 /* GreaterThanToken */; + case 18 /* OpenParenToken */: + return 19 /* CloseParenToken */; + case 26 /* LessThanToken */: + return 28 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -72554,7 +73271,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 187 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 188 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -72688,11 +73405,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 15 /* OpenBraceToken */) { + if (nextToken.kind === 16 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 16 /* CloseBraceToken */) { + else if (nextToken.kind === 17 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -72710,8 +73427,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); + if (parent.kind === 204 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -72722,23 +73439,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return node.parent.properties; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return node.parent.elements; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: { + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -72749,8 +73466,8 @@ var ts; } break; } - case 175 /* NewExpression */: - case 174 /* CallExpression */: { + case 176 /* NewExpression */: + case 175 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -72777,11 +73494,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 18 /* CloseParenToken */) { + if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) && + if (node.parent && (node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -72799,10 +73516,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: node = node.expression; break; default: @@ -72818,7 +73535,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24 /* CommaToken */) { + if (list[i].kind === 25 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -72866,48 +73583,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ExpressionStatement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 170 /* ArrayLiteralExpression */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: - case 161 /* TupleType */: - case 227 /* CaseBlock */: + case 203 /* ExpressionStatement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 171 /* ArrayLiteralExpression */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: + case 162 /* TupleType */: + case 228 /* CaseBlock */: case 250 /* DefaultClause */: case 249 /* CaseClause */: - case 178 /* ParenthesizedExpression */: - case 172 /* PropertyAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 200 /* VariableStatement */: - case 218 /* VariableDeclaration */: - case 235 /* ExportAssignment */: - case 211 /* ReturnStatement */: - case 188 /* ConditionalExpression */: - case 168 /* ArrayBindingPattern */: - case 167 /* ObjectBindingPattern */: - case 243 /* JsxOpeningElement */: - case 242 /* JsxSelfClosingElement */: + case 179 /* ParenthesizedExpression */: + case 173 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 201 /* VariableStatement */: + case 219 /* VariableDeclaration */: + case 236 /* ExportAssignment */: + case 212 /* ReturnStatement */: + case 189 /* ConditionalExpression */: + case 169 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 244 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: case 248 /* JsxExpression */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 142 /* Parameter */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 164 /* ParenthesizedType */: - case 176 /* TaggedTemplateExpression */: - case 184 /* AwaitExpression */: - case 237 /* NamedExports */: - case 233 /* NamedImports */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 143 /* Parameter */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 165 /* ParenthesizedType */: + case 177 /* TaggedTemplateExpression */: + case 185 /* AwaitExpression */: + case 238 /* NamedExports */: + case 234 /* NamedImports */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: return true; } return false; @@ -72916,26 +73633,26 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 203 /* IfStatement */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return childKind !== 199 /* Block */; - case 236 /* ExportDeclaration */: - return childKind !== 237 /* NamedExports */; - case 230 /* ImportDeclaration */: - return childKind !== 231 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 233 /* NamedImports */); - case 241 /* JsxElement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 204 /* IfStatement */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return childKind !== 200 /* Block */; + case 237 /* ExportDeclaration */: + return childKind !== 238 /* NamedExports */; + case 231 /* ImportDeclaration */: + return childKind !== 232 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 234 /* NamedImports */); + case 242 /* JsxElement */: return childKind !== 245 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument @@ -73001,7 +73718,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 121 /* ConstructorKeyword */) { + if (token.kind !== 122 /* ConstructorKeyword */) { return undefined; } var newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -73016,7 +73733,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97 /* ThisKeyword */) { + if (token.kind !== 98 /* ThisKeyword */) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -73026,7 +73743,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 174 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 175 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -73050,7 +73767,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -73095,8 +73812,8 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 69 /* Identifier */ ? new IdentifierObject(69 /* Identifier */, pos, end) : + var node = kind >= 140 /* FirstNode */ ? new NodeObject(kind, pos, end) : + kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -73173,7 +73890,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 139 /* FirstNode */) { + if (this.kind >= 140 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; @@ -73235,7 +73952,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 139 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -73243,7 +73960,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 139 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -73282,19 +73999,19 @@ var ts; TokenOrIdentifierObject.prototype.getText = function (sourceFile) { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildCount = function () { return 0; }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { + TokenOrIdentifierObject.prototype.getChildAt = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; return TokenOrIdentifierObject; @@ -73315,7 +74032,7 @@ var ts; }; SymbolObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; }; @@ -73332,12 +74049,12 @@ var ts; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { + function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69 /* Identifier */; + IdentifierObject.prototype.kind = 70 /* Identifier */; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -73398,9 +74115,7 @@ var ts; }; SignatureObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; }; @@ -73448,9 +74163,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -73460,7 +74175,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -73470,10 +74185,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -73493,32 +74208,32 @@ var ts; ts.forEachChild(node, visit); } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 159 /* TypeLiteral */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 160 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 142 /* Parameter */: + case 143 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: { + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -73528,18 +74243,18 @@ var ts; visit(decl.initializer); } case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: addDeclaration(node); break; - case 236 /* ExportDeclaration */: + case 237 /* 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 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -73551,7 +74266,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -73575,7 +74290,7 @@ var ts; getSourceFileConstructor: function () { return SourceFileObject; }, getSymbolConstructor: function () { return SymbolObject; }, getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } + getSignatureConstructor: function () { return SignatureObject; }, }; } function toEditorSettings(optionsAsMap) { @@ -73674,7 +74389,7 @@ var ts; }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { + this.fileNameToEntry.forEachValue(function (_path, value) { if (value) { fileNames.push(value.hostFileName); } @@ -73706,7 +74421,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -73884,7 +74599,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, + writeFile: function () { }, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality @@ -74080,12 +74795,12 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 95 /* SuperKeyword */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -74219,7 +74934,7 @@ var ts; function getSourceFile(fileName) { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location var node = ts.getTouchingPropertyName(sourceFile, startPos); @@ -74227,16 +74942,16 @@ var ts; return; } switch (node.kind) { - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: case 9 /* StringLiteral */: - case 84 /* FalseKeyword */: - case 99 /* TrueKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 69 /* Identifier */: + case 85 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 70 /* Identifier */: break; // Cant create the text span default: @@ -74252,7 +74967,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 === 225 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 226 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -74343,14 +75058,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; - case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; - case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; - case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; - case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; - case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; - case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; - case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; + case 16 /* OpenBraceToken */: return 17 /* CloseBraceToken */; + case 18 /* OpenParenToken */: return 19 /* CloseParenToken */; + case 20 /* OpenBracketToken */: return 21 /* CloseBracketToken */; + case 26 /* LessThanToken */: return 28 /* GreaterThanToken */; + case 17 /* CloseBraceToken */: return 16 /* OpenBraceToken */; + case 19 /* CloseParenToken */: return 18 /* OpenParenToken */; + case 21 /* CloseBracketToken */: return 20 /* OpenBracketToken */; + case 28 /* GreaterThanToken */: return 26 /* LessThanToken */; } return undefined; } @@ -74626,7 +75341,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9 /* StringLiteral */: @@ -74636,7 +75351,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 === 240 /* ExternalModuleReference */ || + node.parent.kind === 241 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -74656,7 +75371,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 173 /* ElementAccessExpression */ && + node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -74740,143 +75455,143 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218 /* VariableDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return spanInVariableDeclaration(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return spanInParameterDeclaration(node); - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return spanInBlock(node); case 252 /* CatchClause */: return spanInBlock(node.block); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 203 /* IfStatement */: + case 204 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return spanInForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); case 249 /* CaseClause */: case 250 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 216 /* TryStatement */: + case 217 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: // span on complete node return textSpan(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 143 /* Decorator */: + case 144 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return spanInPreviousNode(node); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 20 /* CloseBracketToken */: + case 21 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return spanInOpenParenToken(node); - case 18 /* CloseParenToken */: + case 19 /* CloseParenToken */: return spanInCloseParenToken(node); - case 54 /* ColonToken */: + case 55 /* ColonToken */: return spanInColonToken(node); - case 27 /* GreaterThanToken */: - case 25 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 26 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return spanInWhileKeyword(node); - case 80 /* ElseKeyword */: - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 81 /* ElseKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 138 /* OfKeyword */: + case 139 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -74888,14 +75603,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern - if ((node.kind === 69 /* Identifier */ || - node.kind == 191 /* SpreadElementExpression */ || + if ((node.kind === 70 /* Identifier */ || + node.kind == 192 /* SpreadElementExpression */ || node.kind === 253 /* PropertyAssignment */ || node.kind === 254 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 187 /* BinaryExpression */) { + if (node.kind === 188 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -74904,7 +75619,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 56 /* EqualsToken */ && + if (binaryExpression.operatorToken.kind === 57 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of @@ -74912,28 +75627,28 @@ var ts; // { a = expression, b, c } = someExpression return textSpan(node); } - if (binaryExpression.operatorToken.kind === 24 /* CommaToken */) { + if (binaryExpression.operatorToken.kind === 25 /* CommaToken */) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 143 /* Decorator */: + case 144 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: return textSpan(node); - case 187 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 24 /* CommaToken */) { + case 188 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -74948,7 +75663,7 @@ var ts; return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 177 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 178 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -74956,8 +75671,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 218 /* VariableDeclaration */ || - node.parent.kind === 142 /* Parameter */)) { + if ((node.parent.kind === 219 /* VariableDeclaration */ || + node.parent.kind === 143 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -74965,7 +75680,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 187 /* BinaryExpression */) { + if (node.parent.kind === 188 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -74991,7 +75706,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 207 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 208 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -75002,7 +75717,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 208 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 209 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -75042,7 +75757,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 221 /* ClassDeclaration */ && functionDeclaration.kind !== 148 /* Constructor */); + (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -75065,25 +75780,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 205 /* WhileStatement */: - case 203 /* IfStatement */: - case 207 /* ForInStatement */: + case 206 /* WhileStatement */: + case 204 /* IfStatement */: + case 208 /* 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 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* 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 === 219 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 220 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -75108,23 +75823,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 169 /* BindingElement */) { + if (bindingPattern.parent.kind === 170 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 /* ArrayBindingPattern */ && node.kind !== 167 /* ObjectBindingPattern */); - var elements = node.kind === 170 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 169 /* ArrayBindingPattern */ && node.kind !== 168 /* ObjectBindingPattern */); + var elements = node.kind === 171 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -75132,18 +75847,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 187 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 188 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -75151,16 +75866,16 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 224 /* EnumDeclaration */: - case 221 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); @@ -75168,7 +75883,7 @@ var ts; // fall through case 252 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -75176,7 +75891,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75192,7 +75907,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75207,12 +75922,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 204 /* DoStatement */ || - node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 205 /* DoStatement */ || + node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 178 /* ParenthesizedExpression */) { + if (node.parent.kind === 179 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -75221,21 +75936,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 178 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 179 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -75246,19 +75961,19 @@ var ts; // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || node.parent.kind === 253 /* PropertyAssignment */ || - node.parent.kind === 142 /* Parameter */) { + node.parent.kind === 143 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177 /* TypeAssertionExpression */) { + if (node.parent.kind === 178 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 204 /* DoStatement */) { + if (node.parent.kind === 205 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -75266,7 +75981,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.kind === 209 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -75445,7 +76160,7 @@ var ts; return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { @@ -75494,7 +76209,7 @@ var ts; // Wrap the API changes for 2.0 release. This try/catch // should be removed once TypeScript 2.0 has shipped. try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); } catch (e) { @@ -75568,7 +76283,7 @@ var ts; this.factory = factory; factory.registerShim(this); } - ShimBase.prototype.dispose = function (dummy) { + ShimBase.prototype.dispose = function (_dummy) { this.factory.unregisterShim(this); }; return ShimBase; @@ -75991,7 +76706,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false); return this.forwardJSONCall("discoverTypings()", function () { var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); }); }; return CoreServicesShimObject; @@ -76080,3 +76795,5 @@ var TypeScript; /* @internal */ var toolsVersion = "2.1"; /* tslint:enable:no-unused-variable */ + +//# sourceMappingURL=typescriptServices.js.map diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 577a8ee4fc94f..147b38fde197d 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -20,6 +20,418 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +444,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -46,6 +490,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -63,10 +667,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -77,7 +938,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -129,7 +990,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -150,7 +1018,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -192,6 +1060,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -335,13 +1209,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -442,6 +1335,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -454,8 +1359,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -488,8 +1393,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -708,8 +1613,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -810,7 +1715,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -841,7 +1746,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -866,11 +1771,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -933,7 +1838,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1086,7 +1991,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1383,7 +2288,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1398,7 +2303,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1508,6 +2413,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1571,10 +2484,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1596,6 +2509,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1908,7 +2828,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1980,6 +2900,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2121,7 +3046,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2137,9 +3062,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2927,7 +3852,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2964,139 +3889,139 @@ var ts; 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" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 69; + return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "abstract": 115, - "any": 117, - "as": 116, - "boolean": 120, - "break": 70, - "case": 71, - "catch": 72, - "class": 73, - "continue": 75, - "const": 74, - "constructor": 121, - "debugger": 76, - "declare": 122, - "default": 77, - "delete": 78, - "do": 79, - "else": 80, - "enum": 81, - "export": 82, - "extends": 83, - "false": 84, - "finally": 85, - "for": 86, - "from": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 44, - ">>>": 45, - "&": 46, - "|": 47, - "^": 48, - "!": 49, - "~": 50, - "&&": 51, - "||": 52, - "?": 53, - ":": 54, - "=": 56, - "+=": 57, - "-=": 58, - "*=": 59, - "**=": 60, - "/=": 61, - "%=": 62, - "<<=": 63, - ">>=": 64, - ">>>=": 65, - "&=": 66, - "|=": 67, - "^=": 68, - "@": 55 + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, }); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -3493,7 +4418,7 @@ var ts; return iterateCommentRanges(true, text, pos, true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -3559,8 +4484,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3579,7 +4504,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -3696,20 +4621,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; + resultingToken = startedWithBacktick ? 13 : 14; break; } if (currChar === 92) { @@ -3871,7 +4796,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69; + return token = 70; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -3946,12 +4871,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } pos++; - return token = 49; + return token = 50; case 34: case 39: tokenValue = scanString(); @@ -3960,68 +4885,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 67; } pos++; - return token = 46; + return token = 47; case 40: pos++; - return token = 17; + return token = 18; case 41: pos++; - return token = 18; + return token = 19; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 38; + return pos += 2, token = 39; } pos++; - return token = 37; + return token = 38; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; + return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } pos++; - return token = 35; + return token = 36; case 44: pos++; - return token = 24; + return token = 25; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } pos++; - return token = 36; + return token = 37; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; + return pos += 3, token = 23; } pos++; - return token = 21; + return token = 22; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -4065,10 +4990,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } pos++; - return token = 39; + return token = 40; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -4117,10 +5042,10 @@ var ts; return token = 8; case 58: pos++; - return token = 54; + return token = 55; case 59: pos++; - return token = 23; + return token = 24; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4133,20 +5058,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 64; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; + return pos += 2, token = 29; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; + return pos += 2, token = 27; } pos++; - return token = 25; + return token = 26; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4159,15 +5084,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; + return pos += 2, token = 35; } pos++; - return token = 56; + return token = 57; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4179,43 +5104,43 @@ var ts; } } pos++; - return token = 27; + return token = 28; case 63: pos++; - return token = 53; + return token = 54; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; + return pos += 2, token = 69; } pos++; - return token = 48; + return token = 49; case 123: pos++; - return token = 15; + return token = 16; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; + return pos += 2, token = 53; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; + return pos += 2, token = 68; } pos++; - return token = 47; + return token = 48; case 125: pos++; - return token = 16; + return token = 17; case 126: pos++; - return token = 50; + return token = 51; case 64: pos++; - return token = 55; + return token = 56; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -4253,29 +5178,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27) { + if (token === 28) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; + return pos += 3, token = 66; } - return pos += 2, token = 45; + return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } pos++; - return token = 44; + return token = 45; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 29; + return token = 30; } } return token; } function reScanSlashToken() { - if (token === 39 || token === 61) { + if (token === 40 || token === 62) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -4314,12 +5239,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10; + token = 11; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -4336,14 +5261,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 26; + return token = 27; } pos++; - return token = 25; + return token = 26; } if (char === 123) { pos++; - return token = 15; + return token = 16; } while (pos < end) { pos++; @@ -4352,7 +5277,7 @@ var ts; break; } } - return token = 244; + return token = 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -4399,39 +5324,39 @@ var ts; return token = 5; case 64: pos++; - return token = 55; + return token = 56; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 37; + return token = 38; case 123: pos++; - return token = 15; + return token = 16; case 125: pos++; - return token = 16; + return token = 17; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 61: pos++; - return token = 56; + return token = 57; case 44: pos++; - return token = 24; + return token = 25; } - if (isIdentifierStart(ch, 2)) { + if (isIdentifierStart(ch, 4)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { pos++; } - return token = 69; + return token = 70; } else { return pos += 1, token = 0; @@ -4521,24 +5446,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -4553,7 +5478,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -4563,15 +5488,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -4580,7 +5505,7 @@ var ts; "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -4589,18 +5514,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -4611,11 +5536,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -4624,12 +5549,12 @@ var ts; "lf": 1 }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -4638,7 +5563,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -4647,59 +5572,59 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -4722,30 +5647,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -4756,7 +5681,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -4771,22 +5696,24 @@ var ts; "es3": 0, "es5": 1, "es6": 2, - "es2015": 2 + "es2015": 2, + "es2016": 3, + "es2017": 4, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -4803,10 +5730,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -4929,7 +5856,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -4956,7 +5883,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -4979,7 +5906,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; function getOptionNameMap() { @@ -4999,10 +5926,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -5608,7 +6532,7 @@ var ts; ; var safeList; var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -5743,7 +6667,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -6342,10 +7266,9 @@ var ts; typingsInstaller.NpmViewRequest = "npm view"; typingsInstaller.NpmInstallRequest = "npm install"; var TypingsInstaller = (function () { - function TypingsInstaller(globalCachePath, npmPath, safeListPath, throttleLimit, log) { + function TypingsInstaller(globalCachePath, safeListPath, throttleLimit, log) { if (log === void 0) { log = nullLog; } this.globalCachePath = globalCachePath; - this.npmPath = npmPath; this.safeListPath = safeListPath; this.throttleLimit = throttleLimit; this.log = log; @@ -6396,7 +7319,7 @@ var ts; } this.processCacheLocation(req.cachePath); } - var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, req.fileNames, req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, req.typingOptions, req.compilerOptions); + var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, req.fileNames, req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, req.typingOptions); if (this.log.isEnabled()) { this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult)); } @@ -6567,12 +7490,11 @@ var ts; var filteredTypings = []; for (var _i = 0, typingsToInstall_3 = typingsToInstall; _i < typingsToInstall_3.length; _i++) { var typing = typingsToInstall_3[_i]; - execNpmViewTyping(this, typing); + filterExistingTypings(this, typing); } - function execNpmViewTyping(self, typing) { - var command = self.npmPath + " view @types/" + typing + " --silent name"; - self.execAsync(typingsInstaller.NpmViewRequest, requestId, command, cachePath, function (err, stdout, stderr) { - if (stdout) { + function filterExistingTypings(self, typing) { + self.execAsync(typingsInstaller.NpmViewRequest, requestId, [typing], cachePath, function (ok) { + if (ok) { filteredTypings.push(typing); } execInstallCmdCount++; @@ -6587,9 +7509,8 @@ var ts; return; } var scopedTypings = filteredTypings.map(function (t) { return "@types/" + t; }); - var command = self.npmPath + " install " + scopedTypings.join(" ") + " --save-dev"; - self.execAsync(typingsInstaller.NpmInstallRequest, requestId, command, cachePath, function (err, stdout, stderr) { - postInstallAction(stdout ? scopedTypings : []); + self.execAsync(typingsInstaller.NpmInstallRequest, requestId, scopedTypings, cachePath, function (ok) { + postInstallAction(ok ? scopedTypings : []); }); } }; @@ -6632,8 +7553,8 @@ var ts; kind: "set" }; }; - TypingsInstaller.prototype.execAsync = function (requestKind, requestId, command, cwd, onRequestCompleted) { - this.pendingRunRequests.unshift({ requestKind: requestKind, requestId: requestId, command: command, cwd: cwd, onRequestCompleted: onRequestCompleted }); + TypingsInstaller.prototype.execAsync = function (requestKind, requestId, args, cwd, onRequestCompleted) { + this.pendingRunRequests.unshift({ requestKind: requestKind, requestId: requestId, args: args, cwd: cwd, onRequestCompleted: onRequestCompleted }); this.executeWithThrottling(); }; TypingsInstaller.prototype.executeWithThrottling = function () { @@ -6641,9 +7562,9 @@ var ts; var _loop_1 = function () { this_1.inFlightRequestCount++; var request = this_1.pendingRunRequests.pop(); - this_1.runCommand(request.requestKind, request.requestId, request.command, request.cwd, function (err, stdout, stderr) { + this_1.executeRequest(request.requestKind, request.requestId, request.args, request.cwd, function (ok) { _this.inFlightRequestCount--; - request.onRequestCompleted(err, stdout, stderr); + request.onRequestCompleted(ok); _this.executeWithThrottling(); }); }; @@ -6689,13 +7610,14 @@ var ts; var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); function NodeTypingsInstaller(globalTypingsCacheLocation, throttleLimit, log) { - var _this = _super.call(this, globalTypingsCacheLocation, getNPMLocation(process.argv[0]), ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; + var _this = _super.call(this, globalTypingsCacheLocation, ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; _this.installTypingHost = ts.sys; if (_this.log.isEnabled()) { _this.log.writeLine("Process id: " + process.pid); } - var exec = require("child_process").exec; - _this.exec = exec; + _this.npmPath = getNPMLocation(process.argv[0]); + _this.exec = require("child_process").exec; + _this.httpGet = require("http").get; return _this; } NodeTypingsInstaller.prototype.init = function () { @@ -6720,18 +7642,54 @@ var ts; this.log.writeLine("Response has been sent."); } }; - NodeTypingsInstaller.prototype.runCommand = function (requestKind, requestId, command, cwd, onRequestCompleted) { + NodeTypingsInstaller.prototype.executeRequest = function (requestKind, requestId, args, cwd, onRequestCompleted) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("#" + requestId + " running command '" + command + "'."); + this.log.writeLine("#" + requestId + " executing " + requestKind + ", arguments'" + JSON.stringify(args) + "'."); + } + switch (requestKind) { + case typingsInstaller.NpmViewRequest: + { + ts.Debug.assert(args.length === 1); + var url_1 = "http://registry.npmjs.org/@types%2f" + args[0]; + var start_2 = Date.now(); + this.httpGet(url_1, function (response) { + var ok = false; + if (_this.log.isEnabled()) { + _this.log.writeLine(requestKind + " #" + requestId + " request to " + url_1 + ":: status code " + response.statusCode + ", status message '" + response.statusMessage + "', took " + (Date.now() - start_2) + " ms"); + } + switch (response.statusCode) { + case 200: + case 301: + case 302: + ok = true; + break; + } + response.destroy(); + onRequestCompleted(ok); + }).on("error", function (err) { + if (_this.log.isEnabled()) { + _this.log.writeLine(requestKind + " #" + requestId + " query to npm registry failed with error " + err.message + ", stack " + err.stack); + } + onRequestCompleted(false); + }); + } + break; + case typingsInstaller.NpmInstallRequest: + { + var command = this.npmPath + " install " + args.join(" ") + " --save-dev"; + var start_3 = Date.now(); + this.exec(command, { cwd: cwd }, function (_err, stdout, stderr) { + if (_this.log.isEnabled()) { + _this.log.writeLine(requestKind + " #" + requestId + " took: " + (Date.now() - start_3) + " ms" + ts.sys.newLine + "stdout: " + stdout + ts.sys.newLine + "stderr: " + stderr); + } + onRequestCompleted(!!stdout); + }); + } + break; + default: + ts.Debug.assert(false, "Unknown request kind " + requestKind); } - this.exec(command, { cwd: cwd }, function (err, stdout, stderr) { - if (_this.log.isEnabled()) { - _this.log.writeLine(requestKind + " #" + requestId + " stdout: " + stdout); - _this.log.writeLine(requestKind + " #" + requestId + " stderr: " + stderr); - } - onRequestCompleted(err, stdout, stderr); - }); }; return NodeTypingsInstaller; }(typingsInstaller.TypingsInstaller)); @@ -6761,3 +7719,5 @@ var ts; })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); + +//# sourceMappingURL=typingsInstaller.js.map diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index af10f355e1f17..e9fa5d6be2e80 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -47,19 +47,6 @@ namespace FourSlash { ranges: Range[]; } - interface MemberListData { - result: { - maybeInaccurate: boolean; - isMemberCompletion: boolean; - entries: { - name: string; - type: string; - kind: string; - kindModifiers: string; - }[]; - }; - } - export interface Marker { fileName: string; position: number; @@ -178,15 +165,9 @@ namespace FourSlash { // Return object may lack some functionalities for other purposes. function createScriptSnapShot(sourceText: string): ts.IScriptSnapshot { return { - getText: (start: number, end: number) => { - return sourceText.substr(start, end - start); - }, - getLength: () => { - return sourceText.length; - }, - getChangeRange: (oldSnapshot: ts.IScriptSnapshot) => { - return undefined; - } + getText: (start: number, end: number) => sourceText.substr(start, end - start), + getLength: () => sourceText.length, + getChangeRange: () => undefined }; } @@ -419,9 +400,8 @@ namespace FourSlash { public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) { const startMarker = this.getMarkerByName(startMarkerName); const endMarker = this.getMarkerByName(endMarkerName); - const predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { - return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false; - }; + const predicate = (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => + ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false; const exists = this.anyErrorInRange(predicate, startMarker, endMarker); @@ -471,14 +451,12 @@ namespace FourSlash { let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean; if (after) { - predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { - return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false; - }; + predicate = (errorMinChar: number, errorLimChar: number, startPos: number) => + ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false; } else { - predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { - return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false; - }; + predicate = (errorMinChar: number, errorLimChar: number, startPos: number) => + ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false; } const exists = this.anyErrorInRange(predicate, marker); @@ -1179,7 +1157,7 @@ namespace FourSlash { private alignmentForExtraInfo = 50; - private spanInfoToString(pos: number, spanInfo: ts.TextSpan, prefixString: string) { + private spanInfoToString(spanInfo: ts.TextSpan, prefixString: string) { let resultString = "SpanInfo: " + JSON.stringify(spanInfo); if (spanInfo) { const spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length); @@ -1230,7 +1208,7 @@ namespace FourSlash { startColumn = 0; length = 0; } - const spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString); + const spanInfo = this.spanInfoToString(getSpanAtPos(pos), prefixString); if (previousSpanInfo && previousSpanInfo !== spanInfo) { addSpanInfoString(); previousSpanInfo = spanInfo; @@ -1300,10 +1278,10 @@ namespace FourSlash { } } - emitOutput.outputFiles.forEach((outputFile, idx, array) => { + for (const outputFile of emitOutput.outputFiles) { const fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); resultString = resultString + fileName + outputFile.text; - }); + } resultString += Harness.IO.newLine(); }); @@ -1328,7 +1306,7 @@ namespace FourSlash { } public printBreakpointLocation(pos: number) { - Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(pos, this.getBreakpointStatementLocation(pos), " ")); + Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(this.getBreakpointStatementLocation(pos), " ")); } public printBreakpointAtCurrentLocation() { @@ -1830,7 +1808,7 @@ namespace FourSlash { return result; } - private rangeText({fileName, start, end}: Range, more = false): string { + private rangeText({fileName, start, end}: Range): string { return this.getFileContent(fileName).slice(start, end); } @@ -1925,7 +1903,7 @@ namespace FourSlash { } public printNameOrDottedNameSpans(pos: number) { - Harness.IO.log(this.spanInfoToString(pos, this.getNameOrDottedNameSpan(pos), "**")); + Harness.IO.log(this.spanInfoToString(this.getNameOrDottedNameSpan(pos), "**")); } private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 38cb56d820257..7bfd94637b590 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -220,9 +220,7 @@ namespace Utils { } export function sourceFileToJSON(file: ts.Node): string { - return JSON.stringify(file, (k, v) => { - return isNodeOrArray(v) ? serializeNode(v) : v; - }, " "); + return JSON.stringify(file, (_, v) => isNodeOrArray(v) ? serializeNode(v) : v, " "); function getKindName(k: number | string): string { if (typeof k === "string") { @@ -692,7 +690,7 @@ namespace Harness { export const getCurrentDirectory = () => ""; export const args = () => []; export const getExecutingFilePath = () => ""; - export const exit = (exitCode: number) => { }; + export const exit = () => { }; export const getDirectories = () => []; export let log = (s: string) => console.log(s); @@ -742,7 +740,7 @@ namespace Harness { } } - export function createDirectory(path: string) { + export function createDirectory() { // Do nothing (?) } @@ -750,7 +748,7 @@ namespace Harness { Http.writeToServerSync(serverRoot + path, "DELETE"); } - export function directoryExists(path: string): boolean { + export function directoryExists(): boolean { return false; } @@ -792,7 +790,7 @@ namespace Harness { return response.status === 200; } - export function _listFilesImpl(path: string, spec?: RegExp, options?: any) { + export let listFiles = Utils.memoize((path: string, spec?: RegExp): string[] => { const response = Http.getFileFromServerSync(serverRoot + path); if (response.status === 200) { const results = response.responseText.split(","); @@ -806,8 +804,7 @@ namespace Harness { else { return [""]; } - }; - export let listFiles = Utils.memoize(_listFilesImpl); + }); export function readFile(file: string) { const response = Http.getFileFromServerSync(serverRoot + file); @@ -991,7 +988,7 @@ namespace Harness { } } - function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget) { + function getSourceFile(fileName: string) { fileName = ts.normalizePath(fileName); const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); if (fileMap.contains(path)) { @@ -1051,7 +1048,7 @@ namespace Harness { getDirectories: d => { const path = ts.toPath(d, currentDirectory, getCanonicalFileName); const result: string[] = []; - fileMap.forEachValue((key, value) => { + fileMap.forEachValue(key => { if (key.indexOf(path) === 0 && key.lastIndexOf("/") > path.length) { let dirName = key.substr(path.length, key.indexOf("/", path.length + 1) - path.length); if (dirName[0] === "/") { @@ -1669,7 +1666,7 @@ namespace Harness { } // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed - export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) { + export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' throw new Error("compileString NYI"); } @@ -1853,8 +1850,8 @@ namespace Harness { // unit tests always list files explicitly const parseConfigHost: ts.ParseConfigHost = { useCaseSensitiveFileNames: false, - readDirectory: (name) => [], - fileExists: (name) => true, + readDirectory: () => [], + fileExists: () => true, readFile: (name) => ts.forEach(testUnitData, data => data.name.toLowerCase() === name.toLowerCase() ? data.content : undefined) }; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 7cc4c2044ef16..28b57728e1f7f 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -165,7 +165,7 @@ namespace Harness.LanguageService { throw new Error("No script with name '" + fileName + "'"); } - public openFile(fileName: string, content?: string, scriptKindName?: string): void { + public openFile(_fileName: string, _content?: string, _scriptKindName?: string): void { } /** @@ -198,7 +198,7 @@ namespace Harness.LanguageService { const script = this.getScriptInfo(fileName); return script ? new ScriptSnapshot(script) : undefined; } - getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; } + getScriptKind(): ts.ScriptKind { return ts.ScriptKind.Unknown; } getScriptVersion(fileName: string): string { const script = this.getScriptInfo(fileName); return script ? script.version.toString() : undefined; @@ -214,7 +214,7 @@ namespace Harness.LanguageService { this.getCurrentDirectory(), (p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p)); } - readFile(path: string, encoding?: string): string { + readFile(path: string): string { const snapshot = this.getScriptSnapshot(path); return snapshot.getText(0, snapshot.getLength()); } @@ -223,9 +223,9 @@ namespace Harness.LanguageService { } - log(s: string): void { } - trace(s: string): void { } - error(s: string): void { } + log(_: string): void { } + trace(_: string): void { } + error(_: string): void { } } export class NativeLanguageServiceAdapter implements LanguageServiceAdapter { @@ -308,17 +308,17 @@ namespace Harness.LanguageService { const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName); return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot); } - getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); } + getScriptKind(): ts.ScriptKind { return this.nativeHost.getScriptKind(); } getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); } getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); } - readDirectory(rootDir: string, extension: string): string { + readDirectory(_rootDir: string, _extension: string): string { throw new Error("NYI"); } - readDirectoryNames(path: string): string { + readDirectoryNames(_path: string): string { throw new Error("Not implemented."); } - readFileNames(path: string): string { + readFileNames(_path: string): string { throw new Error("Not implemented."); } fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; } @@ -329,7 +329,7 @@ namespace Harness.LanguageService { log(s: string): void { this.nativeHost.log(s); } trace(s: string): void { this.nativeHost.trace(s); } error(s: string): void { this.nativeHost.error(s); } - directoryExists(directoryName: string): boolean { + directoryExists(): boolean { // for tests pessimistically assume that directory always exists return true; } @@ -338,7 +338,7 @@ namespace Harness.LanguageService { class ClassifierShimProxy implements ts.Classifier { constructor(private shim: ts.ClassifierShim) { } - getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications { + getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications { throw new Error("NYI"); } getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult { @@ -411,7 +411,7 @@ namespace Harness.LanguageService { getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails { return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName)); } - getCompletionEntrySymbol(fileName: string, position: number, entryName: string): ts.Symbol { + getCompletionEntrySymbol(): ts.Symbol { throw new Error("getCompletionEntrySymbol not implemented across the shim layer."); } getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo { @@ -490,7 +490,7 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { + getCodeFixesAtPosition(): ts.CodeAction[] { throw new Error("Not supported on the shim."); } getEmitOutput(fileName: string): ts.EmitOutput { @@ -499,10 +499,10 @@ namespace Harness.LanguageService { getProgram(): ts.Program { throw new Error("Program can not be marshaled across the shim layer."); } - getNonBoundSourceFile(fileName: string): ts.SourceFile { + getNonBoundSourceFile(): ts.SourceFile { throw new Error("SourceFile can not be marshaled across the shim layer."); } - getSourceFile(fileName: string): ts.SourceFile { + getSourceFile(): ts.SourceFile { throw new Error("SourceFile can not be marshaled across the shim layer."); } dispose(): void { this.shim.dispose({}); } @@ -572,11 +572,11 @@ namespace Harness.LanguageService { super(cancellationToken, settings); } - onMessage(message: string): void { + onMessage(): void { } - writeMessage(message: string): void { + writeMessage(): void { } @@ -604,11 +604,11 @@ namespace Harness.LanguageService { this.newLine = this.host.getNewLine(); } - onMessage(message: string): void { + onMessage(): void { } - writeMessage(message: string): void { + writeMessage(_message: string): void { } write(message: string): void { @@ -624,7 +624,7 @@ namespace Harness.LanguageService { return snapshot && snapshot.getText(0, snapshot.getLength()); } - writeFile(name: string, text: string, writeByteOrderMark: boolean): void { + writeFile(): void { } resolvePath(path: string): string { @@ -635,7 +635,7 @@ namespace Harness.LanguageService { return !!this.host.getScriptSnapshot(path); } - directoryExists(path: string): boolean { + directoryExists(): boolean { // for tests assume that directory exists return true; } @@ -644,10 +644,10 @@ namespace Harness.LanguageService { return ""; } - exit(exitCode: number): void { + exit(): void { } - createDirectory(directoryName: string): void { + createDirectory(_directoryName: string): void { throw new Error("Not Implemented Yet."); } @@ -655,7 +655,7 @@ namespace Harness.LanguageService { return this.host.getCurrentDirectory(); } - getDirectories(path: string): string[] { + getDirectories(): string[] { return []; } @@ -663,15 +663,15 @@ namespace Harness.LanguageService { return ts.sys.getEnvironmentVariable(name); } - readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]): string[] { + readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] { throw new Error("Not implemented Yet."); } - watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher { + watchFile(): ts.FileWatcher { return { close() { } }; } - watchDirectory(path: string, callback: (path: string) => void, recursive?: boolean): ts.FileWatcher { + watchDirectory(): ts.FileWatcher { return { close() { } }; } @@ -717,7 +717,7 @@ namespace Harness.LanguageService { clearTimeout(timeoutId); } - setImmediate(callback: (...args: any[]) => void, ms: number, ...args: any[]): any { + setImmediate(callback: (...args: any[]) => void, _ms: number, ...args: any[]): any { return setImmediate(callback, args); } @@ -760,6 +760,6 @@ namespace Harness.LanguageService { getHost() { return this.host; } getLanguageService(): ts.LanguageService { return this.client; } getClassifier(): ts.Classifier { throw new Error("getClassifier is not available using the server interface."); } - getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); } + getPreProcessedFileInfo(): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); } } } diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 07dbf4a4e1c43..eeb47f0cfa03c 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -173,7 +173,7 @@ namespace Playback { path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }), memoize(path => { // If we read from the file, it must exist - if (findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) { + if (findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) { return true; } else { @@ -217,7 +217,7 @@ namespace Playback { recordLog.filesRead.push(logEntry); return result; }, - memoize(path => findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents)); + memoize(path => findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents)); wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)( (path, extensions, exclude, include) => { @@ -226,7 +226,7 @@ namespace Playback { recordLog.directoriesRead.push(logEntry); return result; }, - (path, extensions, exclude) => { + path => { // Because extensions is an array of all allowed extension, we will want to merge each of the replayLog.directoriesRead into one // if each of the directoriesRead has matched path with the given path (directory with same path but different extension will considered // different entry). @@ -244,7 +244,7 @@ namespace Playback { wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( (path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), - (path: string, contents: string) => noOpReplay("writeFile")); + () => noOpReplay("writeFile")); wrapper.exit = (exitCode) => { if (recordLog !== undefined) { @@ -295,7 +295,7 @@ namespace Playback { return results[0].result; } - function findFileByPath(wrapper: { resolvePath(s: string): string }, logArray: IOLogFile[], + function findFileByPath(logArray: IOLogFile[], expectedPath: string, throwFileNotFoundError: boolean): FileInformation { const normalizedName = ts.normalizePath(expectedPath).toLowerCase(); // Try to find the result through normal fileName @@ -314,7 +314,7 @@ namespace Playback { } } - function noOpReplay(name: string) { + function noOpReplay(_name: string) { // console.log("Swallowed write operation during replay: " + name); } @@ -322,13 +322,17 @@ namespace Playback { const wrapper: PlaybackIO = {}; initWrapper(wrapper, underlying); - wrapper.directoryName = (path): string => { throw new Error("NotSupported"); }; - wrapper.createDirectory = (path): void => { throw new Error("NotSupported"); }; - wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); }; - wrapper.deleteFile = (path): void => { throw new Error("NotSupported"); }; - wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); }; + wrapper.directoryName = notSupported; + wrapper.createDirectory = notSupported; + wrapper.directoryExists = notSupported; + wrapper.deleteFile = notSupported; + wrapper.listFiles = notSupported; return wrapper; + + function notSupported(): never { + throw new Error("NotSupported"); + } } export function wrapSystem(underlying: ts.System): PlaybackSystem { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 415c09caff6d9..f7541dc9bfe9e 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -178,7 +178,7 @@ class ProjectRunner extends RunnerBase { function createCompilerHost(): ts.CompilerHost { return { getSourceFile, - getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName, + getDefaultLibFileName: () => Harness.Compiler.defaultLibFileName, writeFile, getCurrentDirectory, getCanonicalFileName: Harness.Compiler.getCanonicalFileName, @@ -421,7 +421,7 @@ class ProjectRunner extends RunnerBase { return undefined; } - function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) { + function writeFile() { } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index d0f500e27aa06..e4099d3014cf0 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node", "mocha", "chai" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../compiler/core.ts", diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 9489feb43e9d4..0a522ddb22ef2 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -21,15 +21,14 @@ namespace ts { args: [], newLine: "\r\n", useCaseSensitiveFileNames: false, - write: (s: string) => { - }, - readFile: (path: string, encoding?: string): string => { + write: () => { }, + readFile: (path: string): string => { return path in fileMap ? fileMap[path].content : undefined; }, - writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => { + writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => { throw new Error("NYI"); }, - resolvePath: (path: string): string => { + resolvePath: (_path: string): string => { throw new Error("NYI"); }, fileExists: (path: string): boolean => { @@ -38,31 +37,25 @@ namespace ts { directoryExists: (path: string): boolean => { return existingDirectories[path] || false; }, - createDirectory: (path: string) => { - }, + createDirectory: () => { }, getExecutingFilePath: (): string => { return ""; }, getCurrentDirectory: (): string => { return ""; }, - getDirectories: (path: string) => [], - getEnvironmentVariable: (name: string) => "", - readDirectory: (path: string, extension?: string[], exclude?: string[], include?: string[]): string[] => { + getDirectories: () => [], + getEnvironmentVariable: () => "", + readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => { throw new Error("NYI"); }, - exit: (exitCode?: number) => { - }, - watchFile: (path, callback) => { - return { - close: () => { } - }; - }, - watchDirectory: (path, callback, recursive?) => { - return { - close: () => { } - }; - }, + exit: () => { }, + watchFile: () => ({ + close: () => { } + }), + watchDirectory: () => ({ + close: () => { } + }), setTimeout, clearTimeout, setImmediate, @@ -75,11 +68,11 @@ namespace ts { close() { }, hasLevel: () => false, loggingEnabled: () => false, - perftrc: (s: string) => { }, - info: (s: string) => { }, + perftrc: () => { }, + info: () => { }, startGroup: () => { }, endGroup: () => { }, - msg: (s: string, type?: string) => { }, + msg: () => { }, getLogFileName: (): string => undefined }; @@ -116,7 +109,7 @@ namespace ts { const originalFileExists = serverHost.fileExists; { // patch fileExists to make sure that disk is not touched - serverHost.fileExists = (fileName): boolean => { + serverHost.fileExists = (): boolean => { assert.isTrue(false, "fileExists should not be called"); return false; }; diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index 2c935439a9b63..addd01b0e0a08 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -101,7 +101,7 @@ namespace ts { Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json", () => JSON.stringify(comment.jsDoc, - (k, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4)); + (_, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4)); }); } diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index b2f7d0c224d3d..c21d2df401925 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -290,7 +290,7 @@ namespace ts { return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", - writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, + writeFile: (): void => { throw new Error("NotImplemented"); }, getCurrentDirectory: () => currentDirectory, getDirectories: () => [], getCanonicalFileName: fileName => fileName.toLowerCase(), @@ -300,7 +300,7 @@ namespace ts { const path = normalizePath(combinePaths(currentDirectory, fileName)); return path in files; }, - readFile: (fileName): string => { throw new Error("NotImplemented"); } + readFile: (): string => { throw new Error("NotImplemented"); } }; const program = createProgram(rootFiles, options, host); @@ -370,7 +370,7 @@ export = C; return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", - writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, + writeFile: (): void => { throw new Error("NotImplemented"); }, getCurrentDirectory: () => currentDirectory, getDirectories: () => [], getCanonicalFileName, @@ -380,7 +380,7 @@ export = C; const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); return path in files; }, - readFile: (fileName): string => { throw new Error("NotImplemented"); } + readFile: (): string => { throw new Error("NotImplemented"); } }; const program = createProgram(rootFiles, options, host); const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics())); @@ -1022,7 +1022,7 @@ import b = require("./moduleB"); fileExists : fileName => fileName in sourceFiles, getSourceFile: fileName => sourceFiles[fileName], getDefaultLibFileName: () => "lib.d.ts", - writeFile(file, text) { + writeFile(_file, _text) { throw new Error("NYI"); }, getCurrentDirectory: () => "/", diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 60687d34c55af..fcdfc6d08c641 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -111,13 +111,13 @@ namespace ts { getDefaultLibFileName(): string { return "lib.d.ts"; }, - writeFile(file, text) { + writeFile() { throw new Error("NYI"); }, getCurrentDirectory(): string { return ""; }, - getDirectories(path: string): string[] { + getDirectories(): string[] { return []; }, getCanonicalFileName(fileName): string { @@ -244,17 +244,13 @@ namespace ts { it("fails if change affects type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); - updateProgram(program_1, ["a.ts"], { types: ["b"] }, files => { - - }); + updateProgram(program_1, ["a.ts"], { types: ["b"] }, () => { }); assert.isTrue(!program_1.structureIsReused); }); it("succeeds if change doesn't affect type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); - updateProgram(program_1, ["a.ts"], { types: ["a"] }, files => { - - }); + updateProgram(program_1, ["a.ts"], { types: ["a"] }, () => { }); assert.isTrue(program_1.structureIsReused); }); @@ -280,19 +276,19 @@ namespace ts { it("fails if module kind changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, files => void 0); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, () => { }); assert.isTrue(!program_1.structureIsReused); }); it("fails if rootdir changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/b" }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, files => void 0); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, () => { }); assert.isTrue(!program_1.structureIsReused); }); it("fails if config path changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/b/tsconfig.json" }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, files => void 0); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, () => { }); assert.isTrue(!program_1.structureIsReused); }); diff --git a/src/harness/unittests/services/documentRegistry.ts b/src/harness/unittests/services/documentRegistry.ts index 09e95db6c76bd..ab624a17dbf02 100644 --- a/src/harness/unittests/services/documentRegistry.ts +++ b/src/harness/unittests/services/documentRegistry.ts @@ -62,7 +62,7 @@ describe("DocumentRegistry", () => { const snapshot = ts.ScriptSnapshot.fromString(contents); // Always treat any change as a full change. - snapshot.getChangeRange = old => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length); + snapshot.getChangeRange = () => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length); // Simulate one LS getting the document. documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1"); diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 9099f0a4285d1..0d8fb31e5d86c 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -18,11 +18,11 @@ namespace ts.server { createDirectory(): void {}, getExecutingFilePath(): string { return void 0; }, getCurrentDirectory(): string { return void 0; }, - getEnvironmentVariable(name: string): string { return ""; }, + getEnvironmentVariable(): string { return ""; }, readDirectory(): string[] { return []; }, exit(): void { }, - setTimeout(callback, ms, ...args) { return 0; }, - clearTimeout(timeoutId) { }, + setTimeout() { return 0; }, + clearTimeout() { }, setImmediate: () => 0, clearImmediate() {} }; @@ -31,11 +31,11 @@ namespace ts.server { close(): void {}, hasLevel(): boolean { return false; }, loggingEnabled(): boolean { return false; }, - perftrc(s: string): void {}, - info(s: string): void {}, + perftrc(): void {}, + info(): void {}, startGroup(): void {}, endGroup(): void {}, - msg(s: string, type?: string): void {}, + msg(): void {}, getLogFileName: (): string => undefined }; @@ -245,7 +245,7 @@ namespace ts.server { responseRequired: true }; - session.addProtocolHandler(command, (req) => result); + session.addProtocolHandler(command, () => result); expect(session.executeCommand({ command, @@ -263,9 +263,9 @@ namespace ts.server { }; const command = "newhandle"; - session.addProtocolHandler(command, (req) => resp); + session.addProtocolHandler(command, () => resp); - expect(() => session.addProtocolHandler(command, (req) => resp)) + expect(() => session.addProtocolHandler(command, () => resp)) .to.throw(`Protocol handler already exists for command "${command}"`); }); }); diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index c3962c7749419..de2fdd10e8ecb 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -72,7 +72,7 @@ namespace ts.projectSystem { this.postExecActions.forEach((act, i) => assert.equal(act.requestKind, expected[i], "Unexpected post install action")); } - onProjectClosed(p: server.Project) { + onProjectClosed() { } attach(projectService: server.ProjectService) { @@ -83,7 +83,7 @@ namespace ts.projectSystem { return this.installTypingHost; } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { switch (requestKind) { case TI.NpmViewRequest: case TI.NpmInstallRequest: @@ -122,7 +122,7 @@ namespace ts.projectSystem { return JSON.stringify({ dependencies: dependencies }); } - export function getExecutingFilePathFromLibFile(libFilePath: string): string { + export function getExecutingFilePathFromLibFile(_libFilePath: string): string { return combinePaths(getDirectoryPath(libFile.path), "tsc.js"); } @@ -322,9 +322,9 @@ namespace ts.projectSystem { count() { let n = 0; -/* tslint:disable:no-unused-variable */ for (const _ in this.map) { -/* tslint:enable:no-unused-variable */ + // TODO: GH#11734 + _; n++; } return n; @@ -473,7 +473,7 @@ namespace ts.projectSystem { } // TOOD: record and invoke callbacks to simulate timer events - setTimeout(callback: TimeOutCallback, time: number, ...args: any[]) { + setTimeout(callback: TimeOutCallback, _time: number, ...args: any[]) { return this.timeoutCallbacks.register(callback, args); }; @@ -490,7 +490,7 @@ namespace ts.projectSystem { this.timeoutCallbacks.invoke(); } - setImmediate(callback: TimeOutCallback, time: number, ...args: any[]) { + setImmediate(callback: TimeOutCallback, _time: number, ...args: any[]) { return this.immediateCallbacks.register(callback, args); } @@ -522,15 +522,14 @@ namespace ts.projectSystem { this.reloadFS(filesOrFolders); } - write(s: string) { - } + write() { } readonly readFile = (s: string) => (this.fs.get(this.toPath(s))).content; readonly resolvePath = (s: string) => s; readonly getExecutingFilePath = () => this.executingFilePath; readonly getCurrentDirectory = () => this.currentDirectory; - readonly exit = () => notImplemented(); - readonly getEnvironmentVariable = (v: string) => notImplemented(); + readonly exit = notImplemented; + readonly getEnvironmentVariable = notImplemented; } export function makeSessionRequest(command: string, args: T) { diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index ebd0f0ef7920c..323d8c0ed9e37 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -81,7 +81,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -125,7 +125,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -221,7 +221,7 @@ namespace ts.projectSystem { enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typingOptions); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -275,7 +275,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/lodash", "@types/react"]; const typingFiles = [lodash, react]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -323,7 +323,7 @@ namespace ts.projectSystem { enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typingOptions); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings: string[] = []; const typingFiles: FileOrFolder[] = []; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -398,7 +398,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment"]; const typingFiles = [commander, express, jquery, moment]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -477,7 +477,7 @@ namespace ts.projectSystem { constructor() { super(host, { throttleLimit: 3 }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment", "@types/lodash"]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); } @@ -567,7 +567,7 @@ namespace ts.projectSystem { constructor() { super(host, { throttleLimit: 3 }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { if (requestKind === TI.NpmInstallRequest) { let typingFiles: (FileOrFolder & { typings: string}) [] = []; if (args.indexOf("@types/commander") >= 0) { @@ -655,7 +655,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jqueryDTS]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -701,7 +701,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jqueryDTS]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -766,7 +766,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }, { isEnabled: () => true, writeLine: msg => messages.push(msg) }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest() { assert(false, "runCommand should not be invoked"); } })(); diff --git a/src/server/builder.ts b/src/server/builder.ts index 475202a0aabae..548a3ac854c0e 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -122,7 +122,7 @@ namespace ts.server { } protected forEachFileInfo(action: (fileInfo: T) => any) { - this.fileInfos.forEachValue((path: Path, value: T) => action(value)); + this.fileInfos.forEachValue((_path, value) => action(value)); } abstract getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index bcfe5ddb4657a..1c4c0d608261e 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "cancellationToken.ts" diff --git a/src/server/client.ts b/src/server/client.ts index 6d8ef419a7aae..adc55f96471fd 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -5,11 +5,6 @@ namespace ts.server { writeMessage(message: string): void; } - interface CompletionEntry extends CompletionInfo { - fileName: string; - position: number; - } - interface RenameEntry extends RenameInfo { fileName: string; position: number; @@ -246,7 +241,7 @@ namespace ts.server { return response.body[0]; } - getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol { + getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol { throw new Error("Not Implemented Yet."); } @@ -278,7 +273,7 @@ namespace ts.server { }); } - getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] { + getFormattingEditsForRange(fileName: string, start: number, end: number, _options: ts.FormatCodeOptions): ts.TextChange[] { const startLineOffset = this.positionToOneBasedLineOffset(fileName, start); const endLineOffset = this.positionToOneBasedLineOffset(fileName, end); const args: protocol.FormatRequestArgs = { @@ -300,7 +295,7 @@ namespace ts.server { return this.getFormattingEditsForRange(fileName, 0, this.host.getScriptSnapshot(fileName).getLength(), options); } - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] { + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, _options: FormatCodeOptions): ts.TextChange[] { const lineOffset = this.positionToOneBasedLineOffset(fileName, position); const args: protocol.FormatOnKeyRequestArgs = { file: fileName, @@ -390,7 +385,7 @@ namespace ts.server { }); } - findReferences(fileName: string, position: number): ReferencedSymbol[] { + findReferences(_fileName: string, _position: number): ReferencedSymbol[] { // Not yet implemented. return []; } @@ -419,7 +414,7 @@ namespace ts.server { }); } - getEmitOutput(fileName: string): EmitOutput { + getEmitOutput(_fileName: string): EmitOutput { throw new Error("Not Implemented Yet."); } @@ -441,7 +436,7 @@ namespace ts.server { return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); } - convertDiagnostic(entry: protocol.DiagnosticWithLinePosition, fileName: string): Diagnostic { + convertDiagnostic(entry: protocol.DiagnosticWithLinePosition, _fileName: string): Diagnostic { let category: DiagnosticCategory; for (const id in DiagnosticCategory) { if (typeof id === "string" && entry.category === id.toLowerCase()) { @@ -566,11 +561,11 @@ namespace ts.server { this.lineOffsetToPosition(fileName, span.end, lineMap)); } - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan { + getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan { throw new Error("Not Implemented Yet."); } - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan { + getBreakpointStatementAtPosition(_fileName: string, _position: number): TextSpan { throw new Error("Not Implemented Yet."); } @@ -660,19 +655,19 @@ namespace ts.server { } } - getOutliningSpans(fileName: string): OutliningSpan[] { + getOutliningSpans(_fileName: string): OutliningSpan[] { throw new Error("Not Implemented Yet."); } - getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { + getTodoComments(_fileName: string, _descriptors: TodoCommentDescriptor[]): TodoComment[] { throw new Error("Not Implemented Yet."); } - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion { + getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion { throw new Error("Not Implemented Yet."); } - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { + isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean { throw new Error("Not Implemented Yet."); } @@ -739,23 +734,23 @@ namespace ts.server { }); } - getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number { + getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number { throw new Error("Not Implemented Yet."); } - getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { + getSyntacticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { throw new Error("Not Implemented Yet."); } - getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { + getSemanticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { throw new Error("Not Implemented Yet."); } - getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications { + getEncodedSyntacticClassifications(_fileName: string, _span: TextSpan): Classifications { throw new Error("Not Implemented Yet."); } - getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications { + getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications { throw new Error("Not Implemented Yet."); } @@ -763,11 +758,11 @@ namespace ts.server { throw new Error("SourceFile objects are not serializable through the server protocol."); } - getNonBoundSourceFile(fileName: string): SourceFile { + getNonBoundSourceFile(_fileName: string): SourceFile { throw new Error("SourceFile objects are not serializable through the server protocol."); } - getSourceFile(fileName: string): SourceFile { + getSourceFile(_fileName: string): SourceFile { throw new Error("SourceFile objects are not serializable through the server protocol."); } diff --git a/src/server/scriptVersionCache.ts b/src/server/scriptVersionCache.ts index 8d0efa081adaf..f094a183610c1 100644 --- a/src/server/scriptVersionCache.ts +++ b/src/server/scriptVersionCache.ts @@ -41,7 +41,7 @@ namespace ts.server { class BaseLineIndexWalker implements ILineIndexWalker { goSubtree = true; done = false; - leaf(rangeStart: number, rangeLength: number, ll: LineLeaf) { + leaf(_rangeStart: number, _rangeLength: number, _ll: LineLeaf) { } } @@ -150,7 +150,7 @@ namespace ts.server { return this.lineIndex; } - post(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection): LineCollection { + post(_relativeStart: number, _relativeLength: number, lineCollection: LineCollection): LineCollection { // have visited the path for start of range, now looking for end // if range is on single line, we will never make this state transition if (lineCollection === this.lineCollectionAtBranch) { @@ -161,7 +161,7 @@ namespace ts.server { return undefined; } - pre(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection) { + pre(_relativeStart: number, _relativeLength: number, lineCollection: LineCollection, _parent: LineCollection, nodeType: CharRangeSection) { // currentNode corresponds to parent, but in the new tree const currentNode = this.stack[this.stack.length - 1]; @@ -414,7 +414,7 @@ namespace ts.server { const starts: number[] = [-1]; let count = 1; let pos = 0; - this.index.every((ll, s, len) => { + this.index.every(ll => { starts[count] = pos; count++; pos += ll.text.length; diff --git a/src/server/server.ts b/src/server/server.ts index e728d7e9d723c..6ddd267f56e7d 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -53,14 +53,6 @@ namespace ts.server { historySize?: number; } - interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } - interface Stats { isFile(): boolean; isDirectory(): boolean; @@ -192,7 +184,7 @@ namespace ts.server { constructor( private readonly logger: server.Logger, - private readonly eventPort: number, + eventPort: number, readonly globalTypingsCacheLocation: string, private newLine: string) { if (eventPort) { @@ -218,7 +210,7 @@ namespace ts.server { const match = /^--(debug|inspect)(=(\d+))?$/.exec(arg); if (match) { // if port is specified - use port + 1 - // otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1 + // otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1 const currentPort = match[3] !== undefined ? +match[3] : match[1] === "debug" ? 5858 : 9229; diff --git a/src/server/session.ts b/src/server/session.ts index 3bf4acd248622..545701f1449fa 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1300,7 +1300,7 @@ namespace ts.server { } // No need to analyze lib.d.ts - let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0); + let fileNamesInProject = fileNames.filter(value => value.indexOf("lib.d.ts") < 0); // Sort the file name list to make the recently touched files come first const highPriorityFiles: NormalizedPath[] = []; @@ -1500,7 +1500,7 @@ namespace ts.server { [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => { return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments)); }, - [CommandNames.Cleanup]: (request: protocol.Request) => { + [CommandNames.Cleanup]: () => { this.cleanup(); return this.requiredResponse(true); }, @@ -1581,7 +1581,7 @@ namespace ts.server { [CommandNames.ProjectInfo]: (request: protocol.ProjectInfoRequest) => { return this.requiredResponse(this.getProjectInfo(request.arguments)); }, - [CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => { + [CommandNames.ReloadProjects]: () => { this.projectService.reloadProjects(); return this.notRequired(); }, @@ -1591,7 +1591,7 @@ namespace ts.server { [CommandNames.GetCodeFixesFull]: (request: protocol.CodeFixRequest) => { return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ false)); }, - [CommandNames.GetSupportedCodeFixes]: (request: protocol.Request) => { + [CommandNames.GetSupportedCodeFixes]: () => { return this.requiredResponse(this.getSupportedCodeFixes()); } }); diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 5308abb0c8457..a99994d97c5f9 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../services/shims.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index a287a77fed5d8..e269629b55898 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -8,7 +8,9 @@ "stripInternal": true, "declaration": true, "types": [], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../services/shims.ts", diff --git a/src/server/typingsCache.ts b/src/server/typingsCache.ts index 889cfe1fb8f67..d522974cc5b74 100644 --- a/src/server/typingsCache.ts +++ b/src/server/typingsCache.ts @@ -10,8 +10,8 @@ namespace ts.server { export const nullTypingsInstaller: ITypingsInstaller = { enqueueInstallTypingsRequest: () => {}, - attach: (projectService: ProjectService) => {}, - onProjectClosed: (p: Project) => {}, + attach: () => {}, + onProjectClosed: () => {}, globalTypingsCacheLocation: undefined }; diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index ff643e885e432..8941926493051 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -126,7 +126,7 @@ namespace ts.server.typingsInstaller { case NpmInstallRequest: { const command = `${this.npmPath} install ${args.join(" ")} --save-dev`; const start = Date.now(); - this.exec(command, { cwd }, (err, stdout, stderr) => { + this.exec(command, { cwd }, (_err, stdout, stderr) => { if (this.log.isEnabled()) { this.log.writeLine(`${requestKind} #${requestId} took: ${Date.now() - start} ms${sys.newLine}stdout: ${stdout}${sys.newLine}stderr: ${stderr}`); } diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index 58805081de698..c9b4d8f0ad14a 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../types.d.ts", diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index f62f5fc4abe5c..58d56195068f9 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -35,7 +35,7 @@ namespace ts.server.typingsInstaller { export const MaxPackageNameLength = 214; /** - * Validates package name using rules defined at https://docs.npmjs.com/files/package.json + * Validates package name using rules defined at https://docs.npmjs.com/files/package.json */ export function validatePackageName(packageName: string): PackageNameValidationResult { Debug.assert(!!packageName, "Package name is not specified"); @@ -131,7 +131,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Got install request ${JSON.stringify(req)}`); } - // load existing typing information from the cache + // load existing typing information from the cache if (req.cachePath) { if (this.log.isEnabled()) { this.log.writeLine(`Request specifies cache path '${req.cachePath}', loading cached information...`); @@ -145,8 +145,7 @@ namespace ts.server.typingsInstaller { req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, - req.typingOptions, - req.compilerOptions); + req.typingOptions); if (this.log.isEnabled()) { this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); diff --git a/src/services/completions.ts b/src/services/completions.ts index 3b76fdc8c3b82..ba5d150307519 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -179,7 +179,7 @@ namespace ts.Completions { // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } // Get completion for string literal from string literal type @@ -199,7 +199,7 @@ namespace ts.Completions { } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, location: Node) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) { const candidates: Signature[] = []; const entries: CompletionEntry[] = []; @@ -361,7 +361,7 @@ namespace ts.Completions { /** * 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(); @@ -617,7 +617,7 @@ namespace ts.Completions { if (typeRoots) { for (const root of typeRoots) { - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -626,14 +626,14 @@ namespace ts.Completions { // 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, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, span: TextSpan, result: CompletionEntry[]) { + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: CompletionEntry[]) { if (host.getDirectories && tryDirectoryExists(host, directory)) { const directories = tryGetDirectories(host, directory); if (directories) { @@ -1708,11 +1708,11 @@ namespace ts.Completions { * to determine if the caret is currently within the string literal and capture the literal fragment * for completions. * For example, this matches - * + * * /// , - typingOptions: TypingOptions, - compilerOptions: CompilerOptions): + typingOptions: TypingOptions): { cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } { // A typing name to typing file path mapping diff --git a/src/services/services.ts b/src/services/services.ts index 666644aca1b8e..9ed73318d8e50 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -264,23 +264,23 @@ namespace ts { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); } - public getChildCount(sourceFile?: SourceFile): number { + public getChildCount(): number { return 0; } - public getChildAt(index: number, sourceFile?: SourceFile): Node { + public getChildAt(): Node { return undefined; } - public getChildren(sourceFile?: SourceFile): Node[] { + public getChildren(): Node[] { return emptyArray; } - public getFirstToken(sourceFile?: SourceFile): Node { + public getFirstToken(): Node { return undefined; } - public getLastToken(sourceFile?: SourceFile): Node { + public getLastToken(): Node { return undefined; } } @@ -313,7 +313,7 @@ namespace ts { getDocumentationComment(): SymbolDisplayPart[] { if (this.documentationComment === undefined) { - this.documentationComment = JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & SymbolFlags.Property)); + this.documentationComment = JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; @@ -338,7 +338,7 @@ namespace ts { _incrementExpressionBrand: any; _unaryExpressionBrand: any; _expressionBrand: any; - constructor(kind: SyntaxKind.Identifier, pos: number, end: number) { + constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) { super(pos, end); } } @@ -423,10 +423,7 @@ namespace ts { getDocumentationComment(): SymbolDisplayPart[] { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? JsDoc.getJsDocCommentsFromDeclarations( - [this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; + this.documentationComment = this.declaration ? JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; @@ -802,7 +799,7 @@ namespace ts { public getRootFileNames(): string[] { const fileNames: string[] = []; - this.fileNameToEntry.forEachValue((path, value) => { + this.fileNameToEntry.forEachValue((_path, value) => { if (value) { fileNames.push(value.hostFileName); } @@ -1054,7 +1051,7 @@ namespace ts { useCaseSensitiveFileNames: () => useCaseSensitivefileNames, getNewLine: () => getNewLineOrDefaultFromHost(host), getDefaultLibFileName: (options) => host.getDefaultLibFileName(options), - writeFile: (fileName, data, writeByteOrderMark) => { }, + writeFile: () => { }, getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { // stub missing host functionality @@ -1458,7 +1455,7 @@ namespace ts { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan { + function getNameOrDottedNameSpan(fileName: string, startPos: number, _endPos: number): TextSpan { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location diff --git a/src/services/shims.ts b/src/services/shims.ts index 571f009d86645..bd4c48838dabc 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -119,13 +119,13 @@ namespace ts { } export interface Shim { - dispose(dummy: any): void; + dispose(_dummy: any): void; } export interface LanguageServiceShim extends Shim { languageService: LanguageService; - dispose(dummy: any): void; + dispose(_dummy: any): void; refresh(throwOnError: boolean): void; @@ -600,7 +600,7 @@ namespace ts { constructor(private factory: ShimFactory) { factory.registerShim(this); } - public dispose(dummy: any): void { + public dispose(_dummy: any): void { this.factory.unregisterShim(this); } } @@ -1168,8 +1168,7 @@ namespace ts { toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, - info.typingOptions, - info.compilerOptions); + info.typingOptions); }); } } diff --git a/src/services/transpile.ts b/src/services/transpile.ts index 303ca0d4173a2..da54faed1a2f7 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -74,8 +74,8 @@ namespace ts { // Create a compilerHost object to allow the compiler to read and write files const compilerHost: CompilerHost = { - getSourceFile: (fileName, target) => fileName === normalizePath(inputFileName) ? sourceFile : undefined, - writeFile: (name, text, writeByteOrderMark) => { + getSourceFile: (fileName) => fileName === normalizePath(inputFileName) ? sourceFile : undefined, + writeFile: (name, text) => { if (fileExtensionIs(name, ".map")) { Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`); sourceMapText = text; @@ -91,9 +91,9 @@ namespace ts { getCurrentDirectory: () => "", getNewLine: () => newLine, fileExists: (fileName): boolean => fileName === inputFileName, - readFile: (fileName): string => "", - directoryExists: directoryExists => true, - getDirectories: (path: string) => [] + readFile: () => "", + directoryExists: () => true, + getDirectories: () => [] }; const program = createProgram([inputFileName], options, compilerHost); diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 4e130c7dfb2c8..e81db68325c05 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -10,7 +10,9 @@ "stripInternal": true, "noResolve": false, "declaration": true, - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../compiler/core.ts", diff --git a/src/services/types.ts b/src/services/types.ts index 3d2bcf4c36019..4e04df3fc7caf 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -97,7 +97,7 @@ namespace ts { return this.text.length; } - public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange { + public getChangeRange(): TextChangeRange { // Text-based snapshots do not support incremental parsing. Return undefined // to signal that to the caller. return undefined; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index b83262a9d8c58..45dff60dd89f1 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1179,7 +1179,7 @@ namespace ts { } export function symbolPart(text: string, symbol: Symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol: Symbol): SymbolDisplayPartKind { const flags = symbol.flags; @@ -1205,7 +1205,7 @@ namespace ts { } } - export function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart { + export function displayPart(text: string, kind: SymbolDisplayPartKind): SymbolDisplayPart { return { text: text, kind: SymbolDisplayPartKind[kind] From c877635b470e43fcbc8bbf38039d0712c75969ef Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 19 Oct 2016 09:13:52 -0700 Subject: [PATCH 2/2] Don't need `libFilePath` parameter --- src/harness/unittests/tsserverProjectSystem.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index de2fdd10e8ecb..a1ef87c24830b 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -122,7 +122,7 @@ namespace ts.projectSystem { return JSON.stringify({ dependencies: dependencies }); } - export function getExecutingFilePathFromLibFile(_libFilePath: string): string { + export function getExecutingFilePathFromLibFile(): string { return combinePaths(getDirectoryPath(libFile.path), "tsc.js"); } @@ -154,16 +154,13 @@ namespace ts.projectSystem { currentDirectory?: string; } - export function createServerHost(fileOrFolderList: FileOrFolder[], - params?: TestServerHostCreationParameters, - libFilePath: string = libFile.path): TestServerHost { - + export function createServerHost(fileOrFolderList: FileOrFolder[], params?: TestServerHostCreationParameters): TestServerHost { if (!params) { params = {}; } const host = new TestServerHost( params.useCaseSensitiveFileNames !== undefined ? params.useCaseSensitiveFileNames : false, - params.executingFilePath || getExecutingFilePathFromLibFile(libFilePath), + params.executingFilePath || getExecutingFilePathFromLibFile(), params.currentDirectory || "/", fileOrFolderList); host.createFileOrFolder(safeList, /*createParentDirectory*/ true);